//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCheckAllCollisionsFromPopulatorAdd() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCheckAllCollisionsFromPopulatorAdd() { // given _populator = NewPopulator(); int iterations = 228; // This value has to be high enough to stress the EntrySet implementation IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); for (int nodeId = 0; nodeId < iterations; nodeId++) { updater.Process(add(nodeId, _schemaDescriptor, 1)); when(_nodePropertyAccessor.getNodePropertyValue(nodeId, PROPERTY_KEY_ID)).thenReturn(Values.of(nodeId)); } // ... and the actual conflicting property: updater.Process(add(iterations, _schemaDescriptor, 1)); when(_nodePropertyAccessor.getNodePropertyValue(iterations, PROPERTY_KEY_ID)).thenReturn(Values.of(1)); // This collision is real!!! // when try { updater.Close(); fail("should have thrown exception"); } // then catch (IndexEntryConflictException conflict) { assertEquals(1, conflict.ExistingNodeId); assertEquals(Values.of(1), conflict.SinglePropertyValue); assertEquals(iterations, conflict.AddedNodeId); } }
public override void Process <T1>(IndexEntryUpdate <T1> update) { Pair <IndexPopulation, IndexUpdater> pair = PopulationsWithUpdaters[update.IndexKey().schema()]; if (pair != null) { IndexPopulation population = pair.First(); IndexUpdater updater = pair.Other(); try { population.Populator.includeSample(update); updater.Process(update); } catch (Exception t) { try { updater.Close(); } catch (Exception ce) { Log.error(format("Failed to close index updater: [%s]", updater), ce); } PopulationsWithUpdaters.Remove(update.IndexKey().schema()); MultipleIndexPopulator.fail(population, t); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRejectDuplicateEntryWhenUsingPopulatingUpdater() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRejectDuplicateEntryWhenUsingPopulatingUpdater() { // given _populator = NewPopulator(); AddUpdate(_populator, 1, "value1"); AddUpdate(_populator, 2, "value2"); Value value = Values.of("value1"); when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(value); when(_nodePropertyAccessor.getNodePropertyValue(3, PROPERTY_KEY_ID)).thenReturn(value); // when try { IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); updater.Process(add(3, _schemaDescriptor, "value1")); updater.Close(); fail("should have thrown exception"); } // then catch (IndexEntryConflictException conflict) { assertEquals(1, conflict.ExistingNodeId); assertEquals(value, conflict.SinglePropertyValue); assertEquals(3, conflict.AddedNodeId); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void updaterShouldThrowOnDuplicateValues() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void UpdaterShouldThrowOnDuplicateValues() { // given outerInstance.populator.create(); IndexEntryUpdate <IndexDescriptor>[] updates = valueCreatorUtil.someUpdatesWithDuplicateValues(random); IndexUpdater updater = outerInstance.populator.newPopulatingUpdater(NullPropertyAccessor); // when foreach (IndexEntryUpdate <IndexDescriptor> update in updates) { updater.Process(update); } try { updater.Close(); outerInstance.populator.scanCompleted(nullInstance); fail("Updates should have conflicted"); } catch (Exception e) { // then assertTrue(e.Message, Exceptions.contains(e, typeof(IndexEntryConflictException))); } finally { outerInstance.populator.close(true); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void applyInterleaved(org.neo4j.kernel.api.index.IndexEntryUpdate<org.neo4j.storageengine.api.schema.IndexDescriptor>[] updates, NativeIndexPopulator<KEY,VALUE> populator) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void ApplyInterleaved(IndexEntryUpdate <IndexDescriptor>[] updates, NativeIndexPopulator <KEY, VALUE> populator) { bool useUpdater = true; ICollection <IndexEntryUpdate <IndexDescriptor> > populatorBatch = new List <IndexEntryUpdate <IndexDescriptor> >(); IndexUpdater updater = populator.NewPopulatingUpdater(NullPropertyAccessor); foreach (IndexEntryUpdate <IndexDescriptor> update in updates) { if (random.Next(100) < 20) { if (useUpdater) { updater.Close(); populatorBatch = new List <IndexEntryUpdate <IndexDescriptor> >(); } else { populator.Add(populatorBatch); updater = populator.NewPopulatingUpdater(NullPropertyAccessor); } useUpdater = !useUpdater; } if (useUpdater) { updater.Process(update); } else { populatorBatch.Add(update); } } if (useUpdater) { updater.Close(); } else { populator.Add(populatorBatch); } }
public virtual void CloseUpdater <T1>(DatabaseIndex <T1> index, IndexUpdater indexUpdater) where T1 : Org.Neo4j.Storageengine.Api.schema.IndexReader { _scheduler.schedule(Group.INDEX_UPDATING, () => { try { indexUpdater.Close(); } catch (IndexEntryConflictException e) { MarkAsFailed(index, e); } }); }
public override void Close() { foreach (Pair <IndexPopulation, IndexUpdater> pair in PopulationsWithUpdaters.Values) { IndexPopulation population = pair.First(); IndexUpdater updater = pair.Other(); try { updater.Close(); } catch (Exception t) { MultipleIndexPopulator.fail(population, t); } } PopulationsWithUpdaters.Clear(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void updaterMustThrowIfProcessAfterClose() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void UpdaterMustThrowIfProcessAfterClose() { // given Populator.create(); IndexUpdater updater = Populator.newPopulatingUpdater(NullPropertyAccessor); // when updater.Close(); // then try { updater.Process(valueCreatorUtil.add(1, Values.of(long.MaxValue))); fail("Expected process to throw on closed updater"); } catch (System.InvalidOperationException) { // good } Populator.close(true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotRejectDuplicateEntryOnSameNodeIdAfterUsingPopulatingUpdater() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotRejectDuplicateEntryOnSameNodeIdAfterUsingPopulatingUpdater() { // given _populator = NewPopulator(); when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(Values.of("value1")); IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); updater.Process(add(1, _schemaDescriptor, "value1")); updater.Process(change(1, _schemaDescriptor, "value1", "value1")); updater.Close(); AddUpdate(_populator, 2, "value2"); AddUpdate(_populator, 3, "value3"); // when _populator.verifyDeferredConstraints(_nodePropertyAccessor); _populator.close(true); // then assertEquals(asList(1L), GetAllNodes(Directory, "value1")); assertEquals(asList(2L), GetAllNodes(Directory, "value2")); assertEquals(asList(3L), GetAllNodes(Directory, "value3")); }