//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldApplyIndexUpdatesInWorkSyncedBatches() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldApplyIndexUpdatesInWorkSyncedBatches()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            long duration = parseTimeMillis.apply(System.getProperty(this.GetType().FullName + ".duration", "2s"));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            int numThreads = Integer.getInteger(this.GetType().FullName + ".numThreads", Runtime.Runtime.availableProcessors());
            DefaultFileSystemAbstraction fs   = _fileSystemRule.get();
            PageCache           pageCache     = _pageCacheRule.getPageCache(fs);
            FusionIndexProvider indexProvider = NativeLuceneFusionIndexProviderFactory20.create(pageCache, _directory.databaseDir(), fs, IndexProvider.Monitor_Fields.EMPTY, Config.defaults(), OperationalMode.single, RecoveryCleanupWorkCollector.immediate());
            RecordStorageEngine storageEngine = _storageEngineRule.getWith(fs, pageCache, _directory.databaseLayout()).indexProvider(indexProvider).build();

            storageEngine.Apply(Tx(singletonList(createIndexRule(DESCRIPTOR, 1, _descriptor))), TransactionApplicationMode.EXTERNAL);
            Dependencies dependencies = new Dependencies();

            storageEngine.SatisfyDependencies(dependencies);
            IndexProxy index = dependencies.ResolveDependency(typeof(IndexingService)).getIndexProxy(_descriptor);

            AwaitOnline(index);

            // WHEN
            Workers <Worker> workers = new Workers <Worker>(this.GetType().Name);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean end = new java.util.concurrent.atomic.AtomicBoolean();
            AtomicBoolean end = new AtomicBoolean();

            for (int i = 0; i < numThreads; i++)
            {
                workers.Start(new Worker(this, i, end, storageEngine, 10, index));
            }

            // let the threads hammer the storage engine for some time
            Thread.Sleep(duration);
            end.set(true);

            // THEN (assertions as part of the workers applying transactions)
            workers.AwaitAndThrowOnError();
        }
Ejemplo n.º 2
0
            public override Lifecycle NewInstance(KernelContext context, SchemaIndexHaIT.IndexProviderDependencies deps)
            {
                PageCache pageCache             = deps.PageCache();
                File      databaseDirectory     = context.Directory();
                DefaultFileSystemAbstraction fs = FileSystemRule.get();

                IndexProvider.Monitor monitor   = IndexProvider.Monitor_Fields.EMPTY;
                Config          config          = deps.Config();
                OperationalMode operationalMode = context.DatabaseInfo().OperationalMode;
                RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = deps.RecoveryCleanupWorkCollector();

                FusionIndexProvider fusionIndexProvider = NativeLuceneFusionIndexProviderFactory20.create(pageCache, databaseDirectory, fs, monitor, config, operationalMode, recoveryCleanupWorkCollector);

                if (InjectLatchPredicate.test(deps.Db()))
                {
                    ControlledIndexProvider provider = new ControlledIndexProvider(fusionIndexProvider);
                    PerDbIndexProvider[deps.Db()] = provider;
                    return(provider);
                }
                else
                {
                    return(fusionIndexProvider);
                }
            }