org.apache.bookkeeper.client.BKException Java Examples
The following examples show how to use
org.apache.bookkeeper.client.BKException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManagedLedgerErrorsTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void recoverAfterMarkDeleteError() throws Exception { ManagedLedger ledger = factory.open("my_test_ledger"); ManagedCursor cursor = ledger.openCursor("my-cursor"); Position position = ledger.addEntry("entry".getBytes()); bkc.failNow(BKException.Code.BookieHandleNotAvailableException); zkc.failConditional(Code.CONNECTIONLOSS, (op, path) -> { return path.equals("/managed-ledgers/my_test_ledger/my-cursor") && op == MockZooKeeper.Op.SET; }); try { cursor.markDelete(position); fail("should fail"); } catch (ManagedLedgerException e) { // ok } // The metadata ledger is reopened in background, until it's not reopened the mark-delete will fail Thread.sleep(100); // Next markDelete should succeed cursor.markDelete(position); }
Example #2
Source File: BookKeeperEditLogOutputStream.java From hadoop with Apache License 2.0 | 6 votes |
/** * Transmit the current buffer to bookkeeper. * Synchronised at the FSEditLog level. #write() and #setReadyToFlush() * are never called at the same time. */ private void transmit() throws IOException { if (!transmitResult.compareAndSet(BKException.Code.OK, BKException.Code.OK)) { throw new IOException("Trying to write to an errored stream;" + " Error code : (" + transmitResult.get() + ") " + BKException.getMessage(transmitResult.get())); } if (bufCurrent.getLength() > 0) { byte[] entry = Arrays.copyOf(bufCurrent.getData(), bufCurrent.getLength()); lh.asyncAddEntry(entry, this, null); bufCurrent.reset(); outstandingRequests.incrementAndGet(); } }
Example #3
Source File: LedgerHandleCache.java From distributedlog with Apache License 2.0 | 6 votes |
/** * Async Read Entries * * @param ledgerDesc * ledger descriptor * @param first * first entry * @param last * second entry */ public Future<Enumeration<LedgerEntry>> asyncReadEntries( LedgerDescriptor ledgerDesc, long first, long last) { RefCountedLedgerHandle refHandle = handlesMap.get(ledgerDesc); if (null == refHandle) { LOG.error("Accessing ledger {} without opening.", ledgerDesc); return Future.exception(BKException.create(BKException.Code.UnexpectedConditionException)); } final Promise<Enumeration<LedgerEntry>> promise = new Promise<Enumeration<LedgerEntry>>(); refHandle.handle.asyncReadEntries(first, last, new AsyncCallback.ReadCallback() { @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> entries, Object ctx) { if (BKException.Code.OK == rc) { promise.setValue(entries); } else { promise.setException(BKException.create(rc)); } } }, null); return promise; }
Example #4
Source File: BookkeeperCommitLogManager.java From herddb with Apache License 2.0 | 6 votes |
@Override public void start() throws LogNotAvailableException { try { this.bookKeeper = BookKeeper .forConfig(config) .statsLogger(statsLogger) .build(); if (maxIdleTime > 0) { this.forceLastAddConfirmedTimer.scheduleWithFixedDelay(() -> { this.forceLastAddConfirmed(); }, maxIdleTime, maxIdleTime, TimeUnit.MILLISECONDS); } } catch (IOException | InterruptedException | BKException t) { close(); throw new LogNotAvailableException(t); } }
Example #5
Source File: CompactedTopicImpl.java From pulsar with Apache License 2.0 | 6 votes |
private static CompletableFuture<MessageIdData> readOneMessageId(LedgerHandle lh, long entryId) { CompletableFuture<MessageIdData> promise = new CompletableFuture<>(); lh.asyncReadEntries(entryId, entryId, (rc, _lh, seq, ctx) -> { if (rc != BKException.Code.OK) { promise.completeExceptionally(BKException.create(rc)); } else { // Need to release buffers for all entries in the sequence if (seq.hasMoreElements()) { LedgerEntry entry = seq.nextElement(); try (RawMessage m = RawMessageImpl.deserializeFrom(entry.getEntryBuffer())) { entry.getEntryBuffer().release(); while (seq.hasMoreElements()) { seq.nextElement().getEntryBuffer().release(); } promise.complete(m.getMessageIdData()); } } else { promise.completeExceptionally(new NoSuchElementException( String.format("No such entry %d in ledger %d", entryId, lh.getId()))); } } }, null); return promise; }
Example #6
Source File: ManagedCursorImpl.java From pulsar with Apache License 2.0 | 6 votes |
private void asyncDeleteLedger(final LedgerHandle lh, int retry) { if (lh == null || retry <= 0) { if (lh != null) { log.warn("[{}-{}] Failed to delete ledger after retries {}", ledger.getName(), name, lh.getId()); } return; } ledger.mbean.startCursorLedgerDeleteOp(); bookkeeper.asyncDeleteLedger(lh.getId(), (rc, ctx) -> { ledger.mbean.endCursorLedgerDeleteOp(); if (rc != BKException.Code.OK) { log.warn("[{}] Failed to delete ledger {}: {}", ledger.getName(), lh.getId(), BKException.getMessage(rc)); if (!isNoSuchLedgerExistsException(rc)) { ledger.getScheduledExecutor().schedule(safeRun(() -> asyncDeleteLedger(lh, retry - 1)), DEFAULT_LEDGER_DELETE_BACKOFF_TIME_SEC, TimeUnit.SECONDS); } return; } else { log.info("[{}][{}] Successfully closed & deleted ledger {} in cursor", ledger.getName(), name, lh.getId()); } }, null); }
Example #7
Source File: ReadAheadWorker.java From distributedlog with Apache License 2.0 | 6 votes |
private boolean closeCurrentLedgerHandle() { if (currentLH == null) { return true; } boolean retVal = false; LedgerDescriptor ld = currentLH; try { handleCache.closeLedger(ld); currentLH = null; retVal = true; } catch (BKException bke) { LOG.debug("BK Exception during closing {} : ", ld, bke); handleException(ReadAheadPhase.CLOSE_LEDGER, bke.getCode()); } return retVal; }
Example #8
Source File: BookKeeperClientFactoryImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public BookKeeper create(ServiceConfiguration conf, ZooKeeper zkClient, Optional<Class<? extends EnsemblePlacementPolicy>> ensemblePlacementPolicyClass, Map<String, Object> properties, StatsLogger statsLogger) throws IOException { ClientConfiguration bkConf = createBkClientConfiguration(conf); if (properties != null) { properties.forEach((key, value) -> bkConf.setProperty(key, value)); } if (ensemblePlacementPolicyClass.isPresent()) { setEnsemblePlacementPolicy(bkConf, conf, zkClient, ensemblePlacementPolicyClass.get()); } else { setDefaultEnsemblePlacementPolicy(rackawarePolicyZkCache, clientIsolationZkCache, bkConf, conf, zkClient); } try { return BookKeeper.forConfig(bkConf) .allocator(PulsarByteBufAllocator.DEFAULT) .statsLogger(statsLogger) .build(); } catch (InterruptedException | BKException e) { throw new IOException(e); } }
Example #9
Source File: BookKeeperClient.java From distributedlog with Apache License 2.0 | 6 votes |
public Future<LedgerHandle> createLedger(int ensembleSize, int writeQuorumSize, int ackQuorumSize) { BookKeeper bk; try { bk = get(); } catch (IOException ioe) { return Future.exception(ioe); } final Promise<LedgerHandle> promise = new Promise<LedgerHandle>(); bk.asyncCreateLedger(ensembleSize, writeQuorumSize, ackQuorumSize, BookKeeper.DigestType.CRC32, passwd, new AsyncCallback.CreateCallback() { @Override public void createComplete(int rc, LedgerHandle lh, Object ctx) { if (BKException.Code.OK == rc) { promise.updateIfEmpty(new Return<LedgerHandle>(lh)); } else { promise.updateIfEmpty(new Throw<LedgerHandle>(BKException.create(rc))); } } }, null); return promise; }
Example #10
Source File: BookkeeperCommitLogManager.java From herddb with Apache License 2.0 | 6 votes |
@Override public void close() { if (forceLastAddConfirmedTimer != null) { try { forceLastAddConfirmedTimer.shutdown(); } finally { forceLastAddConfirmedTimer = null; } } if (bookKeeper != null) { try { bookKeeper.close(); } catch (InterruptedException | BKException ex) { LOG.log(Level.SEVERE, null, ex); } } }
Example #11
Source File: BookKeeperEditLogOutputStream.java From big-c with Apache License 2.0 | 6 votes |
@Override public void flushAndSync(boolean durable) throws IOException { assert(syncLatch != null); try { syncLatch.await(); } catch (InterruptedException ie) { throw new IOException("Interrupted waiting on latch", ie); } if (transmitResult.get() != BKException.Code.OK) { throw new IOException("Failed to write to bookkeeper; Error is (" + transmitResult.get() + ") " + BKException.getMessage(transmitResult.get())); } syncLatch = null; // wait for whatever we wait on }
Example #12
Source File: OpAddEntry.java From pulsar with Apache License 2.0 | 6 votes |
@Override public void closeComplete(int rc, LedgerHandle lh, Object ctx) { checkArgument(ledger.getId() == lh.getId(), "ledgerId %s doesn't match with acked ledgerId %s", ledger.getId(), lh.getId()); if (rc == BKException.Code.OK) { log.debug("Successfuly closed ledger {}", lh.getId()); } else { log.warn("Error when closing ledger {}. Status={}", lh.getId(), BKException.getMessage(rc)); } ml.ledgerClosed(lh); updateLatency(); AddEntryCallback cb = callbackUpdater.getAndSet(this, null); if (cb != null) { cb.addComplete(PositionImpl.get(lh.getId(), entryId), ctx); ml.notifyCursors(); this.recycle(); } }
Example #13
Source File: ManagedCursorTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test(timeOut = 20000) void errorRecoveringCursor3() throws Exception { ManagedLedger ledger = factory.open("my_test_ledger"); Position p1 = ledger.addEntry("entry".getBytes()); ledger.addEntry("entry".getBytes()); ManagedCursor c1 = ledger.openCursor("c1"); Position p3 = ledger.addEntry("entry".getBytes()); assertEquals(c1.getReadPosition(), p3); ManagedLedgerFactory factory2 = new ManagedLedgerFactoryImpl(bkc, bkc.getZkHandle()); bkc.failAfter(4, BKException.Code.ReadException); ledger = factory2.open("my_test_ledger"); c1 = ledger.openCursor("c1"); // Verify the ManagedCursor was rewind back to the snapshotted position assertEquals(c1.getReadPosition(), p3); factory2.shutdown(); }
Example #14
Source File: BookKeeperJournalManager.java From big-c with Apache License 2.0 | 6 votes |
@Override public void purgeLogsOlderThan(long minTxIdToKeep) throws IOException { checkEnv(); for (EditLogLedgerMetadata l : getLedgerList(false)) { if (l.getLastTxId() < minTxIdToKeep) { try { Stat stat = zkc.exists(l.getZkPath(), false); zkc.delete(l.getZkPath(), stat.getVersion()); bkc.deleteLedger(l.getLedgerId()); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); LOG.error("Interrupted while purging " + l, ie); } catch (BKException bke) { LOG.error("Couldn't delete ledger from bookkeeper", bke); } catch (KeeperException ke) { LOG.error("Error deleting ledger entry in zookeeper", ke); } } } }
Example #15
Source File: ManagedCursorTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test(timeOut = 20000) void errorRecoveringCursor() throws Exception { ManagedLedger ledger = factory.open("my_test_ledger"); Position p1 = ledger.addEntry("entry".getBytes()); ledger.addEntry("entry".getBytes()); ManagedCursor c1 = ledger.openCursor("c1"); Position p3 = ledger.addEntry("entry".getBytes()); assertEquals(c1.getReadPosition(), p3); ManagedLedgerFactory factory2 = new ManagedLedgerFactoryImpl(bkc, bkc.getZkHandle()); bkc.failAfter(3, BKException.Code.LedgerRecoveryException); ledger = factory2.open("my_test_ledger"); c1 = ledger.openCursor("c1"); // Verify the ManagedCursor was rewind back to the snapshotted position assertEquals(c1.getReadPosition(), p3); factory2.shutdown(); }
Example #16
Source File: TwoPhaseCompactor.java From pulsar with Apache License 2.0 | 6 votes |
private CompletableFuture<LedgerHandle> createLedger(BookKeeper bk, Map<String,byte[]> metadata) { CompletableFuture<LedgerHandle> bkf = new CompletableFuture<>(); try { bk.asyncCreateLedger(conf.getManagedLedgerDefaultEnsembleSize(), conf.getManagedLedgerDefaultWriteQuorum(), conf.getManagedLedgerDefaultAckQuorum(), Compactor.COMPACTED_TOPIC_LEDGER_DIGEST_TYPE, Compactor.COMPACTED_TOPIC_LEDGER_PASSWORD, (rc, ledger, ctx) -> { if (rc != BKException.Code.OK) { bkf.completeExceptionally(BKException.create(rc)); } else { bkf.complete(ledger); } }, null, metadata); } catch (Throwable t) { log.error("Encountered unexpected error when creating compaction ledger", t); return FutureUtil.failedFuture(t); } return bkf; }
Example #17
Source File: BlobStoreManagedLedgerOffloaderTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testOffloadEmpty() throws Exception { CompletableFuture<LedgerEntries> noEntries = new CompletableFuture<>(); noEntries.completeExceptionally(new BKException.BKReadException()); ReadHandle readHandle = Mockito.mock(ReadHandle.class); Mockito.doReturn(-1L).when(readHandle).getLastAddConfirmed(); Mockito.doReturn(noEntries).when(readHandle).readAsync(anyLong(), anyLong()); Mockito.doReturn(0L).when(readHandle).getLength(); Mockito.doReturn(true).when(readHandle).isClosed(); Mockito.doReturn(1234L).when(readHandle).getId(); UUID uuid = UUID.randomUUID(); LedgerOffloader offloader = new BlobStoreManagedLedgerOffloader(blobStore, BUCKET, scheduler, DEFAULT_BLOCK_SIZE, DEFAULT_READ_BUFFER_SIZE); try { offloader.offload(readHandle, uuid, new HashMap<>()).get(); Assert.fail("Shouldn't have been able to offload"); } catch (ExecutionException e) { Assert.assertEquals(e.getCause().getClass(), IllegalArgumentException.class); } }
Example #18
Source File: LedgerHandleCache.java From distributedlog with Apache License 2.0 | 6 votes |
/** * Async read last confirmed and entry * * @param ledgerDesc * ledger descriptor * @param entryId * entry id to read * @param timeOutInMillis * time out if no newer entry available * @param parallel * whether to read from replicas in parallel */ public Future<Pair<Long, LedgerEntry>> asyncReadLastConfirmedAndEntry( LedgerDescriptor ledgerDesc, long entryId, long timeOutInMillis, boolean parallel) { RefCountedLedgerHandle refHandle = handlesMap.get(ledgerDesc); if (null == refHandle) { LOG.error("Accessing ledger {} without opening.", ledgerDesc); return Future.exception(BKException.create(BKException.Code.UnexpectedConditionException)); } final Promise<Pair<Long, LedgerEntry>> promise = new Promise<Pair<Long, LedgerEntry>>(); refHandle.handle.asyncReadLastConfirmedAndEntry(entryId, timeOutInMillis, parallel, new AsyncCallback.ReadLastConfirmedAndEntryCallback() { @Override public void readLastConfirmedAndEntryComplete(int rc, long lac, LedgerEntry ledgerEntry, Object ctx) { if (BKException.Code.OK == rc) { promise.setValue(Pair.of(lac, ledgerEntry)); } else { promise.setException(BKException.create(rc)); } } }, null); return promise; }
Example #19
Source File: ReadAheadWorker.java From distributedlog with Apache License 2.0 | 6 votes |
@Override public void operationComplete(final int rc, final LedgerDescriptor result) { // submit callback execution to dlg executor to avoid deadlock. submit(new Runnable() { @Override public void run() { if (BKException.Code.OK != rc) { LOG.debug("BK Exception {} while opening ledger", rc); handleException(ReadAheadPhase.OPEN_LEDGER, rc); return; } currentLH = result; if (conf.getTraceReadAheadMetadataChanges()) { LOG.info("Opened ledger of {} for {} at {}.", new Object[]{currentMetadata, fullyQualifiedName, System.currentTimeMillis()}); } bkcZkExceptions.set(0); bkcUnExpectedExceptions.set(0); bkcNoLedgerExceptionsOnReadLAC.set(0); next.process(rc); } }); }
Example #20
Source File: BKLogSegmentEntryReader.java From distributedlog with Apache License 2.0 | 6 votes |
/** * Check return code and retry if needed. * * @param rc the return code * @param isLongPoll is it a long poll request * @return is the request successful or not */ boolean checkReturnCodeAndHandleFailure(int rc, boolean isLongPoll) { if (BKException.Code.OK == rc) { numReadErrors.set(0); return true; } if (BKException.Code.BookieHandleNotAvailableException == rc || (isLongPoll && BKException.Code.NoSuchLedgerExistsException == rc)) { int numErrors = Math.max(1, numReadErrors.incrementAndGet()); int nextReadBackoffTime = Math.min(numErrors * readAheadWaitTime, maxReadBackoffTime); scheduler.schedule( getSegment().getLogSegmentId(), this, nextReadBackoffTime, TimeUnit.MILLISECONDS); } else { completeExceptionally(rc); } return false; }
Example #21
Source File: BKLogSegmentEntryStore.java From distributedlog with Apache License 2.0 | 6 votes |
@Override public void deleteComplete(int rc, Object ctx) { DeleteLogSegmentRequest deleteRequest = (DeleteLogSegmentRequest) ctx; if (BKException.Code.NoSuchLedgerExistsException == rc) { logger.warn("No ledger {} found to delete for {}.", deleteRequest.segment.getLogSegmentId(), deleteRequest.segment); } else if (BKException.Code.OK != rc) { logger.error("Couldn't delete ledger {} from bookkeeper for {} : {}", new Object[]{ deleteRequest.segment.getLogSegmentId(), deleteRequest.segment, BKException.getMessage(rc) }); FutureUtils.completeExceptionally(deleteRequest.deletePromise, new BKTransmitException("Couldn't delete log segment " + deleteRequest.segment, rc)); return; } FutureUtils.complete(deleteRequest.deletePromise, deleteRequest.segment); }
Example #22
Source File: ManagedLedgerErrorsTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void errorInRecovering() throws Exception { ManagedLedger ledger = factory.open("my_test_ledger"); ledger.addEntry("entry".getBytes()); ledger.close(); factory = new ManagedLedgerFactoryImpl(bkc, zkc); bkc.failNow(BKException.Code.LedgerFencedException); try { ledger = factory.open("my_test_ledger"); fail("should fail"); } catch (ManagedLedgerException e) { // ok } // It should be fine now ledger = factory.open("my_test_ledger"); }
Example #23
Source File: BookKeeperClient.java From distributedlog with Apache License 2.0 | 6 votes |
public CompletableFuture<LedgerHandle> createLedger(int ensembleSize, int writeQuorumSize, int ackQuorumSize) { BookKeeper bk; try { bk = get(); } catch (IOException ioe) { return FutureUtils.exception(ioe); } final CompletableFuture<LedgerHandle> promise = new CompletableFuture<LedgerHandle>(); bk.asyncCreateLedger(ensembleSize, writeQuorumSize, ackQuorumSize, BookKeeper.DigestType.CRC32, passwd, new AsyncCallback.CreateCallback() { @Override public void createComplete(int rc, LedgerHandle lh, Object ctx) { if (BKException.Code.OK == rc) { promise.complete(lh); } else { promise.completeExceptionally(BKException.create(rc)); } } }, null, Collections.emptyMap()); return promise; }
Example #24
Source File: ManagedLedgerTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testManagedLedgerWithCreateLedgerTimeOut() throws Exception { ManagedLedgerConfig config = new ManagedLedgerConfig().setMetadataOperationsTimeoutSeconds(3); ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("timeout_ledger_test", config); BookKeeper bk = mock(BookKeeper.class); doNothing().when(bk).asyncCreateLedger(anyInt(), anyInt(), anyInt(), any(), any(), any(), any(), any()); AtomicInteger response = new AtomicInteger(0); CountDownLatch latch = new CountDownLatch(1); AtomicReference<Object> ctxHolder = new AtomicReference<>(); ledger.asyncCreateLedger(bk, config, null, (rc, lh, ctx) -> { response.set(rc); latch.countDown(); ctxHolder.set(ctx); }, Collections.emptyMap()); latch.await(config.getMetadataOperationsTimeoutSeconds() + 2, TimeUnit.SECONDS); assertEquals(response.get(), BKException.Code.TimeoutException); assertTrue(ctxHolder.get() instanceof AtomicBoolean); AtomicBoolean ledgerCreated = (AtomicBoolean) ctxHolder.get(); assertFalse(ledgerCreated.get()); ledger.close(); }
Example #25
Source File: ManagedCursorImpl.java From pulsar with Apache License 2.0 | 6 votes |
private void asyncDeleteCursorLedger(int retry) { STATE_UPDATER.set(this, State.Closed); if (cursorLedger == null || retry <= 0) { if (cursorLedger != null) { log.warn("[{}-{}] Failed to delete ledger after retries {}", ledger.getName(), name, cursorLedger.getId()); } return; } ledger.mbean.startCursorLedgerDeleteOp(); bookkeeper.asyncDeleteLedger(cursorLedger.getId(), (rc, ctx) -> { ledger.mbean.endCursorLedgerDeleteOp(); if (rc == BKException.Code.OK) { log.info("[{}][{}] Deleted cursor ledger {}", ledger.getName(), name, cursorLedger.getId()); } else { log.warn("[{}][{}] Failed to delete ledger {}: {}", ledger.getName(), name, cursorLedger.getId(), BKException.getMessage(rc)); if (!isNoSuchLedgerExistsException(rc)) { ledger.getScheduledExecutor().schedule(safeRun(() -> asyncDeleteCursorLedger(retry - 1)), DEFAULT_LEDGER_DELETE_BACKOFF_TIME_SEC, TimeUnit.SECONDS); } } }, null); }
Example #26
Source File: OpAddEntry.java From pulsar with Apache License 2.0 | 5 votes |
@Override public void addComplete(int rc, final LedgerHandle lh, long entryId, Object ctx) { if (!STATE_UPDATER.compareAndSet(OpAddEntry.this, State.INITIATED, State.COMPLETED)) { log.warn("[{}] The add op is terminal legacy callback for entry {}-{} adding.", ml.getName(), lh.getId(), entryId); OpAddEntry.this.recycle(); return; } 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()); if (!checkAndCompleteOp(ctx)) { // means callback might have been completed by different thread (timeout task thread).. so do nothing return; } 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) { handleAddFailure(lh); } else { // Trigger addComplete callback in a thread hashed on the managed ledger name ml.getExecutor().executeOrdered(ml.getName(), this); } }
Example #27
Source File: CompactedTopicImpl.java From pulsar with Apache License 2.0 | 5 votes |
private static CompletableFuture<Void> tryDeleteCompactedLedger(BookKeeper bk, long id) { CompletableFuture<Void> promise = new CompletableFuture<>(); bk.asyncDeleteLedger(id, (rc, ctx) -> { if (rc != BKException.Code.OK) { log.warn("Error deleting compacted topic ledger {}", id, BKException.create(rc)); } else { log.debug("Compacted topic ledger deleted successfully"); } promise.complete(null); // don't propagate any error }, null); return promise; }
Example #28
Source File: LedgerHandleCache.java From distributedlog with Apache License 2.0 | 5 votes |
/** * Get the last add confirmed of <code>ledgerDesc</code>. * * @param ledgerDesc * ledger descriptor. * @return last add confirmed of <code>ledgerDesc</code> * @throws BKException */ public long getLastAddConfirmed(LedgerDescriptor ledgerDesc) throws BKException { RefCountedLedgerHandle refhandle = getLedgerHandle(ledgerDesc); if (null == refhandle) { LOG.error("Accessing ledger {} without opening.", ledgerDesc); throw BKException.create(BKException.Code.UnexpectedConditionException); } return refhandle.handle.getLastAddConfirmed(); }
Example #29
Source File: BKLogSegmentEntryReader.java From distributedlog with Apache License 2.0 | 5 votes |
@Override public void readLastConfirmedAndEntryComplete(int rc, long entryId, LedgerEntry entry, Object ctx) { if (failureInjector.shouldInjectCorruption(this.entryId, this.entryId)) { rc = BKException.Code.DigestMatchException; } processReadEntry(rc, entryId, entry, ctx); }
Example #30
Source File: ReadAheadWorker.java From distributedlog with Apache License 2.0 | 5 votes |
@Override void process(int rc) { if (!running) { setReadAheadStopped(); return; } if (null == stopPromise) { stopPromise = new Promise<Void>(); } // proceed the readahead request next.process(BKException.Code.OK); }