@Override public void onSuccess(LogRecordWithDLSN record) { if (null == record) { asyncGetLastLogRecord(ledgerIter, promise, fence, includeControlRecord, includeEndOfStream); } else { promise.setValue(record); } }
@Override public void onSuccess(ZKAccessControl accessControl) { logger.info("Default Access Control will be changed from {} to {}", ZKAccessControlManager.this.defaultAccessControl, accessControl); ZKAccessControlManager.this.defaultAccessControl = accessControl; promise.setValue(accessControl); }
@Override public void onSuccess(LedgerHandle lh) { synchronized (LedgerAllocatorPool.this) { obtainMap.put(lh, allocator); reverseObtainMap.put(allocator, lh); tryObtainPromise.setValue(lh); } }
private synchronized void satisfyPromises(long lssn, long entryId, long startSlotId) { long nextSlotId = startSlotId; for (Promise<DLSN> promise : promiseList) { promise.setValue(new DLSN(lssn, entryId, nextSlotId)); nextSlotId++; } promiseList.clear(); }
@Override public void onFailure(Throwable cause) { if (cause instanceof LogEmptyException) { dlsnPromise.setValue(DLSN.InitialDLSN); } else { dlsnPromise.setException(cause); } } });
void complete() { if (LOG.isTraceEnabled()) { LOG.trace("{} : Satisfied promise with {} records", bkLedgerManager.getFullyQualifiedName(), records.size()); } delayUntilPromiseSatisfied.registerSuccessfulEvent(enqueueTime.stop().elapsed(TimeUnit.MICROSECONDS)); Stopwatch stopwatch = Stopwatch.createStarted(); promise.setValue(records); futureSetLatency.registerSuccessfulEvent(stopwatch.stop().elapsed(TimeUnit.MICROSECONDS)); } }
@Override public void readLastConfirmedAndEntryComplete(int rc, long lac, LedgerEntry ledgerEntry, Object ctx) { if (BKException.Code.OK == rc) { promise.setValue(Pair.of(lac, ledgerEntry)); } else { promise.setException(BKException.create(rc)); } } }, null);
@Override public void onSuccess(T value) { if (duplicatedLogFound.get()) { postCheckedPromise.setException(new UnexpectedException("Duplicate log found under " + namespace)); } else { postCheckedPromise.setValue(value); } }
@Override public void closeComplete(int rc, LedgerHandle ledgerHandle, Object ctx) { if (BKException.Code.OK == rc) { promise.setValue(null); } else { promise.setException(BKException.create(rc)); } } }, null);
@Override public void readLastConfirmedComplete(int rc, long lastAddConfirmed, Object ctx) { if (BKException.Code.OK == rc) { promise.setValue(lastAddConfirmed); } else { promise.setException(BKException.create(rc)); } } }, null);
@Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> entries, Object ctx) { if (BKException.Code.OK == rc) { promise.setValue(entries); } else { promise.setException(BKException.create(rc)); } } }, null);
@Override public void onSuccess(List<LogSegmentMetadata> value) { try { promise.setValue(getCachedLogSegments(comparator)); } catch (UnexpectedException e) { promise.setException(e); } }
@Override public void onSuccess(List<LogSegmentMetadata> ledgers) { forceGetListStat.registerSuccessfulEvent(stopwatch.stop().elapsed(TimeUnit.MICROSECONDS)); if (ledgers.isEmpty() && throwOnEmpty) { promise.setException(new LogEmptyException("Log " + getFullyQualifiedName() + " is empty")); } else { promise.setValue(ledgers); } }
@Override public void processResult(int rc, String path, Object ctx, List<String> children, Stat stat) { if (KeeperException.Code.NONODE.intValue() == rc) { result.setValue(new HashMap<String, DLSN>()); } else if (KeeperException.Code.OK.intValue() != rc) { result.setException(KeeperException.create(KeeperException.Code.get(rc), path)); } else { getLastCommitPositions(result, children); } } }, null);
@Override public void processResult(int rc, String path, Object ctx, String name) { if (KeeperException.Code.OK.intValue() == rc) { ZKAccessControl.this.zkVersion = 0; promise.setValue(ZKAccessControl.this); } else { promise.setException(KeeperException.create(KeeperException.Code.get(rc))); } } }, null);
@Override @SuppressWarnings("unchecked") public void processResult(int rc, String path, Object ctx, List<String> children, Stat stat) { Promise<List<String>> result = ((Promise<List<String>>) ctx); if (KeeperException.Code.OK.intValue() == rc) { result.setValue(children); } else { result.setException(KeeperException.create(KeeperException.Code.get(rc))); } }
@Override public void processResult(int rc, String path, Object ctx) { if (KeeperException.Code.OK.intValue() == rc || KeeperException.Code.NONODE.intValue() == rc) { promise.setValue(null); } else { promise.setException(KeeperException.create(KeeperException.Code.get(rc))); } } }, null);
@Override public void processResult(int rc, String path, Object ctx, Stat stat) { if (KeeperException.Code.OK.intValue() == rc) { ZKAccessControl.this.zkVersion = stat.getVersion(); promise.setValue(ZKAccessControl.this); } else { promise.setException(KeeperException.create(KeeperException.Code.get(rc))); } } }, null);
private static void handleKeeperExceptionCode(int rc, String pathOrMessage, Promise<BoxedUnit> result) { if (KeeperException.Code.OK.intValue() == rc) { result.setValue(BoxedUnit.UNIT); } else if (DistributedLogConstants.ZK_CONNECTION_EXCEPTION_RESULT_CODE == rc) { result.setException(new ZooKeeperClient.ZooKeeperConnectionException(pathOrMessage)); } else if (DistributedLogConstants.DL_INTERRUPTED_EXCEPTION_RESULT_CODE == rc) { result.setException(new DLInterruptedException(pathOrMessage)); } else { result.setException(KeeperException.create(KeeperException.Code.get(rc), pathOrMessage)); } }
@Override public void operationComplete(int rc, List<LogSegmentMetadata> segments) { if (KeeperException.Code.OK.intValue() == rc) { promise.setValue(segments); } else if (KeeperException.Code.NONODE.intValue() == rc) { promise.setException(new LogNotFoundException("Log " + getFullyQualifiedName() + " not found")); } else { String errMsg = "ZK Exception " + rc + " reading ledger list for " + getFullyQualifiedName(); promise.setException(new ZKException(errMsg, KeeperException.Code.get(rc))); } } });