/** * Execute a task which must be performed asnychronously, but has no requirement * for timely execution. This task pool is used for compactions, creating KRFS, etc. * So some of the queued tasks may take a while. */ public boolean executeDiskStoreTask(final Runnable runnable) { return executeDiskStoreTask(runnable, this.diskStoreTaskPool) != null; }
/** * Execute a task asynchronously, or in the calling thread if the bound * is reached. This pool is used for write operations which can be delayed, * but we have a limit on how many write operations we delay so that * we don't run out of disk space. Used for deletes, unpreblow, RAF close, etc. */ public boolean executeDelayedExpensiveWrite(Runnable task) { Future<?> f = executeDiskStoreTask(task, this.delayedWritePool); lastDelayedWrite = f; return f != null; }
void scheduleValueRecovery(Set<Oplog> oplogsNeedingValueRecovery, Map<Long, DiskRecoveryStore> recoveredStores) { ValueRecoveryTask task = new ValueRecoveryTask(oplogsNeedingValueRecovery, recoveredStores); synchronized (currentAsyncValueRecoveryMap) { DiskStoreImpl.this.currentAsyncValueRecoveryMap.putAll(recoveredStores); } executeDiskStoreTask(task); }
/** * Schedule a task to create a krf asynchronously * */ protected void createKrfAsync() { getParent().executeDiskStoreTask(new Runnable() { public void run() { createKrf(false); } }); }
void scheduleValueRecovery(Set<Oplog> oplogsNeedingValueRecovery, Map<Long, DiskRecoveryStore> recoveredStores) { ValueRecoveryTask task = new ValueRecoveryTask(oplogsNeedingValueRecovery, recoveredStores); synchronized (currentAsyncValueRecoveryMap) { DiskStoreImpl.this.currentAsyncValueRecoveryMap.putAll(recoveredStores); } executeDiskStoreTask(task); }
/** * Execute a task which must be performed asnychronously, but has no requirement * for timely execution. This task pool is used for compactions, creating KRFS, etc. * So some of the queued tasks may take a while. */ public boolean executeDiskStoreTask(final Runnable runnable) { return executeDiskStoreTask(runnable, getCache().getDiskStoreTaskPool(), true) != null; }
/** * Execute a task asynchronously, or in the calling thread if the bound * is reached. This pool is used for write operations which can be delayed, * but we have a limit on how many write operations we delay so that * we don't run out of disk space. Used for deletes, unpreblow, RAF close, etc. */ public boolean executeDelayedExpensiveWrite(Runnable task) { Future<?> f = (Future<?>)executeDiskStoreTask(task, getCache().getDiskDelayedWritePool(), false); lastDelayedWrite = f; return f != null; }
private Future<?> executeDiskStoreTask(final Runnable runnable, ThreadPoolExecutor executor) { // schedule another thread to do it incBackgroundTasks(); Future<?> result = executeDiskStoreTask(new DiskStoreTask() { public void run() { try { markBackgroundTaskThread(); // for bug 42775 //getCache().getCachePerfStats().decDiskTasksWaiting(); runnable.run(); } finally { decBackgroundTasks(); } } public void taskCancelled() { decBackgroundTasks(); } }, executor); if(result == null) { decBackgroundTasks(); } return result; }
/** * @return true if compaction done; false if it was not */ private synchronized boolean schedule(CompactableOplog[] opLogs) { assert !this.scheduled; if (!this.compactorEnabled) return false; if (opLogs != null) { for (int i = 0; i < opLogs.length; i++) { opLogs[i].prepareForCompact(); } this.scheduled = true; this.scheduledOplogs = opLogs; boolean result = executeDiskStoreTask(this); if (!result) { reschedule(false); return false; } else { return true; } } else { return false; } }
private Object executeDiskStoreTask(final Runnable runnable, ThreadPoolExecutor executor, boolean async) { // schedule another thread to do it incBackgroundTasks(); Object result = executeDiskStoreTask(new DiskStoreTask() { public void run() { try { markBackgroundTaskThread(); // for bug 42775 //getCache().getCachePerfStats().decDiskTasksWaiting(); runnable.run(); } finally { decBackgroundTasks(); } } public void taskCancelled() { decBackgroundTasks(); } }, executor, async); if (result == null) { decBackgroundTasks(); } return result; }
/** * @return true if compaction done; false if it was not */ private synchronized boolean schedule(CompactableOplog[] opLogs) { assert !this.scheduled; if (!this.compactorEnabled) return false; if (opLogs != null) { for (int i = 0; i < opLogs.length; i++) { // logger.info(LocalizedStrings.DEBUG, // "schedule oplog#" + opLogs[i].getOplogId(), // new RuntimeException("STACK")); opLogs[i].prepareForCompact(); } this.scheduled = true; this.scheduledOplogs = opLogs; boolean result = executeDiskStoreTask(this); if (!result) { reschedule(false, new CompactableOplog[0]); return false; } else { return true; } } else { return false; } }
public void scheduleIndexRecovery(Set<Oplog> allOplogs, boolean recreateIndexes) { // schedule index recovery atmost once if (markIndexRecoveryScheduled()) { IndexRecoveryTask task = new IndexRecoveryTask(allOplogs, recreateIndexes); // other disk store threads wait for this task, so use a different // thread pool for execution if possible (not in loner VM) ThreadPoolExecutor executor = getCache() .getWaitingThreadPoolOrDiskWritePool(); executeDiskStoreTask(task, executor, true); } }
+ parent.getName()); boolean submitted = getParent().executeDiskStoreTask(new Runnable() { public void run() {
private void handleNoLiveValues() { if (!this.doneAppending) { return; } // At one point this method was a noop for the pure overflow case. // But it turns out it was cheaper to delete empty oplogs and create // new ones instead of overwriting the empty one. // This is surprising and may be specific to Linux ext3. // So at some point we may want to comment out the following block // of code and check performance again. if (hasNoLiveValues()) { getOplogSet().removeOverflow(this); if (calledByCompactorThread()) { handleEmpty(true); } else { getParent().executeDiskStoreTask(new Runnable() { public void run() { handleEmpty(false); } }); } } else if (!isCompacting() && needsCompaction()) { addToBeCompacted(); } }
private void handleNoLiveValues() { if (!this.doneAppending) { return; } // At one point this method was a noop for the pure overflow case. // But it turns out it was cheaper to delete empty oplogs and create // new ones instead of overwriting the empty one. // This is surprising and may be specific to Linux ext3. // So at some point we may want to comment out the following block // of code and check performance again. if (hasNoLiveValues()) { getOplogSet().removeOverflow(this); if (calledByCompactorThread()) { handleEmpty(true); } else { getParent().executeDiskStoreTask(new Runnable() { public void run() { handleEmpty(false); } }); } } else if (!isCompacting() && needsCompaction()) { addToBeCompacted(); } }
} else { getParent().executeDiskStoreTask(new Runnable() { public void run() { handleEmptyAndOldest(false); } else { getParent().executeDiskStoreTask(new Runnable() { public void run() { handleEmpty(false);
} else { getParent().executeDiskStoreTask(new Runnable() { public void run() { handleEmptyAndOldest(false); } else { getParent().executeDiskStoreTask(new Runnable() { public void run() { handleEmpty(false);