Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void populatorMarkedAsFailed() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PopulatorMarkedAsFailed()
        {
            SetProperty(BATCH_SIZE_NAME, 2);

            EntityUpdates  update1   = NodeUpdates(1, PROPERTY_ID, "aaa", LABEL_ID);
            EntityUpdates  update2   = NodeUpdates(1, PROPERTY_ID, "bbb", LABEL_ID);
            IndexStoreView storeView = NewStoreView(update1, update2);

            Exception batchFlushError = new Exception("Batch failed");

            IndexPopulator  populator;
            ExecutorService executor = Executors.newSingleThreadExecutor();

            try
            {
                BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, executor, NullLogProvider.Instance, mock(typeof(SchemaState)));

                populator = AddPopulator(batchingPopulator, _index1);
                IList <IndexEntryUpdate <IndexDescriptor> > expected = ForUpdates(_index1, update1, update2);
                doThrow(batchFlushError).when(populator).add(expected);

                batchingPopulator.IndexAllEntities().run();
            }
            finally
            {
                executor.shutdown();
                executor.awaitTermination(1, TimeUnit.MINUTES);
            }

            verify(populator).markAsFailed(failure(batchFlushError).asString());
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void populatorMarkedAsFailedAndUpdatesNotAdded() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PopulatorMarkedAsFailedAndUpdatesNotAdded()
        {
            SetProperty(BATCH_SIZE_NAME, 2);

            EntityUpdates  update1   = NodeUpdates(1, PROPERTY_ID, "aaa", LABEL_ID);
            EntityUpdates  update2   = NodeUpdates(1, PROPERTY_ID, "bbb", LABEL_ID);
            EntityUpdates  update3   = NodeUpdates(1, PROPERTY_ID, "ccc", LABEL_ID);
            EntityUpdates  update4   = NodeUpdates(1, PROPERTY_ID, "ddd", LABEL_ID);
            EntityUpdates  update5   = NodeUpdates(1, PROPERTY_ID, "eee", LABEL_ID);
            IndexStoreView storeView = NewStoreView(update1, update2, update3, update4, update5);

            Exception batchFlushError = new Exception("Batch failed");

            BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, SameThreadExecutor(), NullLogProvider.Instance, mock(typeof(SchemaState)));

            IndexPopulator populator = AddPopulator(batchingPopulator, _index1);

            doThrow(batchFlushError).when(populator).add(ForUpdates(_index1, update3, update4));

            batchingPopulator.IndexAllEntities().run();

            verify(populator).add(ForUpdates(_index1, update1, update2));
            verify(populator).add(ForUpdates(_index1, update3, update4));
            verify(populator).markAsFailed(failure(batchFlushError).asString());
            verify(populator, never()).add(ForUpdates(_index1, update5));
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void populateFromQueueDoesNothingIfThresholdNotReached() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PopulateFromQueueDoesNothingIfThresholdNotReached()
        {
            SetProperty(QUEUE_THRESHOLD_NAME, 5);

            BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(mock(typeof(IndexStoreView)), ImmediateExecutor(), NullLogProvider.Instance, mock(typeof(SchemaState)));

            IndexPopulator populator = AddPopulator(batchingPopulator, _index1);
            IndexUpdater   updater   = mock(typeof(IndexUpdater));

            when(populator.NewPopulatingUpdater(any())).thenReturn(updater);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update1 = add(1, index1.schema(), "foo");
            IndexEntryUpdate <object> update1 = add(1, _index1.schema(), "foo");
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update2 = add(2, index1.schema(), "bar");
            IndexEntryUpdate <object> update2 = add(2, _index1.schema(), "bar");

            batchingPopulator.QueueUpdate(update1);
            batchingPopulator.QueueUpdate(update2);

            batchingPopulator.PopulateFromQueueBatched(42);

            verify(updater, never()).process(any());
            verify(populator, never()).newPopulatingUpdater(any());
        }
Exemple #4
0
        private static IndexPopulator AddPopulator(BatchingMultipleIndexPopulator batchingPopulator, IndexDescriptor descriptor)
        {
            IndexPopulator populator = mock(typeof(IndexPopulator));

            IndexProxyFactory       indexProxyFactory       = mock(typeof(IndexProxyFactory));
            FailedIndexProxyFactory failedIndexProxyFactory = mock(typeof(FailedIndexProxyFactory));
            FlippableIndexProxy     flipper = new FlippableIndexProxy();

            flipper.FlipTarget = indexProxyFactory;

            batchingPopulator.AddPopulator(populator, descriptor.WithId(1).withoutCapabilities(), flipper, failedIndexProxyFactory, "testIndex");

            return(populator);
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void batchIsFlushedWhenThresholdReached() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BatchIsFlushedWhenThresholdReached()
        {
            SetProperty(BATCH_SIZE_NAME, 2);

            EntityUpdates  update1   = NodeUpdates(1, PROPERTY_ID, "foo", LABEL_ID);
            EntityUpdates  update2   = NodeUpdates(2, PROPERTY_ID, "bar", LABEL_ID);
            EntityUpdates  update3   = NodeUpdates(3, PROPERTY_ID, "baz", LABEL_ID);
            IndexStoreView storeView = NewStoreView(update1, update2, update3);

            BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, SameThreadExecutor(), NullLogProvider.Instance, mock(typeof(SchemaState)));

            IndexPopulator populator = AddPopulator(batchingPopulator, _index1);

            batchingPopulator.IndexAllEntities().run();

            verify(populator).add(ForUpdates(_index1, update1, update2));
            verify(populator).add(ForUpdates(_index1, update3));
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pendingBatchesFlushedAfterStoreScan() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PendingBatchesFlushedAfterStoreScan()
        {
            EntityUpdates  update1   = NodeUpdates(1, PROPERTY_ID, "foo", LABEL_ID);
            EntityUpdates  update2   = NodeUpdates(2, PROPERTY_ID, "bar", LABEL_ID);
            EntityUpdates  update3   = NodeUpdates(3, PROPERTY_ID, "baz", LABEL_ID);
            EntityUpdates  update42  = NodeUpdates(4, 42, "42", 42);
            IndexStoreView storeView = NewStoreView(update1, update2, update3, update42);

            BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, SameThreadExecutor(), NullLogProvider.Instance, mock(typeof(SchemaState)));

            IndexPopulator populator1  = AddPopulator(batchingPopulator, _index1);
            IndexPopulator populator42 = AddPopulator(batchingPopulator, _index42);

            batchingPopulator.IndexAllEntities().run();

            verify(populator1).add(ForUpdates(_index1, update1, update2, update3));
            verify(populator42).add(ForUpdates(_index42, update42));
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void populateFromQueuePopulatesWhenThresholdReached() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PopulateFromQueuePopulatesWhenThresholdReached()
        {
            SetProperty(QUEUE_THRESHOLD_NAME, 2);

            NeoStores neoStores = mock(typeof(NeoStores));
            NodeStore nodeStore = mock(typeof(NodeStore));

            when(neoStores.NodeStore).thenReturn(nodeStore);

            NeoStoreIndexStoreView         storeView         = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, neoStores);
            BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, ImmediateExecutor(), NullLogProvider.Instance, mock(typeof(SchemaState)));

            IndexPopulator populator1 = AddPopulator(batchingPopulator, _index1);
            IndexUpdater   updater1   = mock(typeof(IndexUpdater));

            when(populator1.NewPopulatingUpdater(any())).thenReturn(updater1);

            IndexPopulator populator2 = AddPopulator(batchingPopulator, _index42);
            IndexUpdater   updater2   = mock(typeof(IndexUpdater));

            when(populator2.NewPopulatingUpdater(any())).thenReturn(updater2);

            batchingPopulator.IndexAllEntities();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update1 = add(1, index1.schema(), "foo");
            IndexEntryUpdate <object> update1 = add(1, _index1.schema(), "foo");
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update2 = add(2, index42.schema(), "bar");
            IndexEntryUpdate <object> update2 = add(2, _index42.schema(), "bar");
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update3 = add(3, index1.schema(), "baz");
            IndexEntryUpdate <object> update3 = add(3, _index1.schema(), "baz");

            batchingPopulator.QueueUpdate(update1);
            batchingPopulator.QueueUpdate(update2);
            batchingPopulator.QueueUpdate(update3);

            batchingPopulator.PopulateFromQueueBatched(42);

            verify(updater1).process(update1);
            verify(updater1).process(update3);
            verify(updater2).process(update2);
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldApplyBatchesInParallel() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldApplyBatchesInParallel()
        {
            // given
            SetProperty(BATCH_SIZE_NAME, 2);
            EntityUpdates[] updates = new EntityUpdates[9];
            for (int i = 0; i < updates.Length; i++)
            {
                updates[i] = NodeUpdates(i, PROPERTY_ID, i.ToString(), LABEL_ID);
            }
            IndexStoreView  storeView = NewStoreView(updates);
            ExecutorService executor  = SameThreadExecutor();
            BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, executor, NullLogProvider.Instance, mock(typeof(SchemaState)));

            AddPopulator(batchingPopulator, _index1);

            // when
            batchingPopulator.IndexAllEntities().run();

            // then
            verify(executor, atLeast(5)).execute(any(typeof(ThreadStart)));
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void executorShutdownAfterStoreScanCompletes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ExecutorShutdownAfterStoreScanCompletes()
        {
            EntityUpdates  update    = NodeUpdates(1, PROPERTY_ID, "foo", LABEL_ID);
            IndexStoreView storeView = NewStoreView(update);

            ExecutorService executor = ImmediateExecutor();

            when(executor.awaitTermination(anyLong(), any())).thenReturn(true);

            BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, executor, NullLogProvider.Instance, mock(typeof(SchemaState)));

            StoreScan <IndexPopulationFailedKernelException> storeScan = batchingPopulator.IndexAllEntities();

            verify(executor, never()).shutdown();

            storeScan.Run();
            verify(executor, never()).shutdown();
            verify(executor, never()).awaitTermination(anyLong(), any());

            batchingPopulator.Close(true);
            verify(executor).shutdown();
            verify(executor).awaitTermination(anyLong(), any());
        }
Exemple #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void executorForcefullyShutdownIfStoreScanFails() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ExecutorForcefullyShutdownIfStoreScanFails()
        {
            IndexStoreView        storeView        = mock(typeof(IndexStoreView));
            StoreScan <Exception> failingStoreScan = mock(typeof(StoreScan));
            Exception             scanError        = new Exception();

            doThrow(scanError).when(failingStoreScan).run();
            when(storeView.VisitNodes(any(), any(), any(), any(), anyBoolean())).thenReturn(failingStoreScan);

            ExecutorService executor = ImmediateExecutor();

            when(executor.awaitTermination(anyLong(), any())).thenReturn(true);

            BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, executor, NullLogProvider.Instance, mock(typeof(SchemaState)));

            StoreScan <IndexPopulationFailedKernelException> storeScan = batchingPopulator.IndexAllEntities();

            verify(executor, never()).shutdown();

            try
            {
                storeScan.Run();
                fail("Exception expected");
            }
            catch (Exception t)
            {
                assertSame(scanError, t);
            }

            verify(executor, never()).shutdownNow();
            verify(executor, never()).awaitTermination(anyLong(), any());

            batchingPopulator.Close(false);
            verify(executor).shutdownNow();
            verify(executor).awaitTermination(anyLong(), any());
        }
 internal BatchingStoreScan(BatchingMultipleIndexPopulator outerInstance, StoreScan <E> @delegate) : base(@delegate)
 {
     this._outerInstance = outerInstance;
 }