Package org.apache.bookkeeper.client

Examples of org.apache.bookkeeper.client.BookKeeper


    }
   
    public TestClient(String servers, int ensSize, int qSize)
    throws KeeperException, IOException, InterruptedException{
        this();
        x = new BookKeeper(servers);
        try{
        lh = x.createLedger(ensSize, qSize, QMode.VERIFIABLE, new byte[] {'a', 'b'});
        } catch (BKException e) {
            LOG.error(e.toString());
        }
View Full Code Here


   
    @Test
    public void testAsyncCreateClose() throws IOException{
        try {
            // Create a BookKeeper client and a ledger
            bkc = new BookKeeper("127.0.0.1");
          
            ControlObj ctx = new ControlObj();
           
            synchronized(ctx){
                bkc.asyncCreateLedger(3, 2,
View Full Code Here

    }
   
    @Test
    public void testOpenException()
    throws KeeperException, IOException, InterruptedException {
        bkc = new BookKeeper("127.0.0.1");
        try{
            lh = bkc.openLedger(0, ledgerPassword);
            fail("Haven't thrown exception");
        } catch (BKException e) {
            LOG.warn("Successfully thrown and caught exception:", e);
View Full Code Here

     * @throws {@link IOException}, {@link KeeperException}
     */
    @Test
    public void testStreamingClients() throws IOException,
        KeeperException, BKException, InterruptedException {
        bkc = new BookKeeper("127.0.0.1");
        lh = bkc.createLedger(ledgerPassword);
        //write a string so that we cna
        // create a buffer of a single bytes
        // and check for corner cases
        String toWrite = "we need to check for this string to match " +
View Full Code Here

   
    @Test
    public void testReadWriteAsyncSingleClient() throws IOException{
        try {
            // Create a BookKeeper client and a ledger
            bkc = new BookKeeper("127.0.0.1");
            lh = bkc.createLedger(ledgerPassword);
            //bkc.initMessageDigest("SHA1");
            ledgerId = lh.getId();
            LOG.info("Ledger ID: " + lh.getId());
            for(int i = 0; i < numEntriesToWrite; i++){
View Full Code Here

        LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT");
        String charset = "utf-8";
        LOG.debug("Default charset: "  + Charset.defaultCharset());
        try {
            // Create a BookKeeper client and a ledger
            bkc = new BookKeeper("127.0.0.1");
            lh = bkc.createLedger(ledgerPassword);
            //bkc.initMessageDigest("SHA1");
            ledgerId = lh.getId();
            LOG.info("Ledger ID: " + lh.getId());
            for(int i = 0; i < numEntriesToWrite; i++){
View Full Code Here

   
    @Test
    public void testReadWriteSyncSingleClient() throws IOException {
        try {
            // Create a BookKeeper client and a ledger
            bkc = new BookKeeper("127.0.0.1");
            lh = bkc.createLedger(ledgerPassword);
            //bkc.initMessageDigest("SHA1");
            ledgerId = lh.getId();
            LOG.info("Ledger ID: " + lh.getId());
            for(int i = 0; i < numEntriesToWrite; i++){
View Full Code Here

   
    @Test
    public void testReadWriteZero() throws IOException {
        try {
            // Create a BookKeeper client and a ledger
            bkc = new BookKeeper("127.0.0.1");
            lh = bkc.createLedger(ledgerPassword);
            //bkc.initMessageDigest("SHA1");
            ledgerId = lh.getId();
            LOG.info("Ledger ID: " + lh.getId());
            for(int i = 0; i < numEntriesToWrite; i++){            
View Full Code Here

   
    @Test
    public void testMultiLedger() throws IOException {
        try {
            // Create a BookKeeper client and a ledger
            bkc = new BookKeeper("127.0.0.1");
            lh = bkc.createLedger(ledgerPassword);
            lh2 = bkc.createLedger(ledgerPassword);
           
            long ledgerId = lh.getId();
            long ledgerId2 = lh2.getId();
View Full Code Here

    @Test
    public void testLedgerRecovery(){
        /*
         * Instantiate BookKeeper object.
         */
        BookKeeper bk = null;
        try{
            bk = new BookKeeper(HOSTPORT);
        } catch (KeeperException ke){
            LOG.error("Error instantiating BookKeeper", ke);
            fail("ZooKeeper error");
        } catch (IOException ioe){
            LOG.error(ioe);
            fail("Failure due to IOException");
        }
       
        /*
         * Create ledger.
         */
        LedgerHandle beforelh = null;
        try{
            beforelh = bk.createLedger("".getBytes());
        } catch (KeeperException ke){
            LOG.error("Error creating a ledger", ke);
            fail("ZooKeeper error");           
        } catch (BKException bke){
            LOG.error("BookKeeper error");
            fail("BookKeeper error");
        } catch (InterruptedException ie) {
            LOG.error(ie);
            fail("Failure due to interrupted exception");
        } catch (IOException ioe) {
            LOG.error(ioe);
            fail("Failure due to IO exception");
        }
       
        /*
         * Write a 1000 entries.
         */
        try{
            String tmp = "BookKeeper is cool!";
            for(int i = 0; i < 1000; i++){
                beforelh.addEntry(tmp.getBytes());
            }
           
            //bk.resetLedger(beforelh);
        } catch(InterruptedException e){
            LOG.error("Interrupted when adding entry", e);
            fail("Couldn't finish adding entries");
        } catch(BKException e){
            LOG.error("BookKeeper exception", e);
            fail("BookKeeper exception while adding entries");
        }
       
        /*
         * Try to open ledger.
         */
        try{
            LedgerHandle afterlh = bk.openLedger(beforelh.getId(), "".getBytes());
           
            /*
             * Check if has recovered properly.
             */
            assertTrue("Has not recovered correctly: " + afterlh.getLast(), afterlh.getLast() == 999);
View Full Code Here

TOP

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

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.