Package com.taobao.metamorphosis.cluster

Examples of com.taobao.metamorphosis.cluster.Partition


    @Test
    public void testSendMessageNormal_NoBroker() throws Exception {
        final String topic = "topic1";
        final byte[] data = "hello".getBytes();
        final Message message = new Message(topic, data);
        final Partition partition = new Partition("0-0");
        EasyMock.expect(this.producerZooKeeper.selectPartition(topic, message, this.partitionSelector)).andReturn(
            partition);
        EasyMock.expect(this.producerZooKeeper.selectBroker(topic, partition)).andReturn(null);
        this.mocksControl.replay();
        try {
View Full Code Here


    public void testSendOrderedMessageServerError() throws Exception {
        final String topic = "topic1";
        final byte[] data = "hello".getBytes();
        final Message message = new Message(topic, data);
        final String url = "meta://localhost:0";
        final Partition partition = new Partition("0-0");
        // �����ظ�3��
        EasyMock.expect(this.producerZooKeeper.selectPartition(topic, message, this.partitionSelector)).andReturn(
            partition);// .times(3);
        EasyMock.expect(this.producerZooKeeper.selectBroker(topic, partition)).andReturn(url);// .times(3);
        OpaqueGenerator.resetOpaque();
        final int flag = MessageFlagUtils.getFlag(null);
        EasyMock.expect(
            this.remotingClient.invokeToGroup(url,
                new PutCommand(topic, partition.getPartition(), data, flag, CheckSum.crc32(data), null,
                    Integer.MIN_VALUE), 3000, TimeUnit.MILLISECONDS)).andReturn(
                        new BooleanCommand(500, "server error", Integer.MIN_VALUE));
        // EasyMock.expect(
        // this.remotingClient.invokeToGroup(url, new PutCommand(topic,
        // partition.getPartition(), data, null, flag,
View Full Code Here

        try {
            final String topic = "topic1";
            final byte[] data = "hello".getBytes();
            final Message message = new Message(topic, data);
            final String url = "meta://localhost:0";
            final Partition partition = new Partition("0-0");
            EasyMock.expect(this.producerZooKeeper.selectPartition(topic, message, this.partitionSelector)).andReturn(
                partition);
            EasyMock.expect(this.producerZooKeeper.selectBroker(topic, partition)).andReturn(url);
            OpaqueGenerator.resetOpaque();
            final int flag = MessageFlagUtils.getFlag(null);
            EasyMock.expect(
                this.remotingClient.invokeToGroup(url, new PutCommand(topic, partition.getPartition(), data, flag,
                    CheckSum.crc32(data), null, Integer.MIN_VALUE), 3000, TimeUnit.MILLISECONDS)).andThrow(
                        new InterruptedException());
            this.mocksControl.replay();
            this.producer.sendMessage(message);
        }
View Full Code Here

    @Test
    public void testGet() throws Exception {
        final String topic = "topic1";
        final int maxSize = 1024;
        final Partition partition = new Partition("0-0");
        final long offset = 12;
        final byte[] data = "hello".getBytes();
        final String url = "meta://localhost:0";
        final MessageIterator messageIterator = new MessageIterator(topic, data);

        this.producerZooKeeper.publishTopic(topic, this.consumer);
        EasyMock.expect(this.remotingClient.isConnected(url)).andReturn(true);
        EasyMock.expectLastCall();
        EasyMock.expect(this.producerZooKeeper.selectBroker(topic, partition)).andReturn(url);
        EasyMock.expect(
            this.remotingClient.invokeToGroup(url,
                new GetCommand(topic, this.consumerConfig.getGroup(), partition.getPartition(), offset, maxSize,
                    Integer.MIN_VALUE), 10000, TimeUnit.MILLISECONDS)).andReturn(
                        new DataCommand(data, Integer.MIN_VALUE));
        this.mocksControl.replay();
        OpaqueGenerator.resetOpaque();
        assertEquals(messageIterator, this.consumer.get(topic, partition, offset, maxSize));
View Full Code Here

    @Test
    public void testOffset() throws Exception {
        final String topic = "topic1";
        final int maxSize = 1024;
        final Partition partition = new Partition("0-0");
        final long offset = 12;
        final String url = "meta://localhost:8123";

        final Broker broker = new Broker(1, url);
        final long delay = 0;
        final TopicPartitionRegInfo topicPartitionRegInfo = new TopicPartitionRegInfo(topic, partition, offset);
        EasyMock.expect(
            this.remotingClient.invokeToGroup(url,
                new OffsetCommand(topic, this.consumerConfig.getGroup(), partition.getPartition(), offset,
                    Integer.MIN_VALUE), this.consumerConfig.getFetchTimeoutInMills(), TimeUnit.MILLISECONDS))
                    .andReturn(new BooleanCommand(HttpStatus.Success, String.valueOf(offset), Integer.MIN_VALUE));
        this.mocksControl.replay();
        OpaqueGenerator.resetOpaque();
        assertEquals(offset, this.consumer.offset(new FetchRequest(broker, delay, topicPartitionRegInfo, maxSize)));
View Full Code Here

    @Test
    public void testGetFailed() throws Exception {
        final String topic = "topic1";
        final int maxSize = 1024;
        final Partition partition = new Partition("0-0");
        final long offset = 12;
        final byte[] data = "hello".getBytes();
        final String url = "meta://localhost:0";
        final MessageIterator messageIterator = new MessageIterator(topic, data);

        this.producerZooKeeper.publishTopic(topic, this.consumer);
        EasyMock.expectLastCall();
        EasyMock.expect(this.remotingClient.isConnected(url)).andReturn(true);
        EasyMock.expect(this.producerZooKeeper.selectBroker(topic, partition)).andReturn(url);
        EasyMock.expect(
            this.remotingClient.invokeToGroup(url,
                new GetCommand(topic, this.consumerConfig.getGroup(), partition.getPartition(), offset, maxSize,
                    Integer.MIN_VALUE), 10000, TimeUnit.MILLISECONDS)).andReturn(
                        new BooleanCommand(500, "test error", Integer.MIN_VALUE));
        this.mocksControl.replay();
        try {
            OpaqueGenerator.resetOpaque();
View Full Code Here

    @Test
    public void testGetNotFound() throws Exception {
        final String topic = "topic1";
        final int maxSize = 1024;
        final Partition partition = new Partition("0-0");
        final long offset = 12;
        final String url = "meta://localhost:0";

        this.producerZooKeeper.publishTopic(topic, this.consumer);
        EasyMock.expectLastCall();
        EasyMock.expect(this.remotingClient.isConnected(url)).andReturn(true);
        EasyMock.expect(this.producerZooKeeper.selectBroker(topic, partition)).andReturn(url);
        EasyMock.expect(
            this.remotingClient.invokeToGroup(url,
                new GetCommand(topic, this.consumerConfig.getGroup(), partition.getPartition(), offset, maxSize,
                    Integer.MIN_VALUE), 10000, TimeUnit.MILLISECONDS)).andReturn(
                        new BooleanCommand(404, "not found", Integer.MIN_VALUE));
        this.mocksControl.replay();
        OpaqueGenerator.resetOpaque();
        assertNull(this.consumer.get(topic, partition, offset, maxSize));
View Full Code Here


    @Test
    public void testCommitLoad() throws Exception {
        final String group = "test-grp";
        final Partition partition = new Partition("0-1");
        Collection<TopicPartitionRegInfo> infoList = new ArrayList<TopicPartitionRegInfo>();
        for (int i = 0; i < 3; i++) {
            final String topic = "test" + (i + 1);
            infoList.add(new TopicPartitionRegInfo(topic, partition, i));
        }
View Full Code Here


    @Test
    public void testCommitCloseLoad() throws Exception {
        final String group = "test-grp";
        final Partition partition = new Partition("0-1");
        Collection<TopicPartitionRegInfo> infoList = new ArrayList<TopicPartitionRegInfo>();
        for (int i = 0; i < 3; i++) {
            final String topic = "test" + (i + 1);
            infoList.add(new TopicPartitionRegInfo(topic, partition, i));
        }
View Full Code Here


    @Test
    public void testCommitLoadEmpty() throws Exception {
        final String group = "test-grp";
        final Partition partition = new Partition("0-1");
        Collection<TopicPartitionRegInfo> infoList = new ArrayList<TopicPartitionRegInfo>();
        for (int i = 0; i < 3; i++) {
            final String topic = "test" + (i + 1);
            infoList.add(new TopicPartitionRegInfo(topic, partition, i));
        }
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.cluster.Partition

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.