Package com.taobao.metamorphosis.network

Examples of com.taobao.metamorphosis.network.PutCommand


        this.metaConfig.setMaxSegmentSize(1024 * 1024 * 16);
        ConcurrentTestCase testCase = new ConcurrentTestCase(80, 1000, new ConcurrentTestTask() {

            @Override
            public void run(int index, int times) throws Exception {
                final PutCommand cmd =
                        new PutCommand(MessageStoreUnitTest.this.topic, MessageStoreUnitTest.this.partition,
                            new byte[1024], null, 0, 0);
                final long id = MessageStoreUnitTest.this.idWorker.nextId();
                final CountDownLatch latch = new CountDownLatch(1);
                MessageStoreUnitTest.this.messageStore.append(id, cmd, new AppendCallback() {
                    @Override
View Full Code Here


        // �����һ��
        this.clearTopicPartDir();

        final int offset = 2048;
        this.messageStore = new MessageStore(this.topic, this.partition, this.metaConfig, this.deletePolicy, offset);
        final PutCommand cmd1 = new PutCommand(this.topic, this.partition, "hello".getBytes(), null, 0, 0);
        final PutCommand cmd2 = new PutCommand(this.topic, this.partition, "world".getBytes(), null, 0, 0);
        final long id1 = this.idWorker.nextId();
        final long id2 = this.idWorker.nextId();
        this.messageStore.append(id1, cmd1, new AppendCallback() {
            @Override
            public void appendComplete(final Location location) {
View Full Code Here

    }


    @Test
    public void testAppendMessagesRoll() throws Exception {
        final PutCommand req = new PutCommand(this.topic, this.partition, "hello".getBytes(), null, 0, 0);
        final AtomicLong size = new AtomicLong(0);
        for (int i = 0; i < MSG_COUNT; i++) {
            if (i == 0) {
                this.messageStore.append(this.idWorker.nextId(), req, new AppendCallback() {
View Full Code Here

    }


    @Test
    public void testAppendMessagesCloseRecover() throws Exception {
        final PutCommand req = new PutCommand(this.topic, this.partition, "hello".getBytes(), null, 0, 0);
        final AtomicLong size = new AtomicLong(0);
        for (int i = 0; i < 100; i++) {
            if (i == 0) {
                this.messageStore.append(this.idWorker.nextId(), req, new AppendCallback() {
View Full Code Here

    }


    @Test
    public void testSlice() throws Exception {
        final PutCommand req = new PutCommand(this.topic, this.partition, "hello".getBytes(), null, 0, 0);
        for (int i = 0; i < MSG_COUNT; i++) {
            this.messageStore.append(this.idWorker.nextId(), req, null);
        }
        FileMessageSet subSet = (FileMessageSet) this.messageStore.slice(0, this.metaConfig.getMaxSegmentSize() - 10);
        assertEquals(0, subSet.getOffset());
View Full Code Here


    @Test
    public void testRunDeletePolicy() throws Exception {
        ((DiscardDeletePolicy) this.deletePolicy).setMaxReservedTime(1000);
        final PutCommand req = new PutCommand(this.topic, this.partition, "hello".getBytes(), null, 0, 0);
        for (int i = 0; i < MSG_COUNT; i++) {
            this.messageStore.append(this.idWorker.nextId(), req, null);
        }

        final File partDir = this.messageStore.getPartitionDir();
View Full Code Here

    }


    @Test
    public void testAppendMany() throws Exception {
        final PutCommand cmd1 = new PutCommand(this.topic, this.partition, "hello".getBytes(), null, 0, 0);
        final PutCommand cmd2 = new PutCommand(this.topic, this.partition, "world".getBytes(), null, 0, 0);
        final long id1 = this.idWorker.nextId();
        final long id2 = this.idWorker.nextId();

        final List<Long> ids = new ArrayList<Long>();
        ids.add(id1);
View Full Code Here

        for (final PutCommand req : reqs) {
            capacity += 4 + 4 + 8 + 4 + req.getData().length;
        }
        final ByteBuffer buffer = ByteBuffer.allocate(capacity);
        for (int i = 0; i < reqs.size(); i++) {
            final PutCommand req = reqs.get(i);
            final long msgId = msgIds.get(i);
            buffer.putInt(req.getData().length);
            buffer.putInt(CheckSum.crc32(req.getData()));
            buffer.putLong(msgId);
            buffer.putInt(req.getFlag());
            buffer.put(req.getData());
        }
        buffer.flip();
        return buffer;
    }
View Full Code Here

        final long offset = 12;
        final Broker broker = new Broker(0, "meta://localhost:0");
        final int msgId = 1111;
        final byte[] data =
                MessageUtils.makeMessageBuffer(msgId,
                    new PutCommand(topic, partition.getPartition(), "hello".getBytes(), null, 0, 0)).array();
        final FetchRequest request =
                new FetchRequest(broker, 0, new TopicPartitionRegInfo(topic, partition, offset), maxSize);

        final FetchRequestRunner runner = this.fetchManager.new FetchRequestRunner();
View Full Code Here

        final long offset = 12;
        final Broker broker = new Broker(0, "meta://localhost:0");
        final int msgId = 1111;
        final byte[] data =
                MessageUtils.makeMessageBuffer(msgId,
                    new PutCommand(topic, partition.getPartition(), "hello".getBytes(), null, 0, 0)).array();
        final FetchRequest request =
                new FetchRequest(broker, 0, new TopicPartitionRegInfo(topic, partition, offset), maxSize);

        final FetchRequestRunner runner = this.fetchManager.new FetchRequestRunner();
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.network.PutCommand

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.