Package org.apache.bookkeeper.proto

Examples of org.apache.bookkeeper.proto.BookieClient


        this.zk = zk;
        this.channelFactory = channelFactory;
        this.scheduler = Executors.newSingleThreadScheduledExecutor();

        mainWorkerPool = new OrderedSafeExecutor(conf.getNumWorkerThreads());
        bookieClient = new BookieClient(conf, channelFactory, mainWorkerPool);
        bookieWatcher = new BookieWatcher(conf, scheduler, this);
        bookieWatcher.readBookiesBlocking();

        ledgerManagerFactory = LedgerManagerFactory.newLedgerManagerFactory(conf, zk);
        ledgerManager = ledgerManagerFactory.newLedgerManager();
View Full Code Here


    };

    @Test
    public void testWriteGaps() throws Exception {
        final Object notifyObject = new Object();
        BookieClient bc = new BookieClient("127.0.0.1", port, 50000);
        ByteBuffer bb;
        bb = createByteBuffer(1);
        bc.addEntry(1, 1, bb, wrcb, null);
        bb = createByteBuffer(2);
        bc.addEntry(1, 2, bb, wrcb, null);
        bb = createByteBuffer(3);
        bc.addEntry(1, 3, bb, wrcb, null);
        bb = createByteBuffer(5);
        bc.addEntry(1, 5, bb, wrcb, null);
        bb = createByteBuffer(7);
        bc.addEntry(1, 7, bb, wrcb, null);
        synchronized(notifyObject) {
            bb = createByteBuffer(11);
            bc.addEntry(1, 11, bb, wrcb, notifyObject);
            notifyObject.wait();
        }
        ResultStruct arc = new ResultStruct();
        synchronized(arc) {
            bc.readEntry(1, 6, recb, arc);
            arc.wait(1000);
            assertEquals(BookieProtocol.ENOENTRY, arc.rc);
        }
        synchronized(arc) {
            bc.readEntry(1, 7, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(7, arc.entry.getInt());
        }
        synchronized(arc) {
            bc.readEntry(1, 1, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(1, arc.entry.getInt());
        }
        synchronized(arc) {
            bc.readEntry(1, 2, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(2, arc.entry.getInt());
        }
        synchronized(arc) {
            bc.readEntry(1, 3, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(3, arc.entry.getInt());
        }
        synchronized(arc) {
            bc.readEntry(1, 4, recb, arc);
            arc.wait(1000);
            assertEquals(BookieProtocol.ENOENTRY, arc.rc);
        }
        synchronized(arc) {
            bc.readEntry(1, 11, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(11, arc.entry.getInt());
        }
        synchronized(arc) {
            bc.readEntry(1, 5, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(5, arc.entry.getInt());
        }
        synchronized(arc) {
            bc.readEntry(1, 10, recb, arc);
            arc.wait(1000);
            assertEquals(BookieProtocol.ENOENTRY, arc.rc);
        }
        synchronized(arc) {
            bc.readEntry(1, 12, recb, arc);
            arc.wait(1000);
            assertEquals(BookieProtocol.ENOENTRY, arc.rc);
        }
        synchronized(arc) {
            bc.readEntry(1, 13, recb, arc);
            arc.wait(1000);
            assertEquals(BookieProtocol.ENOENTRY, arc.rc);
        }
    }
View Full Code Here

        return bb;
    }
    @Test
    public void testNoLedger() throws Exception {
        ResultStruct arc = new ResultStruct();
        BookieClient bc = new BookieClient("127.0.0.1", port, 50000);
        synchronized(arc) {
            bc.readEntry(2, 13, recb, arc);
            arc.wait(1000);
            assertEquals(BookieProtocol.ENOLEDGER, arc.rc);
        }
    }
View Full Code Here

    }
   
    LoopbackClient(int port, long begin, int limit)
    throws IOException {
        this.client =
            new BookieClient(new InetSocketAddress("127.0.0.1", port), recvTimeout);
        this.begin = begin;
    }
View Full Code Here

    /**
     * @param lh  ledger handle
     * @param addr  address
     */
    BookieHandle(LedgerHandle lh, InetSocketAddress addr) throws IOException {
        this.client = new BookieClient(addr, recvTimeout);
        this.self = lh;
        this.addr = addr;
        this.incomingQueue = new ArrayBlockingQueue<ToSend>(2000);
       
        start();
View Full Code Here

     *
     * @return
     * @throws IOException
     */
    void restart() throws IOException {
        this.client = new BookieClient(addr, recvTimeout);
    }
View Full Code Here

         * Create BookieClient objects and send a request to each one.
         */
       
        for(InetSocketAddress s : bookies){
            LOG.info(s);
            BookieClient client = new BookieClient(s, 3000);
            clients.add(client);
            client.readEntry(lId,
                    -1,
                    this,
                    null);
        }       
       
View Full Code Here

                this.notify();
        }
    }

    LoopbackClient(ClientSocketChannelFactory channelFactory, OrderedSafeExecutor executor, long begin, int limit) throws IOException {
        this.client = new BookieClient(channelFactory, executor);
        this.begin = begin;
    }
View Full Code Here

        byte[] passwd = new byte[20];
        Arrays.fill(passwd, (byte) 'a');
        InetSocketAddress addr = new InetSocketAddress("127.0.0.1", port);
        ResultStruct arc = new ResultStruct();

        BookieClient bc = new BookieClient(channelFactory, executor);
        ChannelBuffer bb;
        bb = createByteBuffer(1, 1, 1);
        bc.addEntry(addr, 1, passwd, 1, bb, wrcb, null);
        synchronized (arc) {
            bc.readEntry(addr, 1, 1, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(1, arc.entry.getInt());
        }
        bb = createByteBuffer(2, 1, 2);
        bc.addEntry(addr, 1, passwd, 2, bb, wrcb, null);
        bb = createByteBuffer(3, 1, 3);
        bc.addEntry(addr, 1, passwd, 3, bb, wrcb, null);
        bb = createByteBuffer(5, 1, 5);
        bc.addEntry(addr, 1, passwd, 5, bb, wrcb, null);
        bb = createByteBuffer(7, 1, 7);
        bc.addEntry(addr, 1, passwd, 7, bb, wrcb, null);
        synchronized (notifyObject) {
            bb = createByteBuffer(11, 1, 11);
            bc.addEntry(addr, 1, passwd, 11, bb, wrcb, notifyObject);
            notifyObject.wait();
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 6, recb, arc);
            arc.wait(1000);
            assertEquals(BKException.Code.NoSuchEntryException, arc.rc);
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 7, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(7, arc.entry.getInt());
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 1, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(1, arc.entry.getInt());
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 2, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(2, arc.entry.getInt());
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 3, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(3, arc.entry.getInt());
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 4, recb, arc);
            arc.wait(1000);
            assertEquals(BKException.Code.NoSuchEntryException, arc.rc);
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 11, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(11, arc.entry.getInt());
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 5, recb, arc);
            arc.wait(1000);
            assertEquals(0, arc.rc);
            assertEquals(5, arc.entry.getInt());
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 10, recb, arc);
            arc.wait(1000);
            assertEquals(BKException.Code.NoSuchEntryException, arc.rc);
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 12, recb, arc);
            arc.wait(1000);
            assertEquals(BKException.Code.NoSuchEntryException, arc.rc);
        }
        synchronized (arc) {
            bc.readEntry(addr, 1, 13, recb, arc);
            arc.wait(1000);
            assertEquals(BKException.Code.NoSuchEntryException, arc.rc);
        }
    }
View Full Code Here

    @Test
    public void testNoLedger() throws Exception {
        ResultStruct arc = new ResultStruct();
        InetSocketAddress addr = new InetSocketAddress("127.0.0.1", port);
        BookieClient bc = new BookieClient(channelFactory, executor);
        synchronized (arc) {
            bc.readEntry(addr, 2, 13, recb, arc);
            arc.wait(1000);
            assertEquals(BKException.Code.NoSuchEntryException, arc.rc);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.bookkeeper.proto.BookieClient

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.