void setException(Throwable throwable) { Stopwatch stopwatch = Stopwatch.createStarted(); if (promise.updateIfEmpty(new Throw<List<LogRecordWithDLSN>>(throwable))) { futureSetLatency.registerFailedEvent(stopwatch.stop().elapsed(TimeUnit.MICROSECONDS)); delayUntilPromiseSatisfied.registerFailedEvent(enqueueTime.elapsed(TimeUnit.MICROSECONDS)); } }
@Override public void onFailure(Throwable cause) { LOG.info("failed to acquire readlock {} at {}", new Object[]{getLockClientId(), readLockPath, cause}); satisfyPromiseAsync(threadAcquirePromise, new Throw<Void>(cause)); } });
/** * Satisfy the <i>promise</i> with provided <i>cause</i>. * * @param promise promise to satisfy * @param cause cause to satisfy * @return true if successfully satisfy the future. false if the promise has been satisfied. */ public static <T> boolean setException(Promise<T> promise, Throwable cause) { boolean success = promise.updateIfEmpty(new Throw<T>(cause)); if (!success) { logger.info("Result set multiple times. Value = '{}', New = 'Throw({})'", promise.poll(), cause); } return success; }
@Override public void createComplete(int rc, LedgerHandle lh, Object ctx) { if (BKException.Code.OK == rc) { promise.updateIfEmpty(new Return<LedgerHandle>(lh)); } else { promise.updateIfEmpty(new Throw<LedgerHandle>(BKException.create(rc))); } } }, null);
@Override public void deleteComplete(int rc, Object ctx) { if (BKException.Code.OK == rc) { promise.updateIfEmpty(new Return<Void>(null)); } else if (BKException.Code.NoSuchLedgerExistsException == rc) { if (ignoreNonExistentLedger) { promise.updateIfEmpty(new Return<Void>(null)); } else { promise.updateIfEmpty(new Throw<Void>(BKException.create(rc))); } } else { promise.updateIfEmpty(new Throw<Void>(BKException.create(rc))); } } }, null);
@Override public void processResult(int rc, String path, Object ctx) { if (KeeperException.Code.OK.intValue() == rc) { promise.updateIfEmpty(new Return<Void>(null)); return; } promise.updateIfEmpty(new Throw<Void>( KeeperException.create(KeeperException.Code.get(rc)))); return; } }, null);
@Override public void processResult(int rc, String path, Object ctx, Stat stat) { if (KeeperException.Code.OK.intValue() == rc) { promise.updateIfEmpty(new Return<ZkVersion>(new ZkVersion(stat.getVersion()))); return; } promise.updateIfEmpty(new Throw<ZkVersion>( KeeperException.create(KeeperException.Code.get(rc)))); return; } }, null);
@Override public void onFailure(Throwable cause) { getOwnerPromise.updateIfEmpty(new Throw<SocketAddress>(cause)); }