private void writeFailure( String indexName, StringBuilder builder, IndexProvider provider, StoreIndexDescriptor descriptor ) { try { String failure = provider.getPopulationFailure( descriptor ); builder.append( indexName ); builder.append( ": " ); builder.append( failure ); builder.append( ' ' ); } catch ( IllegalStateException e ) { // Just catch } }
@Override public String getPopulationFailure( StoreIndexDescriptor descriptor ) throws IllegalStateException { return indexProvider.getPopulationFailure( descriptor ); }
@Override public String getPopulationFailure( StoreIndexDescriptor descriptor ) throws IllegalStateException { return actual.getPopulationFailure( descriptor ); }
@Override public String getPopulationFailure( StoreIndexDescriptor descriptor ) throws IllegalStateException { return failureTypes.contains( FailureType.INITIAL_STATE ) ? INITIAL_STATE_FAILURE_MESSAGE : actualProvider.getPopulationFailure( descriptor ); }
@Test public void getPopulationFailureMustReportFailureWhenMultipleFail() { // when List<String> failureMessages = new ArrayList<>(); for ( IndexProvider aliveProvider : aliveProviders ) { String failureMessage = "FAILURE[" + aliveProvider + "]"; failureMessages.add( failureMessage ); when( aliveProvider.getPopulationFailure( any( StoreIndexDescriptor.class ) ) ).thenReturn( failureMessage ); } // then String populationFailure = fusionIndexProvider.getPopulationFailure( AN_INDEX ); for ( String failureMessage : failureMessages ) { assertThat( populationFailure, containsString( failureMessage ) ); } }
@Test public void getPopulationFailureMustReportFailureWhenAnyFailed() { for ( IndexProvider failingProvider : aliveProviders ) { // when String failure = "failure"; IllegalStateException exception = new IllegalStateException( "not failed" ); for ( IndexProvider provider : aliveProviders ) { if ( provider == failingProvider ) { when( provider.getPopulationFailure( any( StoreIndexDescriptor.class ) ) ).thenReturn( failure ); } else { when( provider.getPopulationFailure( any( StoreIndexDescriptor.class ) ) ).thenThrow( exception ); } } // then assertThat( fusionIndexProvider.getPopulationFailure( AN_INDEX ), containsString( failure ) ); } }
@Test public void getPopulationFailureMustThrowIfNoFailure() { // when // ... no failure IllegalStateException failure = new IllegalStateException( "not failed" ); for ( IndexProvider provider : aliveProviders ) { when( provider.getPopulationFailure( any( StoreIndexDescriptor.class ) ) ).thenThrow( failure ); } // then try { fusionIndexProvider.getPopulationFailure( AN_INDEX ); fail( "Should have failed" ); } catch ( IllegalStateException e ) { // good } }
case FAILED: monitor.initialState( indexDescriptor, FAILED ); IndexPopulationFailure failure = failure( provider.getPopulationFailure( indexDescriptor ) ); indexProxy = indexProxyCreator.createFailedIndexProxy( indexDescriptor, failure ); break;
@Test public void shouldStorePopulationFailedForRetrievalFromProviderLater() throws Exception { // GIVEN String failure = "The contrived failure"; IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.defaults() ); // WHEN (this will attempt to call close) withPopulator( indexProvider.getPopulator( descriptor, indexSamplingConfig ), p -> p.markAsFailed( failure ), false ); // THEN assertThat( indexProvider.getPopulationFailure( descriptor ), containsString( failure ) ); }
verify( provider ).getPopulationFailure( failedIndex ); internalLogProvider.assertAtLeastOnce( logMatch.debug( "IndexingService.start: index 1 on :LabelOne(propertyOne) is ONLINE" ),
@Test public void getPopulationFailureMustThrowIfNoFailure() { // given provider = newProvider(); IndexPopulator populator = provider.getPopulator( descriptor(), samplingConfig() ); populator.create(); populator.close( true ); // when // ... no failure on populator // then try { provider.getPopulationFailure( descriptor() ); fail( "Should have failed" ); } catch ( IllegalStateException e ) { // good assertThat( e.getMessage(), Matchers.containsString( Long.toString( indexId ) ) ); } }
@Test public void getPopulationFailureMustReturnReportedFailure() { // given provider = newProvider(); IndexPopulator populator = provider.getPopulator( descriptor(), samplingConfig() ); populator.create(); // when String failureMessage = "fail"; populator.markAsFailed( failureMessage ); populator.close( false ); // then String populationFailure = provider.getPopulationFailure( descriptor() ); assertThat( populationFailure, is( failureMessage ) ); }
@Test public void getPopulationFailureMustPersistReportedFailure() { // given provider = newProvider(); IndexPopulator populator = provider.getPopulator( descriptor(), samplingConfig() ); populator.create(); // when String failureMessage = "fail"; populator.markAsFailed( failureMessage ); populator.close( false ); // then provider = newProvider(); String populationFailure = provider.getPopulationFailure( descriptor() ); assertThat( populationFailure, is( failureMessage ) ); }
assertThat( provider.getPopulationFailure( descriptor( first ) ), is( firstFailure ) ); assertThat( provider.getPopulationFailure( descriptor( third ) ), is( thirdFailure ) ); try provider.getPopulationFailure( descriptor( second ) ); fail( "Should have failed" );
@Test public void getPopulationFailureMustThrowEvenIfFailureOnOtherIndex() { // given provider = newProvider(); int nonFailedIndexId = NativeIndexProviderTests.indexId; IndexPopulator nonFailedPopulator = provider.getPopulator( descriptor( nonFailedIndexId ), samplingConfig() ); nonFailedPopulator.create(); nonFailedPopulator.close( true ); int failedIndexId = 2; IndexPopulator failedPopulator = provider.getPopulator( descriptor( failedIndexId ), samplingConfig() ); failedPopulator.create(); // when failedPopulator.markAsFailed( "failure" ); failedPopulator.close( false ); // then try { provider.getPopulationFailure( descriptor( nonFailedIndexId ) ); fail( "Should have failed" ); } catch ( IllegalStateException e ) { // good assertThat( e.getMessage(), Matchers.containsString( Long.toString( nonFailedIndexId ) ) ); } }
private void writeFailure( String indexName, StringBuilder builder, IndexProvider provider, StoreIndexDescriptor descriptor ) { try { String failure = provider.getPopulationFailure( descriptor ); builder.append( indexName ); builder.append( ": " ); builder.append( failure ); builder.append( ' ' ); } catch ( IllegalStateException e ) { // Just catch } }
case FAILED: monitor.initialState( indexDescriptor, FAILED ); IndexPopulationFailure failure = failure( provider.getPopulationFailure( indexDescriptor ) ); indexProxy = indexProxyCreator.createFailedIndexProxy( indexDescriptor, failure ); break;