@Override public void process( IndexEntryUpdate<?> update ) throws IndexEntryConflictException { delegate.process( update ); updates++; }
@Override public void close() throws IndexEntryConflictException { for ( IndexUpdater part : this ) { part.close(); } }
@Test public void testMultiplePropertyUpdateFailures() throws IndexEntryConflictException, FlipFailedKernelException { NodePropertyAccessor nodePropertyAccessor = mock( NodePropertyAccessor.class ); IndexEntryUpdate<?> update1 = add( 1, index1, "foo" ); IndexEntryUpdate<?> update2 = add( 2, index1, "bar" ); IndexUpdater updater = mock( IndexUpdater.class ); IndexPopulator populator = createIndexPopulator( updater ); addPopulator( populator, 1 ); doThrow( getPopulatorException() ).when( updater ).process( any( IndexEntryUpdate.class ) ); IndexUpdater multipleIndexUpdater = multipleIndexPopulator.newPopulatingUpdater( nodePropertyAccessor ); multipleIndexUpdater.process( update1 ); multipleIndexUpdater.process( update2 ); verify( updater ).process( update1 ); verify( updater, never() ).process( update2 ); verify( updater ).close(); checkPopulatorFailure( populator ); }
@Test public void shouldReportNodesThatAreNotIndexed() throws Exception { // given IndexSamplingConfig samplingConfig = new IndexSamplingConfig( new Config() ); for ( IndexRule indexRule : loadAllIndexRules( fixture.directStoreAccess().nativeStores().getSchemaStore() ) ) { IndexAccessor accessor = fixture.directStoreAccess().indexes().getOnlineAccessor( indexRule.getId(), new IndexConfiguration( indexRule.isConstraintIndex() ), samplingConfig ); IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE ); updater.remove( asPrimitiveLongSet( indexedNodes ) ); updater.close(); accessor.close(); } // when ConsistencySummaryStatistics stats = check(); // then on( stats ).verify( RecordType.NODE, 1 ) .andThatsAllFolks(); }
@Override public void process( IndexEntryUpdate<?> update ) { Pair<IndexPopulation,IndexUpdater> pair = populationsWithUpdaters.get( update.indexKey().schema() ); if ( pair != null ) { IndexPopulation population = pair.first(); IndexUpdater updater = pair.other(); try { population.populator.includeSample( update ); updater.process( update ); } catch ( Throwable t ) { try { updater.close(); } catch ( Throwable ce ) { log.error( format( "Failed to close index updater: [%s]", updater ), ce ); } populationsWithUpdaters.remove( update.indexKey().schema() ); multipleIndexPopulator.fail( population, t ); } } }
@Test public void testPropertyUpdateFailure() throws IndexEntryConflictException, FlipFailedKernelException { IndexEntryUpdate<?> propertyUpdate = createIndexEntryUpdate( index1 ); IndexUpdater indexUpdater1 = mock( IndexUpdater.class ); IndexPopulator indexPopulator1 = createIndexPopulator( indexUpdater1 ); addPopulator( indexPopulator1, 1 ); doThrow( getPopulatorException() ).when( indexUpdater1 ).process( propertyUpdate ); IndexUpdater multipleIndexUpdater = multipleIndexPopulator.newPopulatingUpdater( mock( NodePropertyAccessor.class ) ); multipleIndexUpdater.process( propertyUpdate ); verify( indexUpdater1 ).close(); checkPopulatorFailure( indexPopulator1 ); }
@Override public void process( IndexEntryUpdate<?> update ) throws IndexEntryConflictException { delegate.process( update ); } }
@Override public void close() throws IndexEntryConflictException { for ( IndexUpdater updater : this ) { updater.close(); } }
@Override public void process( IndexEntryUpdate<?> update ) { try { delegate.process( update ); } catch ( IndexEntryConflictException conflict ) { failures.add( conflict ); } }
@Override public void close() throws IndexEntryConflictException { try { delegate.close(); } finally { closeCall(); } } };
private void processAll( IndexUpdater updater, IndexEntryUpdate<IndexDescriptor>[] updates ) throws IndexEntryConflictException { for ( IndexEntryUpdate<IndexDescriptor> update : updates ) { updater.process( update ); } }
@Override public void close() { try { delegate.close(); } catch ( IndexEntryConflictException conflict ) { failures.add( conflict ); } } };
@Test public void applicationOfUpdatesShouldFlush() throws Exception { // Given when( accessor.newUpdater( any( IndexUpdateMode.class ) ) ).thenReturn( updater ); IndexingService indexing = newIndexingServiceWithMockedDependencies( populator, accessor, withData() ); life.start(); indexing.createIndexes( index.withId( 0 ) ); waitForIndexesToComeOnline( indexing, 0 ); verify( populator, timeout( 10000 ) ).close( true ); // When indexing.apply( updates( asList( add( 1, "foo" ), add( 2, "bar" ) ) ) ); // Then InOrder inOrder = inOrder( updater ); inOrder.verify( updater ).process( add( 1, "foo" ) ); inOrder.verify( updater ).process( add( 2, "bar" ) ); inOrder.verify( updater ).close(); inOrder.verifyNoMoreInteractions(); }
@Override public void process( IndexEntryUpdate<?> update ) throws IndexEntryConflictException { actual.process( update ); updatesTarget.add( update ); }
@Override public void close() throws IndexEntryConflictException { try { delegate.close(); } finally { lock.readLock().unlock(); } } }
@Test public void shouldStillReportInternalIndexStateAsPopulatingWhenConstraintIndexIsDonePopulating() throws Exception { // given when( accessor.newUpdater( any( IndexUpdateMode.class ) ) ).thenReturn( updater ); IndexingService indexingService = newIndexingServiceWithMockedDependencies( populator, accessor, withData() ); life.start(); // when indexingService.createIndexes( constraintIndexRule( 0, labelId, propertyKeyId, PROVIDER_DESCRIPTOR ) ); IndexProxy proxy = indexingService.getIndexProxy( 0 ); // don't wait for index to come ONLINE here since we're testing that it doesn't verify( populator, timeout( 20000 ) ).close( true ); try ( IndexUpdater updater = proxy.newUpdater( IndexUpdateMode.ONLINE ) ) { updater.process( add( 10, "foo" ) ); } // then assertEquals( InternalIndexState.POPULATING, proxy.getState() ); InOrder order = inOrder( populator, accessor, updater ); order.verify( populator ).create(); order.verify( populator ).close( true ); order.verify( accessor ).newUpdater( IndexUpdateMode.ONLINE ); order.verify( updater ).process( add( 10, "foo" ) ); order.verify( updater ).close(); }
@Override public void process( IndexEntryUpdate<?> update ) throws IndexEntryConflictException { actual.process( update ); if ( update.updateMode() != REMOVED ) { touchedTuples.add( ValueTuple.of( update.values() ) ); } }
@Override public void close() throws IndexEntryConflictException { delegate.close(); storeView.incrementIndexUpdates( indexId, updates ); } }