@Override public ILSMIOOperation scheduleMerge(ILSMIndexOperationContext ctx) throws HyracksDataException { ILSMIOOperation operation; synchronized (opTracker) { operation = lsmIndex.createMergeOperation(ctx); } ioScheduler.scheduleOperation(operation); return operation; }
@Override public ILSMIOOperation scheduleFullMerge(ILSMIndexOperationContext ctx) throws HyracksDataException { ILSMIOOperation operation; synchronized (opTracker) { fullMergeIsRequested.set(true); ctx.getComponentsToBeMerged().addAll(lsmIndex.getDiskComponents()); operation = lsmIndex.createMergeOperation(ctx); if (operation != NoOpIoOperation.INSTANCE) { fullMergeIsRequested.set(false); } // If the merge cannot be scheduled because there is already an ongoing merge on // subset/all of the components, then whenever the current merge has finished, // it will schedule the full merge again. } ioScheduler.scheduleOperation(operation); return operation; }
@Override public ILSMIOOperation scheduleFlush(ILSMIndexOperationContext ctx) throws HyracksDataException { ILSMIOOperation flush; LOGGER.debug("Flush is being scheduled on {}", lsmIndex); if (!lsmIndex.isMemoryComponentsAllocated()) { lsmIndex.allocateMemoryComponents(); } synchronized (opTracker) { try { flush = lsmIndex.createFlushOperation(ctx); } finally { // Notify all waiting threads whenever a flush has been scheduled since they will check // again if they can grab and enter the mutable component. opTracker.notifyAll(); } } ioScheduler.scheduleOperation(flush); return flush; }
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); } } } } }