private boolean shouldHandle(ErrorContext context) { if (!(context.getIndexManager() instanceof AffinityIndexManager)) { return false; } Throwable throwable = context.getThrowable(); return throwable instanceof LockObtainFailedException || throwable instanceof SearchException && throwable.getCause() instanceof InvalidLockException; } }
private boolean shouldHandle(ErrorContext context) { if (!(context.getIndexManager() instanceof AffinityIndexManager)) { return false; } Throwable throwable = context.getThrowable(); return throwable instanceof LockObtainFailedException || throwable instanceof SearchException && throwable.getCause() instanceof InvalidLockException; } }
@Override public void handle(ErrorContext context) { indexManager = context.getIndexManager(); super.handle( context ); }
@Override protected boolean errorOccurred(ErrorContext context) { if (!this.shouldHandle(context)) { return false; } AffinityIndexManager affinityIndexManager = (AffinityIndexManager) context.getIndexManager(); ShardAddress localShardAddress = affinityIndexManager.getLocalShardAddress(); List<LuceneWork> failed = this.extractFailedWorks(context); this.clearLockIfNeeded(affinityIndexManager); log.debugf("Retrying operations %s at %s", failed, affinityIndexManager.getLocalShardAddress()); CompletableFuture.supplyAsync(() -> { affinityIndexManager.performOperations(failed, null, true, true); return null; }, asyncExecutor).whenComplete((aVoid, error) -> { if (error == null) { log.debugf("Operation %s completed at %s", failed, localShardAddress); } else { log.errorf(error, "Error reapplying operation %s at %s", failed, localShardAddress); } }); return true; }
@Override protected boolean errorOccurred(ErrorContext context) { if (!this.shouldHandle(context)) { return false; } AffinityIndexManager affinityIndexManager = (AffinityIndexManager) context.getIndexManager(); ShardAddress localShardAddress = affinityIndexManager.getLocalShardAddress(); List<LuceneWork> failed = this.extractFailedWorks(context); this.clearLockIfNeeded(affinityIndexManager); log.debugf("Retrying operations %s at %s", failed, affinityIndexManager.getLocalShardAddress()); CompletableFuture.supplyAsync(() -> { affinityIndexManager.performOperations(failed, null, true, true); return null; }, asyncExecutor).whenComplete((aVoid, error) -> { if (error == null) { log.debugf("Operation %s completed at %s", failed, localShardAddress); } else { log.errorf(error, "Error reapplying operation %s at %s", failed, localShardAddress); } }); return true; }