Package com.taobao.metamorphosis.cluster

Examples of com.taobao.metamorphosis.cluster.Partition


                        }
                        for (int part = 0; part < topicBroker.getNumParts(); part++) {
                            if (partList == null) {
                                partList = new ArrayList<Partition>();
                            }
                            final Partition partition = new Partition(Integer.parseInt(brokerStrs[0]), part);
                            if (!partList.contains(partition)) {
                                partList.add(partition);
                            }
                        }
                    }
View Full Code Here


                    }
                    for (int part = 0; part < topicBroker.getNumParts(); part++) {
                        if (partList == null) {
                            partList = new ArrayList<Partition>();
                        }
                        partList.add(new Partition(brokerId, part));
                    }
                    if (partList != null) {
                        Collections.sort(partList);
                        ret.put(topic, partList);
                    }
View Full Code Here

            final int num = Integer.parseInt(brokerNum.substring(index + 1));
            if (num <= 0) {
                throw new NumberFormatException("���������������0,config string=" + value);
            }
            for (int i = 0; i < num; i++) {
                ret.add(new Partition(brokerId, i));
            }
        }
        Collections.sort(ret);
        return ret;
    }
View Full Code Here

    public void setUp() {
        this.control = EasyMock.createControl();
        this.consumer = this.control.createMock(MessageConsumer.class);
        this.partitions = new ArrayList<Partition>();
        for (int i = 0; i < 3; i++) {
            this.partitions.add(new Partition("0-" + i));
        }
        this.browser =
                new MetaTopicBrowser(this.topic, this.maxSize, this.timeoutInMills, this.consumer, this.partitions);
    }
View Full Code Here

    @Test
    public void testIteratorInSamePartition() throws Exception {
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-0"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-0"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        this.control.replay();
        Iterator<Message> it = this.browser.iterator();
        if (it.hasNext()) {
            this.assertMsg(it.next());
        }
        if (it.hasNext()) {
            this.assertMsg(it.next());
        }
        this.control.verify();
        MetaTopicBrowser.Itr mit = (MetaTopicBrowser.Itr) it;
        assertEquals(2, mit.partitions.size());
        assertFalse(mit.partitions.contains(new Partition("0-0")));
    }
View Full Code Here

    @Test
    public void testIteratorMoveOnPartition() throws Exception {
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-0"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock.expect(
            this.consumer.get(this.topic, new Partition("0-0"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(null);
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-1"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        this.control.replay();
        Iterator<Message> it = this.browser.iterator();
        if (it.hasNext()) {
            this.assertMsg(it.next());
        }
        if (it.hasNext()) {
            this.assertMsg(it.next());
        }
        this.control.verify();
        MetaTopicBrowser.Itr mit = (MetaTopicBrowser.Itr) it;
        assertEquals(1, mit.partitions.size());
        assertFalse(mit.partitions.contains(new Partition("0-0")));
        assertFalse(mit.partitions.contains(new Partition("0-1")));
    }
View Full Code Here

    @Test
    public void testIteratorToEnd() throws Exception {
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-0"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock.expect(
            this.consumer.get(this.topic, new Partition("0-0"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(null);
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-1"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-1"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(null).once();
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-2"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-2"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(null).once();
        this.control.replay();
        Iterator<Message> it = this.browser.iterator();
        if (it.hasNext()) {
            this.assertMsg(it.next());
View Full Code Here

            new TopicBroker(1, "1-m").toJson());

        this.mockConnect("meta://localhost:0");
        // this.mockConnect("meta://localhost:1");�����ӵ�����һ��master
        this.mockCommitOffsets(GROUP, new ArrayList<TopicPartitionRegInfo>());
        this.mockLoadNullInitOffset("topic1", GROUP, new Partition("0-0"));
        this.mockLoadNullInitOffset("topic1", GROUP, new Partition("0-1"));
        this.mockLoadNullInitOffset("topic1", GROUP, new Partition("0-2"));
        this.mockLoadNullInitOffset("topic2", GROUP, new Partition("0-0"));
        // this.mockLoadNullInitOffset("topic2", GROUP, new
        // Partition("1-0"));��load����һ��master�ķ���
        this.mockFetchManagerRestart();
        this.mockAddFetchRequest(new FetchRequest(new Broker(0, "meta://localhost:0"), 0, new TopicPartitionRegInfo(
            "topic1", new Partition("0-0"), 0), 1024 * 1024));
        this.mockAddFetchRequest(new FetchRequest(new Broker(0, "meta://localhost:0"), 0, new TopicPartitionRegInfo(
            "topic1", new Partition("0-1"), 0), 1024 * 1024));
        this.mockAddFetchRequest(new FetchRequest(new Broker(0, "meta://localhost:0"), 0, new TopicPartitionRegInfo(
            "topic1", new Partition("0-2"), 0), 1024 * 1024));
        this.mockAddFetchRequest(new FetchRequest(new Broker(0, "meta://localhost:0"), 0, new TopicPartitionRegInfo(
            "topic2", new Partition("0-0"), 0), 1024 * 1024));
        // this.mockAddFetchRequest(new FetchRequest(new Broker(1,
        // "meta://localhost:1"), 0, new TopicPartitionRegInfo(
        // "topic2", new Partition("1-0"), 0), 1024 * 1024));��������һ��masterץȡ��Ϣ

        this.mocksControl.replay();
View Full Code Here

    public void testReigsterSlaveConsumer_thenMasterDown_thenMasterStart() throws Exception {
        this.testReigsterSlaveConsumer_thenMasterDown();
        this.mocksControl.reset();
        this.mockConnect("meta://localhost:0");
        this.mockCommitOffsets(GROUP, new ArrayList<TopicPartitionRegInfo>());
        this.mockLoadNullInitOffset("topic1", GROUP, new Partition("0-0"));
        this.mockLoadNullInitOffset("topic1", GROUP, new Partition("0-1"));
        this.mockLoadNullInitOffset("topic1", GROUP, new Partition("0-2"));
        this.mockLoadNullInitOffset("topic2", GROUP, new Partition("0-0"));
        this.mockFetchManagerRestart();
        this.mockAddFetchRequest(new FetchRequest(new Broker(0, "meta://localhost:0"), 0, new TopicPartitionRegInfo(
            "topic1", new Partition("0-0"), 0), 1024 * 1024));
        this.mockAddFetchRequest(new FetchRequest(new Broker(0, "meta://localhost:0"), 0, new TopicPartitionRegInfo(
            "topic1", new Partition("0-1"), 0), 1024 * 1024));
        this.mockAddFetchRequest(new FetchRequest(new Broker(0, "meta://localhost:0"), 0, new TopicPartitionRegInfo(
            "topic1", new Partition("0-2"), 0), 1024 * 1024));
        this.mockAddFetchRequest(new FetchRequest(new Broker(0, "meta://localhost:0"), 0, new TopicPartitionRegInfo(
            "topic2", new Partition("0-0"), 0), 1024 * 1024));
        this.mocksControl.replay();

        ZkUtils.createEphemeralPath(this.client, this.metaZookeeper.brokerIdsPath + "/0/master", "meta://localhost:0");
        this.client.createEphemeral(this.metaZookeeper.brokerTopicsSubPath + "/topic1/0-m",
            new TopicBroker(3, "0-m").toJson());
View Full Code Here

    private void checkTopic1(
            final ConcurrentHashMap<String, ConcurrentHashMap<Partition, TopicPartitionRegInfo>> topicRegistry) {
        final ConcurrentHashMap<Partition, TopicPartitionRegInfo> partMap1 = topicRegistry.get("topic1");
        assertNotNull(partMap1);
        assertEquals(3, partMap1.size());
        assertTrue(partMap1.containsKey(new Partition("0-0")));
        assertTrue(partMap1.containsKey(new Partition("0-1")));
        assertTrue(partMap1.containsKey(new Partition("0-2")));
    }
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.