Package org.apache.bookkeeper.client

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


        }
        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

        }
        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

        }
        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

            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

    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

    }
  
    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

            } 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

    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

Related Classes of org.apache.bookkeeper.client.LedgerEntry

Copyright © 2018 www.massapicom. 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.