public LSMHarness(ILSMIndex lsmIndex, ILSMIOOperationScheduler ioScheduler, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker, boolean replicationEnabled, ITracer tracer) { this.lsmIndex = lsmIndex; this.ioScheduler = ioScheduler; this.opTracker = opTracker; this.mergePolicy = mergePolicy; this.tracer = tracer; this.traceCategory = tracer.getRegistry().get("release-memory-component"); fullMergeIsRequested = new AtomicBoolean(); //only durable indexes are replicated this.replicationEnabled = replicationEnabled && lsmIndex.isDurable(); if (replicationEnabled) { this.componentsToBeReplicated = new ArrayList<>(); } componentReplacementCtx = new ComponentReplacementContext(lsmIndex); }
@SuppressWarnings("squid:S1181") @Override public void addBulkLoadedComponent(ILSMIOOperation ioOperation) throws HyracksDataException { ILSMDiskComponent c = ioOperation.getNewComponent(); try { c.markAsValid(lsmIndex.isDurable(), ioOperation); } catch (Throwable th) { ioOperation.setFailure(th); } if (ioOperation.hasFailed()) { throw HyracksDataException.create(ioOperation.getFailure()); } synchronized (opTracker) { lsmIndex.addDiskComponent(c); if (replicationEnabled) { componentsToBeReplicated.clear(); componentsToBeReplicated.add(c); triggerReplication(componentsToBeReplicated, LSMOperationType.LOAD); } mergePolicy.diskComponentAdded(lsmIndex, false); } }
@SuppressWarnings("squid:S1181") @Override public void addBulkLoadedComponent(ILSMIOOperation ioOperation) throws HyracksDataException { ILSMDiskComponent c = ioOperation.getNewComponent(); try { c.markAsValid(lsmIndex.isDurable(), ioOperation); } catch (Throwable th) { ioOperation.setFailure(th); } if (ioOperation.hasFailed()) { throw HyracksDataException.create(ioOperation.getFailure()); } synchronized (opTracker) { lsmIndex.addDiskComponent(c); if (replicationEnabled) { componentsToBeReplicated.clear(); componentsToBeReplicated.add(c); triggerReplication(componentsToBeReplicated, LSMOperationType.LOAD); } // Enter the component enterComponent(c); mergePolicy.diskComponentAdded(lsmIndex, false); } }
public void register(LocalResource resource, ILSMIndex index) throws HyracksDataException { long resourceID = resource.getId(); if (!datasetInfo.isRegistered()) { synchronized (datasetInfo) { if (!datasetInfo.isRegistered()) { datasetInfo.setExternal(index.getNumberOfAllMemoryComponents() == 0); datasetInfo.setRegistered(true); datasetInfo.setDurable(index.isDurable()); } } } if (datasetInfo.getIndexes().containsKey(resourceID)) { throw new HyracksDataException("Index with resource ID " + resourceID + " already exists."); } if (index == null) { throw new HyracksDataException("Attempt to register a null index"); } datasetInfo.addIndex(resourceID, new IndexInfo(index, datasetInfo.getDatasetID(), resource, ((DatasetLocalResource) resource.getResource()).getPartition())); }
operation.getCallback().afterOperation(operation); if (newComponent != null) { newComponent.markAsValid(lsmIndex.isDurable(), operation);