Examples of LedgerEntry


Examples of org.apache.bookkeeper.client.LedgerEntry

                                     + topic.toStringUtf8(), bke);
                        request.callback.scanFailed(request.ctx, new PubSubException.ServiceDownException(bke));
                        return;
                    }

                    LedgerEntry entry = null;
                    while (seq.hasMoreElements()) {
                        entry = seq.nextElement();
                        Message message;
                        try {
                            message = Message.parseFrom(entry.getEntryInputStream());
                        } catch (IOException e) {
                            String msg = "Unreadable message found in ledger: " + imlr.range.getLedgerId()
                                         + " for topic: " + topic.toStringUtf8();
                            logger.error(msg, e);
                            request.callback.scanFailed(ctx, new PubSubException.UnexpectedConditionException(msg));
                            return;
                        }

                        if (logger.isDebugEnabled()) {
                            logger.debug("Read response from ledger: " + lh.getId() + " entry-id: "
                                         + entry.getEntryId());
                        }

                        assert expectedEntryId == entry.getEntryId() : "expectedEntryId (" + expectedEntryId
                        + ") != entry.getEntryId() (" + entry.getEntryId() + ")";
                        assert (message.getMsgId().getLocalComponent() - imlr.startSeqIdIncluded) == expectedEntryId;

                        expectedEntryId++;
                        request.callback.messageScanned(ctx, message);
                        numMessagesRead++;
                        totalSizeRead += message.getBody().size();

                        if (numMessagesRead >= request.messageLimit) {
                            request.callback.scanFinished(ctx, ReasonForFinish.NUM_MESSAGES_LIMIT_EXCEEDED);
                            return;
                        }

                        if (totalSizeRead >= request.sizeLimit) {
                            request.callback.scanFinished(ctx, ReasonForFinish.SIZE_LIMIT_EXCEEDED);
                            return;
                        }
                    }

                    // continue scanning messages
                    scanMessages(request, imlr.startSeqIdIncluded + entry.getEntryId() + 1);
                }
            }, request.ctx);
        }
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

        // Read the ledger entries to verify that they are all present and
        // correct in the new bookie.
        for (LedgerHandle lh : lhs) {
            Enumeration<LedgerEntry> entries = lh.readEntries(startEntryId, endEntryId);
            while (entries.hasMoreElements()) {
                LedgerEntry entry = entries.nextElement();
                assertTrue(new String(entry.getEntry()).equals("LedgerId: " + entry.getLedgerId() + ", EntryId: "
                           + entry.getEntryId()));
            }
        }

    }
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

        }
        Enumeration<LedgerEntry> entries
          = lh.readEntries(readEntries, readEntries);
        readEntries++;
        if (entries.hasMoreElements()) {
            LedgerEntry e = entries.nextElement();
            assert !entries.hasMoreElements();
            return e.getEntryInputStream();
        }
      } catch (BKException e) {
        throw new IOException("Error reading entries from bookkeeper", e);
      } catch (InterruptedException e) {
        throw new IOException("Interrupted reading entries from bookkeeper", e);
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

        }
        Enumeration<LedgerEntry> entries
          = lh.readEntries(readEntries, readEntries);
        readEntries++;
        if (entries.hasMoreElements()) {
            LedgerEntry e = entries.nextElement();
            assert !entries.hasMoreElements();
            return e.getEntryInputStream();
        }
      } catch (BKException e) {
        throw new IOException("Error reading entries from bookkeeper", e);
      } catch (InterruptedException e) {
        throw new IOException("Interrupted reading entries from bookkeeper", e);
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

        }
        Enumeration<LedgerEntry> entries
          = lh.readEntries(readEntries, readEntries);
        readEntries++;
        if (entries.hasMoreElements()) {
            LedgerEntry e = entries.nextElement();
            assert !entries.hasMoreElements();
            return e.getEntryInputStream();
        }
      } catch (BKException e) {
        throw new IOException("Error reading entries from bookkeeper", e);
      } catch (InterruptedException e) {
        throw new IOException("Interrupted reading entries from bookkeeper", e);
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

            if (rc != BKException.Code.OK) {
                LOG.error("Error while reading ledger entries." + BKException.getMessage(rc));
                ((BookKeeperStateBuilder.Context) ctx).setState(null);
            } else {
                while (entries.hasMoreElements()) {
                    LedgerEntry le = entries.nextElement();
                    lp.execute(ByteBuffer.wrap(le.getEntry()));

                    if (lp.finishedRecovery() || le.getEntryId() == 0) {
                        ((BookKeeperStateBuilder.Context) ctx).setState(lp.getState());
                    }
                }
                ((BookKeeperStateBuilder.Context) ctx).decrementPending();
            }
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

    private void verifyLedger(long lid, long startEntryId, long endEntryId) throws Exception {
        LedgerHandle lh = bkc.openLedger(lid, digestType, "".getBytes());
        Enumeration<LedgerEntry> entries = lh.readEntries(startEntryId, endEntryId);
        while (entries.hasMoreElements()) {
            LedgerEntry entry = entries.nextElement();
            assertEquals(msg, new String(entry.getEntry()));
        }
    }
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

    }
  
    public void readComplete(int rc, long ledgerId, LedgerSequence seq, Object ctx){
        System.out.println("Read callback: " + rc);
        while(seq.hasMoreElements()){
            LedgerEntry le = seq.nextElement();
            LOG.debug(new String(le.getEntry()));
        }
        synchronized(ctx){
            ctx.notify();
        }
    }
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

            } catch(InterruptedException ie) {
                Thread.currentThread().interrupt();
            }
            lastEntry = last;
        }
        LedgerEntry le = ledgerSeq.nextElement();
        bbytes = le.getEntry();
        bytebuff = ByteBuffer.wrap(bbytes);
        return true;
    }
View Full Code Here

Examples of org.apache.bookkeeper.client.LedgerEntry

    try {
      Enumeration<LedgerEntry> entries =
          ledger.readEntries(nextLedgerEntryId, nextLedgerEntryId);
      currentStreamState.incrementNextLedgerEntryId();
      if (entries.hasMoreElements()) {
        LedgerEntry entry = entries.nextElement();
        if (entries.hasMoreElements()) {
          throw new IllegalStateException("More than one entry retrieved!");
        }
        currentStreamState.setOffsetInEntry(0);
        return entry.getEntryInputStream();
      }
    } catch (BKException e) {
      throw new IOException("Unrecoverable BookKeeper error reading entry " +
          nextLedgerEntryId, e);
    } catch (InterruptedException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.