Package org.apache.bookkeeper.client

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


        }

        // Now add the current ledger dir to filled dirs list
        ledgerDirsManager.addToFilledDirs(new File(ledgerDirs[0], "current"));
        for (int i = 0; i < 10; i++) {
            ledger.addEntry("data".getBytes());
        }
        assertEquals("writable dirs should have one dir", 1, ledgerDirsManager
                .getWritableLedgerDirs().size());
        assertTrue("Bookie should shutdown if readOnlyMode not enabled",
                bookie.isAlive());
View Full Code Here


     * Try to read closed ledger from restarted ReadOnlyBookie.
     */
    public void testReadFromReadOnlyBookieShouldBeSuccess() throws Exception {
        LedgerHandle ledger = bkc.createLedger(2, 2, DigestType.MAC, "".getBytes());
        for (int i = 0; i < 10; i++) {
            ledger.addEntry("data".getBytes());
        }
        ledger.close();
        bsConfs.get(1).setReadOnlyModeEnabled(true);
        bsConfs.get(1).setDiskCheckInterval(500);
        restartBookies();
View Full Code Here

            LedgerHandle lh = bk.createLedger(ensemble, writeQuorum, ackQuorum,
                                              BookKeeper.DigestType.MAC, new byte[0]);
            System.out.println("Ledger ID: " + lh.getId());
            long lastReport = System.nanoTime();
            for (int i = 0; i < numEntries; i++) {
                lh.addEntry(data);
                if (TimeUnit.SECONDS.convert(System.nanoTime() - lastReport,
                                             TimeUnit.NANOSECONDS) > 1) {
                    System.out.println(i + " entries written");
                    lastReport = System.nanoTime();
                }
View Full Code Here

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

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

        /*
         * Try to open ledger.
         */
 
View Full Code Here

        final CountDownLatch latch = new CountDownLatch(numRecovery);
        Thread writethread = new Thread() {
                public void run() {
                    try {
                        while (true) {
                            writelh.addEntry(tmp.getBytes());
                            latch.countDown();
                        }
                    } catch (Exception e) {
                        LOG.info("Exception adding entry", e);
                    }
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

        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

        LedgerHandle writelh = bkc.createLedger(3,3,digestType, "testPasswd".getBytes());
        String tmp = "Foobar";
       
        final int numEntries = 10;
        for (int i = 0; i < numEntries; i++) {
            writelh.addEntry(tmp.getBytes());
        }
       
        Set<InetSocketAddress> beforeSet = new HashSet<InetSocketAddress>();
        for (InetSocketAddress addr : writelh.getLedgerMetadata().getEnsemble(numEntries)) {
            beforeSet.add(addr);
View Full Code Here

                numberOfLedgers);
        for (int index = 0; index < numberOfLedgers; index++) {
            LedgerHandle lh = bkc.createLedger(3, 3, digestType, PASSWD);
            listOfLedgerHandle.add(lh);
            for (int i = 0; i < numberOfEntries; i++) {
                lh.addEntry(data);
            }
        }
        return listOfLedgerHandle;
    }
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.