static PendingAddOp create(LedgerHandle lh, ClientContext clientCtx, List<BookieSocketAddress> ensemble, ByteBuf payload, EnumSet<WriteFlag> writeFlags, AddCallbackWithLatency cb, Object ctx) { PendingAddOp op = RECYCLER.get(); op.lh = lh; op.clientCtx = clientCtx; op.isRecoveryAdd = false; op.cb = cb; op.ctx = ctx; op.entryId = LedgerHandle.INVALID_ENTRY_ID; op.currentLedgerLength = -1; op.payload = payload; op.entryLength = payload.readableBytes(); op.completed = false; op.ensemble = ensemble; op.ackSet = lh.getDistributionSchedule().getAckSet(); op.pendingWriteRequests = 0; op.callbackTriggered = false; op.hasRun = false; op.requestTimeNanos = Long.MAX_VALUE; op.allowFailFast = false; op.qwcLatency = 0; op.writeFlags = writeFlags; return op; }
LedgerFragment(LedgerHandle lh, long firstEntryId, long lastKnownEntryId, Set<Integer> bookieIndexes) { this.ledgerId = lh.getId(); this.firstEntryId = firstEntryId; this.lastKnownEntryId = lastKnownEntryId; this.bookieIndexes = bookieIndexes; this.ensemble = lh.getLedgerMetadata().getEnsembleAt(firstEntryId); this.schedule = lh.getDistributionSchedule(); SortedMap<Long, ? extends List<BookieSocketAddress>> ensembles = lh .getLedgerMetadata().getAllEnsembles(); this.isLedgerClosed = lh.getLedgerMetadata().isClosed() || !ensemble.equals(ensembles.get(ensembles.lastKey())); }
void initiate() { // capture currentNonDurableLastAddConfirmed // remember that we are inside OrderedExecutor, this induces a strict ordering // on the sequence of events this.currentNonDurableLastAddConfirmed = lh.pendingAddsSequenceHead; if (LOG.isDebugEnabled()) { LOG.debug("force {} clientNonDurableLac {}", lh.ledgerId, currentNonDurableLastAddConfirmed); } // we need to send the request to every bookie in the ensamble this.ackSet = lh.distributionSchedule.getEnsembleAckSet(); DistributionSchedule.WriteSet writeSet = lh.getDistributionSchedule() .getEnsembleSet(currentNonDurableLastAddConfirmed); try { for (int i = 0; i < writeSet.size(); i++) { sendForceLedgerRequest(writeSet.get(i)); } } finally { writeSet.recycle(); } }
DistributionSchedule.WriteSet writeSet = lh.getDistributionSchedule().getWriteSet(entryToRead); for (int i = 0; i < writeSet.size(); i++) { BookieSocketAddress addr = curEnsemble.get(writeSet.get(i));
ReadLACAndEntryRequest(List<BookieSocketAddress> ensemble, long lId, long eId) { this.entryImpl = LedgerEntryImpl.create(lId, eId); this.ensemble = ensemble; this.writeSet = lh.getDistributionSchedule().getEnsembleSet(eId); if (clientCtx.getConf().enableReorderReadSequence) { this.orderedEnsemble = clientCtx.getPlacementPolicy().reorderReadLACSequence(ensemble, lh.getBookiesHealthInfo(), writeSet.copy()); } else { this.orderedEnsemble = writeSet.copy(); } }