private void handleCompatibilityMode(final SplitfileCompatibilityModeEvent ce, ClientContext context) { if(persistence == Persistence.FOREVER && context.jobRunner.hasLoaded()) { try { context.jobRunner.queue(new PersistentJob() { @Override public boolean run(ClientContext context) { innerHandleCompatibilityMode(ce, context); return false; } }, NativeThread.HIGH_PRIORITY); } catch (PersistenceDisabledException e) { // Not much we can do } } else { innerHandleCompatibilityMode(ce, context); } }
private void failDiskOffThread(final IOException e) { parent.jobRunner.queueNormalOrDrop(new PersistentJob() { @Override public boolean run(ClientContext context) { parent.failOnDiskError(e); return true; } }); }
/** Called when a ClientPutState transitions to a new state. If this is the current state, then we update * it, but it might also be a subsidiary state, in which case we ignore it. */ @Override public void onTransition(ClientPutState oldState, ClientPutState newState, ClientContext context) { if(newState == null) throw new NullPointerException(); synchronized (this) { if (currentState == oldState) { currentState = newState; return; } } if(persistent()) context.jobRunner.setCheckpointASAP(); Logger.normal(this, "onTransition: cur=" + currentState + ", old=" + oldState + ", new=" + newState); }
core.clientContext.jobRunner.queue(new PersistentJob() {
context.jobRunner.queue(new PersistentJob() { if(!context.jobRunner.shuttingDown()) Logger.error(this, "Database disabled compressing data", new Exception("error")); shouldFreeOnFinally = true; context.jobRunner.queue(new PersistentJob() {
@Override public boolean start(MemoryLimitedChunk chunk) { boolean shutdown = false; CheckpointLock lock = null; try { lock = parent.jobRunner.lock(); innerEncode(chunk); } catch (PersistenceDisabledException e) { // Will be retried on restarting. shutdown = true; } finally { chunk.release(); try { if(!shutdown) { // We do want to call the callback even if we threw something, because we // may be waiting to cancel. However we DON'T call it if we are shutting down. synchronized(SplitFileInserterCrossSegmentStorage.this) { encoding = false; } parent.onFinishedEncoding(SplitFileInserterCrossSegmentStorage.this); } } finally { // Callback is part of the persistent job, unlock *after* calling it. if(lock != null) lock.unlock(false, MemoryLimitedJobRunner.THREAD_PRIORITY); } } return true; }
context.getJobRunner(persistent).queueInternal(new PersistentJob() {
context.getChkFetchScheduler(realTimeFlag).fetchingKeys(), context.ticker, context.memoryLimitedJobRunner, new CRCChecksumChecker(), context.jobRunner.newSalt(), salter, resumed, callbackCompleteViaTruncation != null); } catch (ResumeFailedException e) {
@Override public void onFailure(final InsertException e, ClientPutState c, ClientContext context) { if(persistent) { try { context.jobRunner.queue(new PersistentJob() { @Override public boolean run(ClientContext context) { inserter.cb.onFailure(e, inserter, context); return true; } }, NativeThread.NORM_PRIORITY+1); } catch (PersistenceDisabledException e1) { // Can't do anything } } else { inserter.cb.onFailure(e, inserter, context); } }
@Override public boolean start(MemoryLimitedChunk chunk) { boolean shutdown = false; CheckpointLock lock = null; try { lock = parent.jobRunner.lock(); innerEncode(chunk); } catch (PersistenceDisabledException e) { // Will be retried on restarting. shutdown = true; } finally { chunk.release(); try { if(!shutdown) { // We do want to call the callback even if we threw something, because we // may be waiting to cancel. However we DON'T call it if we are shutting down. synchronized(SplitFileInserterSegmentStorage.this) { encoding = false; } parent.onFinishedEncoding(SplitFileInserterSegmentStorage.this); } } finally { // Callback is part of the persistent job, unlock *after* calling it. if(lock != null) lock.unlock(false, MemoryLimitedJobRunner.THREAD_PRIORITY); } } return true; }
} else { context.getJobRunner(persistent()).queueInternal(new PersistentJob() {
public void failedBlock() { jobRunner.queueNormalOrDrop(new PersistentJob() { @Override public boolean run(ClientContext context) { fetcher.onFailedBlock(); return false; } }); }
final CountDownLatch done = new CountDownLatch(1); final AtomicBoolean success = new AtomicBoolean(); core.clientContext.jobRunner.queue(new PersistentJob() {
/** * Called when we have metadata for all the PutHandler's. * This does *not* necessarily mean we can immediately insert the final metadata, since * if these metadata's are too big, they will need to be inserted separately. See * resolveAndStartBase(). * @param container * @param context */ private void gotAllMetadata(ClientContext context) { if (containerMode) throw new IllegalStateException(); if(logMINOR) Logger.minor(this, "Got all metadata"); baseMetadata = makeMetadata(rootDir); context.jobRunner.setCheckpointASAP(); resolveAndStartBase(context); }
CheckpointLock lock = null; try { lock = parent.jobRunner.lock(); innerDecode(chunk); } catch (IOException e) {
context.getJobRunner(persistent).queueInternal(new PersistentJob() {
public void restartedAfterDataCorruption(boolean wasCorrupt) { jobRunner.queueNormalOrDrop(new PersistentJob() { @Override public boolean run(ClientContext context) { maybeClearCooldown(); fetcher.restartedAfterDataCorruption(); return false; } }); }
@Override public void run() { try { context.jobRunner.queue(this, NativeThread.HIGH_PRIORITY-1); } catch (PersistenceDisabledException e) { outputHandler.queue(new EndListPersistentRequestsMessage(listRequestIdentifier)); } }
/** * Called when the current state creates a new state and we switch to that. For example, a * SingleFileFetcher might switch to a SplitFileFetcher. Sometimes this will be called with oldState * not equal to our currentState; this means that a subsidiary request has changed state, so we * ignore it. */ @Override public void onTransition(ClientGetState oldState, ClientGetState newState, ClientContext context) { synchronized(this) { if(currentState == oldState) { currentState = newState; if(logMINOR) Logger.minor(this, "Transition: "+oldState+" -> "+newState+" on "+this+" persistent = "+persistent()+" instance = "+super.toString(), new Exception("debug")); } else { if(logMINOR) Logger.minor(this, "Ignoring transition: "+oldState+" -> "+newState+" because current = "+currentState+" on "+this+" persistent = "+persistent(), new Exception("debug")); return; } } if(persistent()) context.jobRunner.setCheckpointASAP(); }
CheckpointLock lock = null; try { lock = parent.jobRunner.lock(); innerDecode(chunk); } catch (IOException e) {