Package org.apache.bookkeeper.client

Examples of org.apache.bookkeeper.client.LedgerHandle.addEntry()


                long stopat = start + time;
                while(System.currentTimeMillis() < stopat) {
                    LedgerHandle lh = handles.get(r.nextInt(handles.size()));
                    if (sync) {
                        lh.addEntry(data);
                        success.incrementAndGet();
                    } else {
                        lh.asyncAddEntry(data, this, null);
                        outstanding.incrementAndGet();
                    }
View Full Code Here


                    LedgerEntry e = readEntry.nextElement();
                    assertEquals(toRead, e.getEntryId());
                    Assert.assertArrayEquals(entries.get(toRead), e.getEntry());
                    // should not written to a read only ledger
                    try {
                        lhOpen.addEntry(entry.array());
                        fail("Should have thrown an exception here");
                    } catch (BKException.BKIllegalOpException bkioe) {
                        // this is the correct response
                    } catch (Exception ex) {
                        LOG.error("Unexpected exception", ex);
View Full Code Here

                    LedgerEntry e = readEntry.nextElement();
                    assertEquals(toRead, e.getEntryId());
                    Assert.assertArrayEquals(entries.get(toRead), e.getEntry());
                    // should not written to a read only ledger
                    try {
                        lhOpen.addEntry(entry.array());
                        fail("Should have thrown an exception here");
                    } catch (BKException.BKIllegalOpException bkioe) {
                        // this is the correct response
                    } catch (Exception ex) {
                        LOG.error("Unexpected exception", ex);
View Full Code Here

        LedgerHandle beforelh = null;
        beforelh = bkc.createLedger(digestType, "".getBytes());

        String tmp = "BookKeeper is cool!";
        for (int i = 0; i < numEntries; i++) {
            beforelh.addEntry(tmp.getBytes());
        }

        long length = (long) (numEntries * tmp.length());

        /*
 
View Full Code Here

        long ledgerId = lh.getId();
        LOG.info("Ledger ID: " + lh.getId());
        String tmp = "BookKeeper is cool!";
        int numEntries = 30;
        for (int i = 0; i < numEntries; i++) {
            lh.addEntry(tmp.getBytes());
        }

        // Using wrong password
        ledgerPassword = "bbbb".getBytes();
        try {
View Full Code Here

        int numLedgers = 3;
        ArrayList<Long> ledgers = new ArrayList<Long>();
        for (int i=0; i<numLedgers; i++) {
            LedgerHandle lh = bkc.createLedger(1, 1, DigestType.CRC32, "bk is cool".getBytes());
            for (int j=0; j<5; j++) {
                lh.addEntry("just test".getBytes());
            }
            ledgers.add(lh.getId());
            lh.close();
        }
        for (long ledgerId : ledgers) {
View Full Code Here

        ledgers.clear();
        Thread.sleep(baseConf.getGcWaitTime() * 2);
        for (int i=0; i<numLedgers; i++) {
            LedgerHandle lh = bkc.createLedger(1, 1, DigestType.CRC32, "bk is cool".getBytes());
            for (int j=0; j<5; j++) {
                lh.addEntry("just test".getBytes());
            }
            ledgers.add(lh.getId());
            lh.close();
        }
    }
View Full Code Here

        // Create a new ledger to write entries
        String dummyMsg = "NoSuchLedger";
        int numMsgs = 3;
        LedgerHandle wlh = bkc.createLedger(1, 1, digestType, "".getBytes());
        for (int i=0; i<numMsgs; i++) {
            wlh.addEntry(dummyMsg.getBytes());
        }

        syncThread.resume();

        // trigger sync
View Full Code Here

        // write two page entries to ledger 2
        int numMsgs = 2 * pageSize / 8;
        LedgerHandle lh2 = bkc.createLedger(1, 1, digestType, "".getBytes());
        for (int i=0; i<numMsgs; i++) {
            lh2.addEntry(dummyMsg.getBytes());
        }

        syncThread.resume();

        // trigger sync
View Full Code Here

        writelh = bkc.createLedger(digestType, "".getBytes());

        String tmp = "BookKeeper is cool!";
        final int numEntries = 10;
        for (int i = 0; i < numEntries; i++) {
            writelh.addEntry(tmp.getBytes());
        }

        /*
         * Try to open ledger.
         */
 
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.