Package org.zper.base.ZLog

Examples of org.zper.base.ZLog.SegmentInfo


        Context ctx = ZMQ.context(1);
        Socket sock = ctx.socket(ZMQ.DEALER);

        ZLog zlog = ZLogManager.instance().get(topic);
        SegmentInfo[] infos = zlog.segments();
        SegmentInfo last = infos[infos.length - 1];

        sock.setIdentity(ZPUtils.genTopicIdentity(topic, 0));

        sock.connect("tcp://127.0.0.1:6556");

        //  Latest offset
        sock.sendMore("FETCH");
        sock.sendMore(ByteBuffer.allocate(8).putLong(last.start()).array());
        sock.send(ByteBuffer.allocate(8).putLong(Integer.MAX_VALUE).array());

        Msg status = sock.base().recv(0);
        assertEquals(100, status.data()[0]);

        Msg result = sock.base().recv(0);
        assertEquals((int) (last.offset() - last.start()), result.size());

        Iterator<Msg> it = new MsgIterator(result.buf(), false);
        while (it.hasNext()) {
            it.next();
        }
View Full Code Here


            return;
        }
        long offset = args.get(0).buf().getLong();
        long size = args.get(1).buf().getLong();

        SegmentInfo info = zlog.segmentInfo(offset);

        if (info == null || info.flushedOffset() < offset) {
            LOG.info("No such segment for offset {}, or found {}",
                    offset, info == null ? -1 : info.flushedOffset());
            code(ZPConstants.TYPE_RESPONSE, ZPConstants.STATUS_INVALID_OFFSET);
            return;
        }

        assert (info.start() <= offset);

        code(ZPConstants.TYPE_FILE, ZPConstants.STATUS_OK);
        worker.sendMore(info.path());
        sendLong(offset - info.start(), true);
        if (info.flushedOffset() - offset < size)
            size = info.flushedOffset() - offset;
        sendLong(size, false);

        if (LOG.isDebugEnabled())
            LOG.debug("FETCH {} {} {}", new Object[] {offset, size, offset + size});
View Full Code Here

TOP

Related Classes of org.zper.base.ZLog.SegmentInfo

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.