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));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConvertDynamicAddedProperty()
        public virtual void ShouldConvertDynamicAddedProperty()
        {
            // GIVEN
            int            key    = 10;
            PropertyRecord before = PropertyRecord();
            PropertyRecord after  = PropertyRecord(Property(key, _longString));

            // THEN
            assertThat(Convert(_none, _none, Change(before, after)), equalTo(EntityUpdates.ForEntity(0, false).added(key, _longString).build()));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIgnoreInlinedUnchangedProperty()
        public virtual void ShouldIgnoreInlinedUnchangedProperty()
        {
            // GIVEN
            int            key    = 10;
            Value          value  = Values.of(12341);
            PropertyRecord before = PropertyRecord(Property(key, value));
            PropertyRecord after  = PropertyRecord(Property(key, value));

            // WHEN
            assertThat(Convert(_none, _none, Change(before, after)), equalTo(EntityUpdates.ForEntity(0, false).build()));
        }
Exemple #5
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
            EntityUpdates that = ( EntityUpdates )o;

            return(_entityId == that._entityId && Arrays.Equals(_entityTokensBefore, that._entityTokensBefore) && Arrays.Equals(_entityTokensAfter, that._entityTokensAfter));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConvertDynamicInlinedRemovedProperty()
        public virtual void ShouldConvertDynamicInlinedRemovedProperty()
        {
            // GIVEN
            int            key    = 10;
            PropertyRecord before = PropertyRecord(Property(key, _longString));
            PropertyRecord after  = PropertyRecord();

            // WHEN
            EntityUpdates update = Convert(_none, _none, Change(before, after));

            // THEN
            EntityUpdates expected = EntityUpdates.ForEntity(0, false).removed(key, _longString).build();

            assertEquals(expected, update);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConvertInlinedRemovedProperty()
        public virtual void ShouldConvertInlinedRemovedProperty()
        {
            // GIVEN
            int            key    = 10;
            Value          value  = Values.of(12341);
            PropertyRecord before = PropertyRecord(Property(key, value));
            PropertyRecord after  = PropertyRecord();

            // WHEN
            EntityUpdates update = Convert(_none, _none, Change(before, after));

            // THEN
            EntityUpdates expected = EntityUpdates.ForEntity(0, false).removed(key, value).build();

            assertEquals(expected, update);
        }
        private EntityUpdates Convert(long[] labelsBefore, long[] labelsAfter, params Command.PropertyCommand[] changes)
        {
            long nodeId = 0;

            EntityUpdates.Builder updates = EntityUpdates.ForEntity(( long )0, false).withTokens(labelsBefore).withTokensAfter(labelsAfter);
            EntityCommandGrouper  grouper = new EntityCommandGrouper <>(typeof(Command.NodeCommand), 8);

            grouper.add(new Command.NodeCommand(new NodeRecord(nodeId), new NodeRecord(nodeId)));
            foreach (Command.PropertyCommand change in changes)
            {
                grouper.add(change);
            }
            EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();
            assertTrue(cursor.NextEntity());
            _converter.convertPropertyRecord(cursor, updates);
            return(updates.Build());
        }
Exemple #9
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 #10
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));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTreatPropertyThatMovedToAnotherRecordAsChange()
        public virtual void ShouldTreatPropertyThatMovedToAnotherRecordAsChange()
        {
            // GIVEN
            int   key      = 12;
            Value oldValue = Values.of("value1");
            Value newValue = Values.of("value two");

            Command.PropertyCommand movedFrom = Change(PropertyRecord(Property(key, oldValue)), PropertyRecord());
            Command.PropertyCommand movedTo   = Change(PropertyRecord(), PropertyRecord(Property(key, newValue)));

            // WHEN
            EntityUpdates update = Convert(_none, _none, movedFrom, movedTo);

            // THEN
            EntityUpdates expected = EntityUpdates.ForEntity(0, false).changed(key, oldValue, newValue).build();

            assertEquals(expected, update);
        }
Exemple #12
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 #13
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 #14
0
 public virtual Builder Added(int propertyKeyId, Value value)
 {
     Updates.put(propertyKeyId, EntityUpdates.After(value));
     return(this);
 }
Exemple #15
0
 public virtual Builder Existing(int propertyKeyId, Value value)
 {
     Updates.put(propertyKeyId, EntityUpdates.Unchanged(value));
     return(this);
 }
Exemple #16
0
 public virtual Builder Changed(int propertyKeyId, Value before, Value after)
 {
     Updates.put(propertyKeyId, EntityUpdates.changed(before, after));
     return(this);
 }
Exemple #17
0
 internal Builder(EntityUpdates updates)
 {
     this.Updates = updates;
 }
Exemple #18
0
 private EntityUpdates NodeUpdates(int nodeId, int propertyId, string propertyValue, params long[] labelIds)
 {
     return(EntityUpdates.ForEntity(( long )nodeId, false).withTokens(labelIds).withTokensAfter(labelIds).added(propertyId, Values.of(propertyValue)).build());
 }
Exemple #19
0
 public virtual Builder Removed(int propertyKeyId, Value value)
 {
     Updates.put(propertyKeyId, EntityUpdates.Before(value));
     return(this);
 }