@Override public void drop() { delegate.drop(); }
@Override public void drop() { indexCountsRemover.remove(); accessor.drop(); }
@Override public void drop() { actual.drop(); }
@Override public void drop() { accessor.drop(); }
private static void verifyFailOnSingleDropFailure( IndexAccessor failingAccessor, FusionIndexAccessor fusionIndexAccessor ) { UncheckedIOException expectedFailure = new UncheckedIOException( new IOException( "fail" ) ); doThrow( expectedFailure ).when( failingAccessor ).drop(); try { fusionIndexAccessor.drop(); fail( "Should have failed" ); } catch ( UncheckedIOException e ) { assertSame( expectedFailure, e ); } doAnswer( invocation -> null ).when( failingAccessor ).drop(); }
@Test public void dropMustThrowIfAllFail() { // given List<UncheckedIOException> exceptions = new ArrayList<>(); for ( IndexAccessor indexAccessor : aliveAccessors ) { UncheckedIOException exception = new UncheckedIOException( new IOException( indexAccessor.getClass().getSimpleName() + " fail" ) ); exceptions.add( exception ); doThrow( exception ).when( indexAccessor ).drop(); } try { // when fusionIndexAccessor.drop(); fail( "Should have failed" ); } catch ( UncheckedIOException e ) { // then assertThat( exceptions, hasItem( e ) ); } }
@Test public void dropMustDropAll() { // when // ... all drop successful fusionIndexAccessor.drop(); // then for ( IndexAccessor accessor : aliveAccessors ) { verify( accessor, times( 1 ) ).drop(); } verify( dropAction ).drop( indexId ); }
@After public void after() { try { testSuite.consistencyCheck( accessor ); } finally { accessor.drop(); accessor.close(); } }
@Test public void shouldRemoveIndexCountsWhenTheIndexItselfIsDropped() throws IOException { // given CapableIndexDescriptor capableIndexDescriptor = descriptor.withId( indexId ).withoutCapabilities(); OnlineIndexProxy index = new OnlineIndexProxy( capableIndexDescriptor, accessor, storeView, false ); // when index.drop(); // then verify( accessor ).drop(); verify( storeView ).replaceIndexCounts( indexId, 0L, 0L, 0L ); verifyNoMoreInteractions( accessor, storeView ); } }
@Test public void shouldForgetDeferredIndexDropDuringRecoveryIfCreatedIndexWithSameRuleId() throws Exception { // given StoreIndexDescriptor rule = index.withId( 0 ); IndexingService indexing = newIndexingServiceWithMockedDependencies( populator, accessor, withData(), rule ); life.init(); // when indexing.dropIndex( rule ); indexing.createIndexes( rule ); life.start(); // then IndexProxy proxy = indexing.getIndexProxy( rule.getId() ); assertNotNull( proxy ); verify( accessor, never() ).drop(); }
@Override public void drop() { delegate.drop(); }
@Override public void drop() { indexCountsRemover.remove(); accessor.drop(); }