Package com.taobao.metamorphosis.cluster

Examples of com.taobao.metamorphosis.cluster.Partition


    @Test
    public void testProcessRequestException() throws Exception {
        // this.mockConsumerReInitializeFetchManager();
        final String topic = "topic1";
        final int maxSize = 1024;
        final Partition partition = new Partition("0-0");
        final long offset = 12;
        final Broker broker = new Broker(0, "meta://localhost:0");
        final byte[] data =
                MessageUtils.makeMessageBuffer(1111,
                    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


    @Test
    public void testProcessRequestMessageRollbackOnly() throws Exception {
        // this.mockConsumerReInitializeFetchManager();
        final String topic = "topic1";
        final int maxSize = 1024;
        final Partition partition = new Partition("0-0");
        final long offset = 12;
        final Broker broker = new Broker(0, "meta://localhost:0");
        final byte[] data =
                MessageUtils.makeMessageBuffer(1111,
                    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

        // this.mockConsumerReInitializeFetchManager();
        // ��֤�������Դ���
        this.consumerConfig.setMaxIncreaseFetchDataRetries(0);
        final String topic = "topic1";
        final int maxSize = 1024;
        final Partition partition = new Partition("0-0");
        final long offset = 12;
        final Broker broker = new Broker(0, "meta://localhost:0");
        final FetchRequest request =
                new FetchRequest(broker, 0, new TopicPartitionRegInfo(topic, partition, offset), maxSize);
        // ��������������0��
View Full Code Here

            case HttpStatus.Success: {
                // messageId partition offset
                final String[] tmps = RESULT_SPLITER.split(resultStr);
                // �ɹ���������Ϣid����Ϣid�ɷ���������
                MessageAccessor.setId(message, Long.parseLong(tmps[0]));
                return new SendResult(true, new Partition(0, Integer.parseInt(tmps[1])), Long.parseLong(tmps[2]), null);
            }
            case HttpStatus.Forbidden: {
                // �����������ر���,��д����
                return new SendResult(false, null, -1, String.valueOf(HttpStatus.Forbidden));
            }
View Full Code Here

    @Before
    public void setUp() {
        this.selector = new OrderedMessagePartitionSelector() {
            @Override
            protected Partition choosePartition(String topic, List<Partition> partitions, Message message) {
                return new Partition("0-0");
            }
        };
        Map<String, List<Partition>> map = new HashMap<String, List<Partition>>();
        map.put(testTopic, Arrays.asList(new Partition("0-0"), new Partition("0-1"), new Partition("1-0")));
        this.selector.setConfigPartitions(map);

    }
View Full Code Here

    @Test
    public void testGetPartition_normal() throws MetaClientException {
        // �������

        Message message = this.createDefaultMessage();
        Partition partition =
                this.selector.getPartition(message.getTopic(),
                    Arrays.asList(new Partition("0-0"), new Partition("0-1"), new Partition("1-0")), message);
        Assert.assertEquals(new Partition("0-0"), partition);
    }
View Full Code Here

    public void testGetPartition_configPartitionsNull() throws MetaClientException {
        // ����������Ϊnull
        this.selector.setConfigPartitions(null);
        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(),
            Arrays.asList(new Partition("0-0"), new Partition("0-1"), new Partition("1-0")), message);
    }
View Full Code Here

        Map<String, List<Partition>> map = new HashMap<String, List<Partition>>();
        map.put(testTopic, new ArrayList<Partition>());
        this.selector.setConfigPartitions(map);
        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(),
            Arrays.asList(new Partition("0-0"), new Partition("0-1"), new Partition("1-0")), message);
    }
View Full Code Here

    @Test
    public void testGetPartition_availablePartitionsChanged_butSelectedPartitionAvailable() throws MetaClientException {
        // ���÷��������˱仯������û��(0-1 -> 1-0),ѡ������ķ�����0-0����������������������������д��
        Message message = this.createDefaultMessage();
        Partition partition =
                this.selector.getPartition(message.getTopic(),
                    Arrays.asList(new Partition("0-0"), new Partition("1-0"), new Partition("2-0")), message);
        Assert.assertEquals(new Partition("0-0"), partition);
    }
View Full Code Here

    @Test(expected = AvailablePartitionNumException.class)
    public void testGetPartition_availablePartitionsChanged_andSelectedPartitionInvalid() throws MetaClientException {
        // ���÷�����������,����ѡ�����ķ�����0-0�����������ڿ��÷�����������û���д�˲����ڵ�һ��������
        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(),
            Arrays.asList(new Partition("1-0"), new Partition("2-0"), new Partition("3-0")), message);
    }
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.