@Override public void operationComplete(int rc, List<LogSegmentMetadata> result) { long elapsedMicros = stopwatch.stop().elapsed(TimeUnit.MICROSECONDS); if (KeeperException.Code.OK.intValue() != rc) { getListStat.registerFailedEvent(elapsedMicros); } else { if (LogSegmentFilter.DEFAULT_FILTER == segmentFilter) { isFullListFetched.set(true); } getListStat.registerSuccessfulEvent(elapsedMicros); } finalCallback.operationComplete(rc, result); } };
@Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> entries, Object ctx) { if (BKException.Code.NoSuchEntryException == rc) { callback.operationComplete(BKException.Code.OK, resultList); } else if (BKException.Code.OK == rc) { while (entries.hasMoreElements()) { resultList.add(entries.nextElement()); } long entryId = (Long) ctx; ++entryId; PendingReadOp readOp = new PendingReadOp(lh, lh.bk.scheduler, entryId, entryId, this, entryId); readOp.initiate(); } else { callback.operationComplete(rc, resultList); } } };
return; callback.operationComplete(rc, null); return; segmentList = getCachedLogSegments(comparator); } catch (UnexpectedException e) { callback.operationComplete(KeeperException.Code.DATAINCONSISTENCY.intValue(), null); return; callback.operationComplete(KeeperException.Code.OK.intValue(), segmentList); notifyUpdatedLogSegments(segmentList); if (!removedSegments.isEmpty()) {
/** * Errors out pending ops from per channel bookie client. As the channel * is being closed, all the operations waiting on the connection * will be sent to completion with error. */ void errorOutPendingOps(int rc) { Queue<GenericCallback<PerChannelBookieClient>> oldPendingOps; synchronized (this) { oldPendingOps = pendingOps; pendingOps = new ArrayDeque<>(); } for (GenericCallback<PerChannelBookieClient> pendingOp : oldPendingOps) { pendingOp.operationComplete(rc, PerChannelBookieClient.this); } }
private void failTLS(int rc) { LOG.error("TLS failure on: {}, rc: {}", channel, rc); Queue<GenericCallback<PerChannelBookieClient>> oldPendingOps; synchronized (this) { disconnect(); oldPendingOps = pendingOps; pendingOps = new ArrayDeque<>(); } for (GenericCallback<PerChannelBookieClient> pendingOp : oldPendingOps) { pendingOp.operationComplete(rc, null); } failedTlsHandshakeCounter.inc(); } }
private void completeOperation(GenericCallback<PerChannelBookieClient> op, int rc) { //Thread.dumpStack(); closeLock.readLock().lock(); try { if (ConnectionState.CLOSED == state) { op.operationComplete(BKException.Code.ClientClosedException, this); } else { op.operationComplete(rc, this); } } finally { closeLock.readLock().unlock(); } }
@Override public void onFailure(Throwable throwable) { if (throwable instanceof BKNoSuchEntryException) { callback.operationComplete(Code.OK, resultList); } else { int retCode; if (throwable instanceof BKException) { retCode = ((BKException) throwable).getCode(); } else { retCode = Code.UnexpectedConditionException; } callback.operationComplete(retCode, resultList); } } };
@Override public void processResult(int rc, String path, Object ctx) { callback.operationComplete(rc, ledgers); } }, null, BKException.Code.OK, BKException.Code.MetaStoreException);
public void readEntryComplete(int rc, long ledgerId, long entryId, ByteBuf buffer, Object ctx) { if (BKException.Code.NoSuchEntryException != rc && BKException.Code.NoSuchLedgerExistsException != rc) { entryMayExist.set(true); } if (numReads.decrementAndGet() == 0) { cb.operationComplete(rc, entryMayExist.get()); } } }
@Override public void operationComplete(int rc, Long result) { if (rc == BKException.Code.LedgerIdOverflowException) { // 31-bit IDs overflowed. Start using 63-bit ids. createLongLedgerIdPathAndGenerateLongLedgerId(cb, ledgerIdGenPath); } else { // 31-bit Generation worked OK, or had some other // error that we will pass on. cb.operationComplete(rc, result); } } });
public void process(WatchedEvent e) { if (e.getType() == Watcher.Event.EventType.NodeDataChanged) { cb.operationComplete(0, null); } } };
public void process(WatchedEvent e) { if (e.getType() == Watcher.Event.EventType.NodeDeleted) { LOG.info("LedgerReplication is enabled externally through Zookeeper, " + "since DISABLE_NODE ZNode is deleted"); cb.operationComplete(0, null); } } };
public void operationComplete(int rc, LedgerFragment result) { if (rc == BKException.Code.ClientClosedException) { cb.operationComplete(BKException.Code.ClientClosedException, badFragments); return; } else if (rc != BKException.Code.OK) { badFragments.add(result); } if (numFragments.decrementAndGet() == 0) { cb.operationComplete(BKException.Code.OK, badFragments); } } }
public void readEntryComplete(int rc, long ledgerId, long entryId, ByteBuf buffer, Object ctx) { if (rc == BKException.Code.OK) { if (numEntries.decrementAndGet() == 0 && !completed.getAndSet(true)) { cb.operationComplete(rc, fragment); } } else if (!completed.getAndSet(true)) { cb.operationComplete(rc, fragment); } } }
@Override public void operationComplete(int rc, T result) { if (successRc == rc) { statsLogger.registerSuccessfulEvent(MathUtils.elapsedNanos(startTime), TimeUnit.NANOSECONDS); } else { statsLogger.registerFailedEvent(MathUtils.elapsedNanos(startTime), TimeUnit.NANOSECONDS); } cb.operationComplete(rc, result); } }
@Override public void operationComplete(int rc, T result) { closeLock.readLock().lock(); try { if (!closed && null != removeCallback(cb)) { cb.operationComplete(rc, result); } } finally { closeLock.readLock().unlock(); } } }
} catch (ZooKeeperClient.ZooKeeperConnectionException e) { getListStat.registerFailedEvent(stopwatch.stop().elapsed(TimeUnit.MICROSECONDS)); finalCallback.operationComplete(KeeperException.Code.CONNECTIONLOSS.intValue(), null); } catch (InterruptedException e) { getListStat.registerFailedEvent(stopwatch.stop().elapsed(TimeUnit.MICROSECONDS)); finalCallback.operationComplete(KeeperException.Code.CONNECTIONLOSS.intValue(), null);
@Override public void readLastConfirmedDataComplete(int rc, DigestManager.RecoveryData recoveryData) { if (BKException.Code.OK != rc) { callback.operationComplete(rc, resultList); return; } if (LedgerHandle.INVALID_ENTRY_ID >= recoveryData.lastAddConfirmed) { callback.operationComplete(BKException.Code.OK, resultList); return; } long entryId = recoveryData.lastAddConfirmed; PendingReadOp readOp = new PendingReadOp(lh, lh.bk.scheduler, entryId, entryId, readCallback, entryId); try { readOp.initiate(); } catch (Throwable t) { logger.error("Failed to initialize pending read entry {} for ledger {} : ", new Object[] { entryId, lh.getLedgerMetadata(), t }); } } };
@Override public void readEntryComplete(int rc, long lid, long eid, ChannelBuffer buffer, Object ctx) { BookieSocketAddress bookieAddress = (BookieSocketAddress) ctx; ReadResult<InputStream> rr; if (BKException.Code.OK != rc) { rr = new ReadResult<InputStream>(eid, rc, null, bookieAddress.getSocketAddress()); } else { try { ChannelBufferInputStream is = lh.macManager.verifyDigestAndReturnData(eid, buffer); rr = new ReadResult<InputStream>(eid, BKException.Code.OK, is, bookieAddress.getSocketAddress()); } catch (BKException.BKDigestMatchException e) { rr = new ReadResult<InputStream>(eid, BKException.Code.DigestMatchException, null, bookieAddress.getSocketAddress()); } } readResults.add(rr); if (numBookies.decrementAndGet() == 0) { callback.operationComplete(BKException.Code.OK, readResults); } } };
@Override public void readEntryComplete(int rc, long lid, long eid, ChannelBuffer buffer, Object ctx) { InetSocketAddress bookieAddress = (InetSocketAddress) ctx; ReadResult<Long> rr; if (BKException.Code.OK != rc) { rr = new ReadResult<Long>(eid, rc, null, bookieAddress); } else { try { DigestManager.RecoveryData data = lh.macManager.verifyDigestAndReturnLastConfirmed(buffer); rr = new ReadResult<Long>(eid, BKException.Code.OK, data.lastAddConfirmed, bookieAddress); } catch (BKException.BKDigestMatchException e) { rr = new ReadResult<Long>(eid, BKException.Code.DigestMatchException, null, bookieAddress); } } readResults.add(rr); if (numBookies.decrementAndGet() == 0) { callback.operationComplete(BKException.Code.OK, readResults); } } };