@Override public void complete() { ioOp.complete(); }
private void after(ILSMIOOperation operation) { if (operation.getIOOpertionType() == LSMIOOperationType.FLUSH) { synchronized (runningFlushOperations) { runningFlushOperations.remove(operation.getIndexIdentifier()); if (operation.getStatus() == LSMIOOperationStatus.FAILURE) { failedGroups.putIfAbsent(operation.getIndexIdentifier(), operation.getFailure()); } operation.complete(); runningFlushOperations.notifyAll(); } } else { operation.complete(); } }
private void fail(ILSMIOOperation executedOp, Throwable t) throws HyracksDataException { callback.operationFailed(executedOp, t); if (executedOp.getIOOpertionType() == LSMIOOperationType.FLUSH) { executedOp.complete(); // Doesn't make sense to process further flush requests... Mark the operation group permanently failed // Fail other scheduled operations synchronized (this) { String id = executedOp.getIndexIdentifier(); failedGroups.put(id, t); runningFlushOperations.remove(id); if (waitingFlushOperations.containsKey(id)) { Deque<ILSMIOOperation> ops = waitingFlushOperations.remove(id); ILSMIOOperation next = ops.poll(); while (next != null) { next.setFailure(new RuntimeException("Operation group " + id + " has permanently failed", t)); next.setStatus(LSMIOOperationStatus.FAILURE); next.complete(); next = ops.poll(); } } } } } }
private void scheduleFlush(ILSMIOOperation operation) { String id = operation.getIndexIdentifier(); synchronized (executor) { if (failedGroups.containsKey(id)) { // Group failure. Fail the operation right away operation.setStatus(LSMIOOperationStatus.FAILURE); operation.setFailure(new RuntimeException("Operation group " + id + " has permanently failed", failedGroups.get(id))); operation.complete(); return; } if (runningFlushOperations.containsKey(id)) { if (waitingFlushOperations.containsKey(id)) { waitingFlushOperations.get(id).offer(operation); } else { Deque<ILSMIOOperation> q = new ArrayDeque<>(); q.offer(operation); waitingFlushOperations.put(id, q); } } else { runningFlushOperations.put(id, operation); executor.submit(operation); } } }
private void doAfterExecute(ILSMIOOperation executedOp, Throwable t) throws HyracksDataException { final boolean failed = (t != null) || (executedOp.getStatus() == LSMIOOperationStatus.FAILURE); if (failed) { fail(executedOp, t != null ? t : executedOp.getFailure()); } if (!failed || executedOp.getIOOpertionType() != LSMIOOperationType.FLUSH) { executedOp.complete(); // destroy if merge or successful flush } if (executedOp.getIOOpertionType() == LSMIOOperationType.FLUSH) { String id = executedOp.getIndexIdentifier(); synchronized (this) { runningFlushOperations.remove(id); if (waitingFlushOperations.containsKey(id)) { ILSMIOOperation op = waitingFlushOperations.get(id).poll(); if (op != null) { scheduler.scheduleOperation(op); } else { waitingFlushOperations.remove(id); } } } } }
@Override public void scheduleOperation(ILSMIOOperation operation) throws HyracksDataException { try { if (modify) { try { modifyOperation(operation); } catch (Exception e) { throw HyracksDataException.create(e); } } operation.call(); } finally { operation.complete(); } }