public static LedgerMetadata getLedgerMetadata(LedgerHandle lh) { return lh.getLedgerMetadata(); } }
static public SortedMap<Long, ArrayList<BookieSocketAddress>> bookiesForLedger(final LedgerHandle lh) { return lh.getLedgerMetadata().getEnsembles(); }
ArrayList<BookieSocketAddress> ensemble = lh.getLedgerMetadata().getEnsemble(eid); for (Integer idx : writeSet) { bookieClient.readEntry(ensemble.get(idx), lh.getId(), eid, readEntryCallback, ensemble.get(idx));
ArrayList<BookieSocketAddress> ensemble = lh.getLedgerMetadata().getEnsemble(eid); for (Integer idx : writeSet) { bookieClient.readEntry(ensemble.get(idx), lh.getId(), eid, readEntryCallback, ensemble.get(idx));
@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 }); } } };
/** * @return the metadata for the passed ledger handle */ public LedgerMetadata getLedgerMetadata(LedgerHandle lh) { return lh.getLedgerMetadata(); }
protected LedgerMetadata getLedgerMetadata() { return lh.getLedgerMetadata(); }
SequenceReadRequest(List<BookieSocketAddress> ensemble, long lId, long eId) { super(ensemble, lId, eId); this.sentReplicas = new BitSet(lh.getLedgerMetadata().getWriteQuorumSize()); this.erroredReplicas = new BitSet(lh.getLedgerMetadata().getWriteQuorumSize()); }
void setLac(long lac) { this.lac = lac; this.receivedResponseSet = new BitSet( lh.getLedgerMetadata().getWriteQuorumSize()); this.receivedResponseSet.set(0, lh.getLedgerMetadata().getWriteQuorumSize()); }
/** * Get this ledger's customMetadata map. * * @return map containing user provided customMetadata. */ public Map<String, byte[]> getCustomMetadata() { return getLedgerMetadata().getCustomMetadata(); }
/** * Get the number of fragments that makeup this ledger. * * @return the count of fragments */ public synchronized long getNumFragments() { return getLedgerMetadata().getAllEnsembles().size(); }
/** * Returns the ledger creation time. * * @return the ledger creation time */ public long getCtime() { return getLedgerMetadata().getCtime(); }
/** * {@inheritDoc} */ @Override public synchronized boolean isClosed() { return getLedgerMetadata().isClosed(); }
/** * Get the count of unique bookies that own part of this ledger * by going over all the fragments of the ledger. * * @return count of unique bookies */ public synchronized long getNumBookies() { Map<Long, ? extends List<BookieSocketAddress>> m = getLedgerMetadata().getAllEnsembles(); Set<BookieSocketAddress> s = Sets.newHashSet(); for (List<BookieSocketAddress> aList : m.values()) { s.addAll(aList); } return s.size(); }
boolean isHandleWritable() { return !getLedgerMetadata().isClosed() && handleState == HandleState.OPEN; }
public static SortedMap<Long, ? extends List<BookieSocketAddress>> bookiesForLedger(final LedgerHandle lh) { return lh.getLedgerMetadata().getAllEnsembles(); }
/** * Notify the LedgerHandle that a read operation was failed on a particular bookie. */ void recordReadErrorOnBookie(int bookieIndex) { // If sticky bookie reads are enabled, switch the sticky bookie to the // next bookie in the ensemble so that we avoid to keep reading from the // same failed bookie if (stickyBookieIndex != -1) { // This will be idempotent when we have multiple read errors on the // same bookie. The net result is that we just go to the next bookie stickyBookieIndex = clientCtx.getPlacementPolicy().getStickyReadBookieIndex(getLedgerMetadata(), Optional.of(bookieIndex)); } }
TryReadLastConfirmedOp(LedgerHandle lh, BookieClient bookieClient, List<BookieSocketAddress> ensemble, LastConfirmedDataCallback cb, long lac) { this.lh = lh; this.bookieClient = bookieClient; this.cb = cb; this.maxRecoveredData = new RecoveryData(lac, 0); this.numResponsesPending = lh.getLedgerMetadata().getEnsembleSize(); this.currentEnsemble = ensemble; }
void handleUnrecoverableErrorDuringAdd(int rc) { if (getLedgerMetadata().getState() == LedgerMetadata.State.IN_RECOVERY) { // we should not close ledger if ledger is recovery mode // otherwise we may lose entry. errorOutPendingAdds(rc); return; } LOG.error("Closing ledger {} due to {}", ledgerId, BKException.codeLogger(rc)); asyncCloseInternal(NoopCloseCallback.instance, null, rc); }
public ReadLastConfirmedOp(LedgerHandle lh, BookieClient bookieClient, List<BookieSocketAddress> ensemble, LastConfirmedDataCallback cb) { this.cb = cb; this.bookieClient = bookieClient; this.maxRecoveredData = new RecoveryData(LedgerHandle.INVALID_ENTRY_ID, 0); this.lh = lh; this.numResponsesPending = lh.getLedgerMetadata().getEnsembleSize(); this.coverageSet = lh.distributionSchedule.getCoverageSet(); this.currentEnsemble = ensemble; }