public void failed(ManagedLedgerException e) { if (!checkAndCompleteTimeoutTask()) { return; } AddEntryCallback cb = callbackUpdater.getAndSet(this, null); data.release(); if (cb != null) { cb.addFailed(e, ctx); ml.mbean.recordAddEntryError(); } }
/** * It handles add failure on the given ledger. it can be triggered when add-entry fails or times out. * * @param ledger */ void handleAddFailure(final LedgerHandle ledger) { // If we get a write error, we will try to create a new ledger and re-submit the pending writes. If the // ledger creation fails (persistent bk failure, another instanche owning the ML, ...), then the writes will // be marked as failed. ml.mbean.recordAddEntryError(); ml.getExecutor().executeOrdered(ml.getName(), SafeRun.safeRun(() -> { // Force the creation of a new ledger. Doing it in a background thread to avoid acquiring ML lock // from a BK callback. ml.ledgerClosed(ledger); })); }
public void failed(ManagedLedgerException e) { AddEntryCallback cb = callbackUpdater.getAndSet(this, null); data.release(); if (cb != null) { cb.addFailed(e, ctx); ml.mbean.recordAddEntryError(); } }
public void failed(ManagedLedgerException e) { AddEntryCallback cb = callbackUpdater.getAndSet(this, null); if (cb != null) { cb.addFailed(e, ctx); ml.mbean.recordAddEntryError(); } }
@Override public void addComplete(int rc, final LedgerHandle lh, long entryId, Object ctx) { checkArgument(ledger.getId() == lh.getId()); checkArgument(this.ctx == ctx); this.entryId = entryId; if (log.isDebugEnabled()) { log.debug("[{}] [{}] write-complete: ledger-id={} entry-id={} size={} rc={}", this, ml.getName(), lh.getId(), entryId, dataLength, rc); } if (rc != BKException.Code.OK) { // If we get a write error, we will try to create a new ledger and re-submit the pending writes. If the // ledger creation fails (persistent bk failure, another instanche owning the ML, ...), then the writes will // be marked as failed. ml.mbean.recordAddEntryError(); ml.getExecutor().submitOrdered(ml.getName(), SafeRun.safeRun(() -> { // Force the creation of a new ledger. Doing it in a background thread to avoid acquiring ML lock // from a BK callback. ml.ledgerClosed(lh); })); } else { // Trigger addComplete callback in a thread hashed on the managed ledger name ml.getExecutor().submitOrdered(ml.getName(), this); } }
@Override public void addComplete(int rc, final LedgerHandle lh, long entryId, Object ctx) { if (ledger.getId() != lh.getId()) { log.warn("[{}] ledgerId {} doesn't match with acked ledgerId {}", ml.getName(), ledger.getId(), lh.getId()); } checkArgument(ledger.getId() == lh.getId(), "ledgerId %s doesn't match with acked ledgerId %s", ledger.getId(), lh.getId()); checkArgument(this.ctx == ctx); this.entryId = entryId; if (log.isDebugEnabled()) { log.debug("[{}] [{}] write-complete: ledger-id={} entry-id={} size={} rc={}", this, ml.getName(), lh.getId(), entryId, dataLength, rc); } if (rc != BKException.Code.OK) { // If we get a write error, we will try to create a new ledger and re-submit the pending writes. If the // ledger creation fails (persistent bk failure, another instanche owning the ML, ...), then the writes will // be marked as failed. ml.mbean.recordAddEntryError(); ml.getExecutor().executeOrdered(ml.getName(), SafeRun.safeRun(() -> { // Force the creation of a new ledger. Doing it in a background thread to avoid acquiring ML lock // from a BK callback. ml.ledgerClosed(lh); })); } else { // Trigger addComplete callback in a thread hashed on the managed ledger name ml.getExecutor().executeOrdered(ml.getName(), this); } }