@Override public void handleException(String errorMsg, Throwable exception) { errorHandler.handleException(errorMsg, exception); }
@Override public void handle(ErrorContext context) { boolean handled = errorOccurred(context); if (!handled) { errorHandler.handle(context); } }
/** * @param ioe The exception to handle * @param errorContextBuilder Might be used to enqueue useful information about the lost operations, or be null */ private void handleIOException(IOException ioe, ErrorContextBuilder errorContextBuilder) { if ( log.isTraceEnabled() ) { log.trace( "going to handle IOException", ioe ); } final ErrorContext errorContext; if ( errorContextBuilder != null ) { errorContext = errorContextBuilder.errorThatOccurred( ioe ).indexManager( indexManager ).createErrorContext(); this.errorHandler.handle( errorContext ); } else { errorHandler.handleException( log.ioExceptionOnIndexWriter(), ioe ); } } }
/** * @param ioe The exception to handle * @param errorContextBuilder Might be used to enqueue useful information about the lost operations, or be null */ private void handleIOException(IOException ioe, ErrorContextBuilder errorContextBuilder) { if ( log.isTraceEnabled() ) { log.trace( "going to handle IOException", ioe ); } final ErrorContext errorContext; if ( errorContextBuilder != null ) { errorContext = errorContextBuilder.errorThatOccurred( ioe ).indexManager( indexManager ).createErrorContext(); this.errorHandler.handle( errorContext ); } else { errorHandler.handleException( log.ioExceptionOnIndexWriter(), ioe ); } } }
@Override public void handleException(String errorMsg, Throwable exception) { errorHandler.handleException(errorMsg, exception); }
@Override public void execute() { try { jestClient.executeBulkRequest( requests, refresh ); } catch (BulkRequestFailedException brfe) { ErrorContextBuilder builder = new ErrorContextBuilder(); List<LuceneWork> allWork = new ArrayList<>(); for ( BackendRequest<?> backendRequest : requests ) { allWork.add( backendRequest.getLuceneWork() ); if ( !brfe.getErroneousItems().contains( backendRequest ) ) { builder.workCompleted( backendRequest.getLuceneWork() ); } } builder.allWorkToBeDone( allWork ); for ( BackendRequest<?> failedAction : brfe.getErroneousItems() ) { builder.addWorkThatFailed( failedAction.getLuceneWork() ); } builder.errorThatOccurred( brfe ); errorHandler.handle( builder.createErrorContext() ); } catch (Exception e) { errorHandler.handleException( "Bulk request failed", e ); } }
@Override public void handle(ErrorContext context) { boolean handled = errorOccurred(context); if (!handled) { errorHandler.handle(context); } }
@Override public void run() { // This is technically running in a race condition with a possible shutdown // (indexwriter getting closed), which would cause an AlreadyClosedException exception, // but gets swallowed as it's running in the service thread (which is also shutting down). try { indexWriterHolder.commitIndexWriter(); } catch (Exception e) { errorHandler.handleException( "Error caught in background thread of ScheduledCommitPolicy", e ); } } }
@Override public void handle() { if ( errorContextBuilder != null || errorThatOccurred != null ) { if ( errorThatOccurred != null ) { getErrorContextBuilder().errorThatOccurred( errorThatOccurred ); } errorHandler.handle( getErrorContextBuilder().createErrorContext() ); } }
@Override public void run() { // This is technically running in a race condition with a possible shutdown // (indexwriter getting closed), which would cause an AlreadyClosedException exception, // but gets swallowed as it's running in the service thread (which is also shutting down). try { indexWriterHolder.commitIndexWriter(); } catch (Exception e) { errorHandler.handleException( "Error caught in background thread of ScheduledCommitPolicy", e ); } } }
@Override public void handle() { if ( errorContextBuilder != null || errorThatOccurred != null ) { if ( errorThatOccurred != null ) { getErrorContextBuilder().errorThatOccurred( errorThatOccurred ); } errorHandler.handle( getErrorContextBuilder().createErrorContext() ); } }
@Override public CompletableFuture<Void> flush() { CompletableFuture<?> future = CompletableFuture.completedFuture( null ); // Flush the indexing monitors return future.thenRun( () -> { for ( BufferedIndexingMonitor buffer : bufferedIndexMonitors.values() ) { try { buffer.flush(); } catch (RuntimeException e) { errorHandler.handleException( "Flushing an indexing monitor failed", e ); } } bufferedIndexMonitors.clear(); } ); }
private void handleException(Exception e) { ErrorContextBuilder builder = new ErrorContextBuilder(); builder.allWorkToBeDone( workList ); builder.errorThatOccurred( e ).indexManager( resources.getIndexManager() ); resources.getErrorHandler().handle( builder.createErrorContext() ); }
@Override public CompletableFuture<Void> flush() { CompletableFuture<?> future = CompletableFuture.completedFuture( null ); // Flush the indexing monitors return future.thenRun( () -> { for ( BufferedIndexingMonitor buffer : bufferedIndexMonitors.values() ) { try { buffer.flush(); } catch (RuntimeException e) { errorHandler.handleException( "Flushing an indexing monitor failed", e ); } } bufferedIndexMonitors.clear(); } ); }
private void handleException(Exception e) { ErrorContextBuilder builder = new ErrorContextBuilder(); builder.allWorkToBeDone( workList ); builder.errorThatOccurred( e ).indexManager( resources.getIndexManager() ); resources.getErrorHandler().handle( builder.createErrorContext() ); }
@Override protected void handleMergeException(Directory dir, Throwable t) { try { super.handleMergeException( dir, t ); } catch (ThreadInterruptedException ie) { Thread.currentThread().interrupt(); } catch (Exception ex) { errorHandler.handleException( log.exceptionDuringIndexMergeOperation() , ex ); } }
@Override public void execute() { try { jestClient.executeRequest( request.getAction(), request.getIgnoredErrorStatuses() ); } catch (Exception e) { ErrorContextBuilder builder = new ErrorContextBuilder(); builder.allWorkToBeDone( Collections.singletonList( request.getLuceneWork() ) ); builder.addWorkThatFailed( request.getLuceneWork() ); builder.errorThatOccurred( e ); errorHandler.handle( builder.createErrorContext() ); } }
@Override protected void handleMergeException(Directory dir, Throwable t) { try { super.handleMergeException( dir, t ); } catch (ThreadInterruptedException ie) { Thread.currentThread().interrupt(); } catch (Exception ex) { errorHandler.handleException( log.exceptionDuringIndexMergeOperation() , ex ); } }
private void doApplySingleWork(LuceneWork work) { try { BackendRequest<?> request = work.acceptIndexWorkVisitor( visitor, true ); if ( request == null ) { return; } jestClient.executeRequest( request.getAction(), request.getIgnoredErrorStatuses() ); // DBQ ignores the refresh parameter for some reason, so doing it explicitly if ( request.getAction() instanceof DeleteByQuery ) { refreshIndex(); } } catch (Exception e) { ErrorContextBuilder builder = new ErrorContextBuilder(); builder.allWorkToBeDone( Collections.singleton( work ) ); builder.addWorkThatFailed( work ); builder.errorThatOccurred( e ); errorHandler.handle( builder.createErrorContext() ); } }
private void indexAllQueue(Session session, List<?> entities, InstanceInitializer sessionInitializer) throws InterruptedException { ConversionContext contextualBridge = new ContextualExceptionBridgeHelper(); if ( entities == null || entities.isEmpty() ) { return; } else { log.tracef( "received a list of objects to index: %s", entities ); for ( Object object : entities ) { try { index( object, session, sessionInitializer, contextualBridge ); monitor.documentsBuilt( 1 ); } catch (RuntimeException e) { String errorMsg = log.massIndexerUnableToIndexInstance( object.getClass().getName(), object.toString() ); errorHandler.handleException( errorMsg, e ); } } } }