public static ManagedLedgerException createManagedLedgerException(Throwable t) { if (t instanceof org.apache.bookkeeper.client.api.BKException) { return createManagedLedgerException(((org.apache.bookkeeper.client.api.BKException) t).getCode()); } else { return new ManagedLedgerException("Unknown exception"); } }
/** * Create a new exception. * * @param code the error code * * @see Code */ public BKException(int code) { super(getMessage(code)); this.code = code; }
/** * Log the fence ledger entry in Journal so that we can rebuild the state. * @param journal log the fence entry in the Journal * @return A future which will be satisfied when add entry to journal complete */ private SettableFuture<Boolean> logFenceEntryInJournal(Journal journal) { SettableFuture<Boolean> result; synchronized (this) { result = logFenceResult = SettableFuture.create(); } ByteBuf entry = createLedgerFenceEntry(ledgerId); try { journal.logAddEntry(entry, false /* ackBeforeSync */, (rc, ledgerId, entryId, addr, ctx) -> { if (LOG.isDebugEnabled()) { LOG.debug("Record fenced state for ledger {} in journal with rc {}", ledgerId, BKException.codeLogger(rc)); } if (rc == 0) { fenceEntryPersisted.compareAndSet(false, true); result.set(true); } else { result.set(false); } }, null); } catch (InterruptedException e) { Thread.currentThread().interrupt(); result.setException(e); } return result; }
/** * Create a new exception with the <tt>cause</tt>. * * @param code exception code * @param cause the exception cause */ public BKException(int code, Throwable cause) { super(getMessage(code), cause); this.code = code; }
public static Exception bkException(String operation, int rc, long ledgerId, long entryId) { String message = org.apache.bookkeeper.client.api.BKException.getMessage(rc) + " - ledger=" + ledgerId; if (entryId != -1) { message += " - entry=" + entryId; } return new IOException(message); } }
if (exception != null) { if (exception instanceof BKException && ((BKException)exception).getCode() == BKException.Code.TooManyRequestsException) { callback.readEntriesFailed(createManagedLedgerException(exception), ctx); } else {
@Override public String toString() { return String.format("%d: %s", code, getMessage(code)); } }
public static ManagedLedgerException createManagedLedgerException(Throwable t) { if (t instanceof org.apache.bookkeeper.client.api.BKException) { return createManagedLedgerException(((org.apache.bookkeeper.client.api.BKException)t).getCode()); } else { return new ManagedLedgerException("Unknown exception"); } }
private void initPoolMessages(Field[] fields) { for (Field field : fields) { int code = getFieldInt(field); int index = poolIndex(code); if (index >= 0) { pool[index] = String.format("%s: %s", field.getName(), getMessage(code)); } } }
if (exception != null) { if (exception instanceof BKException && ((BKException)exception).getCode() == BKException.Code.TooManyRequestsException) { callback.readEntriesFailed(createManagedLedgerException(exception), ctx); } else {