Examples of BookKeeper


Examples of org.apache.bookkeeper.client.BookKeeper

        map = new HashMap<Integer, Integer>();
    }
   
    public TestClient(String servers) throws KeeperException, IOException, InterruptedException{
        this();
        x = new BookKeeper(servers);
        try{
        lh = x.createLedger(new byte[] {'a', 'b'});
        } catch (BKException e) {
            System.out.println(e.toString());
        }
View Full Code Here

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, new byte[] {'a', 'b'}, qSize, QMode.VERIFIABLE);
        } catch (BKException e) {
            System.out.println(e.toString());
        }
View Full Code Here

Examples of org.apache.bookkeeper.client.BookKeeper

   
    @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

Examples of org.apache.bookkeeper.client.BookKeeper

      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

Examples of org.apache.bookkeeper.client.BookKeeper

  }
   
    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

Examples of org.apache.bookkeeper.client.BookKeeper

  }
 
    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

Examples of org.apache.bookkeeper.client.BookKeeper

    @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++){
                bk.addEntry(beforelh, tmp.getBytes());
            }
        } catch(InterruptedException e){
            LOG.error("Interrupted when adding entry", e);
            fail("Couldn't finish adding entries");
        }
       
        ///*
        // * Sleep.
        // */
        //try{
        //    Thread.sleep(2000);
        //} catch(InterruptedException e){
        //    LOG.error("Interrupted while sleeping", e);
        //    fail("Couldn't finish sleeping");
        //}
       
        /*
         * 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() == 1000);
View Full Code Here

Examples of org.apache.bookkeeper.client.BookKeeper

          .await(zkConnectionLatchTimeout, TimeUnit.MILLISECONDS)) {
        throw new IOException("Error connecting to zookeeper");
      }

      prepareBookKeeperEnv();
      bkc = new BookKeeper(new ClientConfiguration(), zkc);
    } catch (KeeperException e) {
      throw new IOException("Error initializing zk", e);
    } catch (InterruptedException ie) {
      Thread.currentThread().interrupt();
      throw new IOException("Interrupted while initializing bk journal manager",
View Full Code Here

Examples of org.apache.bookkeeper.client.BookKeeper

        map = new HashMap<Integer, Integer>();
    }
   
    public TestClient(String servers) throws KeeperException, IOException, InterruptedException{
        this();
        x = new BookKeeper(servers);
        try{
        lh = x.createLedger(new byte[] {'a', 'b'});
        } catch (BKException e) {
            LOG.error(e.toString());
        }
View Full Code Here

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
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.