@Override public LSMIOOperationStatus getStatus() { return ioOp.getStatus(); }
@Override public void scheduleOperation(ILSMIOOperation operation) { try { before(operation); if (operation.getStatus() == LSMIOOperationStatus.FAILURE) { return; } run(operation); } catch (Throwable e) { // NOSONAR: Must catch them all throw new IllegalStateException(e); } finally { after(operation); } }
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(); } }
@Override public synchronized void completed(ILSMIOOperation operation) { if (operation.getIOOpertionType() == LSMIOOperationType.FLUSH) { pendingFlushes--; if (operation.getStatus() == LSMIOOperationStatus.SUCCESS) { Map<String, Object> map = operation.getAccessor().getOpContext().getParameters(); persistenceLsn = pendingFlushes == 0 ? firstLsnForCurrentMemoryComponent : (Long) map.get(KEY_FLUSH_LOG_LSN); } } dsInfo.undeclareActiveIOOperation(); }
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 merge(ILSMIOOperation operation) throws HyracksDataException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Started a merge operation for index: {}", lsmIndex); } synchronized (opTracker) { enterComponents(operation.getAccessor().getOpContext(), LSMOperationType.MERGE); } try { doIo(operation); } finally { exitComponents(operation.getAccessor().getOpContext(), LSMOperationType.MERGE, operation.getNewComponent(), operation.getStatus() == LSMIOOperationStatus.FAILURE); opTracker.completeOperation(lsmIndex, LSMOperationType.MERGE, operation.getAccessor().getOpContext().getSearchOperationCallback(), operation.getAccessor().getOpContext().getModificationCallback()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Finished the merge operation for index: {}. Result: {}", lsmIndex, operation.getStatus()); } }
@SuppressWarnings("squid:S2142") @Override public void flush(ILSMIOOperation operation) throws HyracksDataException { LOGGER.debug("Started a flush operation for index: {}", lsmIndex); synchronized (opTracker) { while (!enterComponents(operation.getAccessor().getOpContext(), LSMOperationType.FLUSH)) { try { opTracker.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw HyracksDataException.create(e); } } } try { doIo(operation); } finally { exitComponents(operation.getAccessor().getOpContext(), LSMOperationType.FLUSH, operation.getNewComponent(), operation.getStatus() == LSMIOOperationStatus.FAILURE); opTracker.completeOperation(lsmIndex, LSMOperationType.FLUSH, operation.getAccessor().getOpContext().getSearchOperationCallback(), operation.getAccessor().getOpContext().getModificationCallback()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Finished the flush operation for index: {}. Result: {}", lsmIndex, operation.getStatus()); } }
private void run(ILSMIOOperation operation) { try { operation.call(); } catch (Throwable th) { // NOSONAR Must catch all LOGGER.log(Level.ERROR, "IO Operation failed", th); operation.setStatus(LSMIOOperationStatus.FAILURE); operation.setFailure(th); } if (operation.getStatus() == LSMIOOperationStatus.FAILURE) { failureCallback.operationFailed(operation, operation.getFailure()); } }
throw HyracksDataException.create(e); if (flush.getStatus() == LSMIOOperationStatus.FAILURE) { throw HyracksDataException.create(flush.getFailure());
@Override public void afterFinalize(ILSMIOOperation operation) throws HyracksDataException { if (operation.getStatus() == LSMIOOperationStatus.FAILURE) { return; } if (operation.getIOOpertionType() != LSMIOOperationType.LOAD && operation.getAccessor().getOpContext().getOperation() == IndexOperation.DELETE_COMPONENTS) { deleteComponentsFromCheckpoint(operation); } else if (operation.getIOOpertionType() == LSMIOOperationType.FLUSH || operation.getIOOpertionType() == LSMIOOperationType.LOAD) { addComponentToCheckpoint(operation); } }
throw HyracksDataException.create(e); if (ioOperation.getStatus() == LSMIOOperationStatus.FAILURE) { throw HyracksDataException.create(ioOperation.getFailure()); throw HyracksDataException.create(e); if (ioOperation.getStatus() == LSMIOOperationStatus.FAILURE) { throw HyracksDataException.create(ioOperation.getFailure());
private void flush(OrderedIndexTestContext ctx) throws HyracksDataException, InterruptedException { ILSMIOOperation flush = scheduleFlush(ctx); flush.sync(); if (flush.getStatus() == LSMIOOperationStatus.FAILURE) { throw HyracksDataException.create(flush.getFailure()); } }
step.acquire(); op.sync(); if (op.getStatus() == LSMIOOperationStatus.FAILURE) { throw HyracksDataException.create(op.getFailure());
@Override public void afterOperation(ILSMIOOperation operation) throws HyracksDataException { if (operation.getStatus() == LSMIOOperationStatus.FAILURE) { return; } if (operation.getIOOpertionType() == LSMIOOperationType.LOAD) { Map<String, Object> map = operation.getParameters(); putComponentIdIntoMetadata(operation.getNewComponent(), (LSMComponentId) map.get(KEY_FLUSHED_COMPONENT_ID)); } else if (operation.getIOOpertionType() == LSMIOOperationType.FLUSH) { Map<String, Object> map = operation.getParameters(); putLSNIntoMetadata(operation.getNewComponent(), (Long) map.get(KEY_FLUSH_LOG_LSN)); putComponentIdIntoMetadata(operation.getNewComponent(), ((FlushOperation) operation).getFlushingComponent().getId()); } else if (operation.getIOOpertionType() == LSMIOOperationType.MERGE) { List<ILSMDiskComponent> mergedComponents = operation.getAccessor().getOpContext().getComponentsToBeMerged(); putLSNIntoMetadata(operation.getNewComponent(), mergedComponents); putComponentIdIntoMetadata(operation.getNewComponent(), mergedComponents); LongPointable markerLsn = LongPointable.FACTORY.createPointable(ComponentUtils.getLong(mergedComponents.get(0).getMetadata(), ComponentUtils.MARKER_LSN_KEY, ComponentUtils.NOT_FOUND, buffer)); operation.getNewComponent().getMetadata().put(ComponentUtils.MARKER_LSN_KEY, markerLsn); } }
private void presistComponentToDisk() throws HyracksDataException { try { lsmIndex.getIOOperationCallback().afterOperation(opCtx.getIoOperation()); componentBulkLoader.end(); } catch (Throwable th) { // NOSONAR Must not call afterFinalize without setting failure fail(th); throw th; } finally { lsmIndex.getIOOperationCallback().afterFinalize(opCtx.getIoOperation()); } if (opCtx.getIoOperation().getStatus() == LSMIOOperationStatus.SUCCESS && opCtx.getIoOperation().getNewComponent().getComponentSize() > 0) { lsmIndex.getHarness().addBulkLoadedComponent(opCtx.getIoOperation()); } }
ILSMIOOperation flush = lsmAccessor.scheduleFlush(); flush.sync(); if (flush.getStatus() == LSMIOOperationStatus.FAILURE) { throw HyracksDataException.create(flush.getFailure());
if (operation.getStatus() == LSMIOOperationStatus.FAILURE) { operation.cleanup(lsmIndex.getBufferCache());
ILSMIOOperation merge = mergeAccessor.scheduleMerge(mergedComponents); merge.sync(); if (merge.getStatus() == LSMIOOperationStatus.FAILURE) { throw HyracksDataException.create(merge.getFailure());
ILSMIOOperation merge = accessor.scheduleMerge(btree.getDiskComponents()); merge.sync(); Assert.assertEquals(LSMIOOperationStatus.FAILURE, merge.getStatus()); scheduler.modify = false; accessor.scheduleMerge(btree.getDiskComponents());
ILSMIOOperation flush = accessor.scheduleFlush(); flush.sync(); if (flush.getStatus() == LSMIOOperationStatus.FAILURE) { throw HyracksDataException.create(flush.getFailure());