private Predicate<ILSMIndex> newLaggingDatasetPredicate(long checkpointTargetLSN) { return lsmIndex -> { final LSMIOOperationCallback ioCallback = (LSMIOOperationCallback) lsmIndex.getIOOperationCallback(); return ioCallback.getPersistenceLsn() < checkpointTargetLSN; }; } }
private void asyncFlush(DatasetResource dsr, PrimaryIndexOperationTracker opTracker, Predicate<ILSMIndex> indexPredicate) throws HyracksDataException { final int partition = opTracker.getPartition(); for (ILSMIndex lsmIndex : dsr.getDatasetInfo().getDatasetPartitionOpenIndexes(partition)) { LSMIOOperationCallback ioCallback = (LSMIOOperationCallback) lsmIndex.getIOOperationCallback(); if (needsFlush(opTracker, lsmIndex, ioCallback) && indexPredicate.test(lsmIndex)) { LOGGER.info("Async flushing {}", opTracker); opTracker.setFlushOnExit(true); opTracker.flushIfNeeded(); break; } } }
@Override public long getLocalMinFirstLSN() throws HyracksDataException { final IDatasetLifecycleManager datasetLifecycleManager = appCtx.getDatasetLifecycleManager(); List<IIndex> openIndexList = datasetLifecycleManager.getOpenResources(); long firstLSN; //the min first lsn can only be the current append or smaller long minFirstLSN = logMgr.getAppendLSN(); if (!openIndexList.isEmpty()) { for (IIndex index : openIndexList) { LSMIOOperationCallback ioCallback = (LSMIOOperationCallback) ((ILSMIndex) index).getIOOperationCallback(); if (!((AbstractLSMIndex) index).isCurrentMutableComponentEmpty() || ioCallback.hasPendingFlush()) { firstLSN = ioCallback.getPersistenceLsn(); minFirstLSN = Math.min(minFirstLSN, firstLSN); } } } return minFirstLSN; }
private long getReplicatedComponentLsn() throws HyracksDataException { final ILSMIndexReplicationJob indexReplJob = (ILSMIndexReplicationJob) job; if (indexReplJob.getLSMOpType() == LSMOperationType.MERGE) { return MERGE_LSN; } else if (indexReplJob.getLSMOpType() == LSMOperationType.LOAD) { return BULKLOAD_LSN; } if (indexReplJob.getLSMOpType() != LSMOperationType.FLUSH) { return LSMIOOperationCallback.INVALID_LSN; } final ILSMIndex lsmIndex = indexReplJob.getLSMIndex(); final ILSMIndexOperationContext ctx = indexReplJob.getLSMIndexOperationContext(); return ((LSMIOOperationCallback) lsmIndex.getIOOperationCallback()) .getComponentLSN(ctx.getComponentsToBeReplicated()); }
index.getCurrentMemoryComponentIndex()); Assert.assertEquals(0, index.getDiskComponents().size()); EncapsulatingIoCallback encapsulating = (EncapsulatingIoCallback) index.getIOOperationCallback(); CountingIoOperationCallback ioCallback = (CountingIoOperationCallback) encapsulating.getEncapsulated();
Assert.assertEquals(getExpectedMemoryComponentIndex(1), index.getCurrentMemoryComponentIndex()); Assert.assertEquals(0, index.getDiskComponents().size()); CountingIoOperationCallback ioCallback = (CountingIoOperationCallback) index.getIOOperationCallback();
Assert.assertEquals(getExpectedMemoryComponentIndex(1), index.getCurrentMemoryComponentIndex()); Assert.assertEquals(1, index.getDiskComponents().size()); CountingIoOperationCallback ioCallback = (CountingIoOperationCallback) index.getIOOperationCallback();
Assert.assertEquals(getExpectedMemoryComponentIndex(1), index.getCurrentMemoryComponentIndex()); Assert.assertEquals(1, index.getDiskComponents().size()); CountingIoOperationCallback ioCallback = (CountingIoOperationCallback) index.getIOOperationCallback();