Package com.taobao.metamorphosis.cluster

Examples of com.taobao.metamorphosis.cluster.Partition


    @Test(expected = AvailablePartitionNumException.class)
    public void testGetPartition_configPartitionsChanged() throws MetaClientException {
        // �������÷����˱仯,���÷�������,ѡ������ķ�����0-0������д
        Map<String, List<Partition>> map = new HashMap<String, List<Partition>>();
        map.put(testTopic, Arrays.asList(new Partition("1-0"), new Partition("1-1"), new Partition("2-0")));
        this.selector.setConfigPartitions(map);

        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
    public void testGetPartition_availablePartitionsChanged_butSelectedPartitionAvailable2() throws MetaClientException {
        // ���÷���������(1-0),�������õķ���ѡ��,ѡ�����ķ���(0-0)�����ڿ��÷�����,��������������������������д��

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

    public void testGetPartition_availablePartitionsChanged_butSelectedPartitionAvailable_expception()
            throws MetaClientException {
        // ���÷��������ˣ�0-0��,�������õķ���ѡ��,ѡ�����ķ�����0-0���������ڿ��÷�����

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

        EasyMock.expect(this.broker.getStoreManager()).andReturn(this.storeManager);
        EasyMock.expect(this.storeManager.getMessageStore(topic, partition)).andReturn(this.store);
        EasyMock.expect(this.store.getSizeInBytes()).andReturn(555L).anyTimes();
        EasyMock.expect(this.store.getMinOffset()).andReturn(100L).once();
        this.mocksControl.replay();
        final TopicPartitionRegInfo info = this.slaveOffsetStorage.load(topic, "ss", new Partition(0, partition));
        this.mocksControl.verify();

        Assert.assertEquals(100L + 555L, info.getOffset().get());
        Assert.assertEquals(partition, info.getPartition().getPartition());
        Assert.assertEquals(topic, info.getTopic());
View Full Code Here

    }


    @Test
    public void testSelectRoundRobin() throws Exception {
        final Partition p1 = new Partition("0-1");
        final Partition p2 = new Partition("0-2");
        final Partition p3 = new Partition("0-3");

        final List<Partition> list = new ArrayList<Partition>();
        list.add(p1);
        list.add(p2);
        list.add(p3);
View Full Code Here

        OpaqueGenerator.resetOpaque();
        final MetaConfig config = new MetaConfig();
        config.setSlaveConfig(new SlaveConfig(0, GROUP, 500, true));
        EasyMock.expect(this.broker.getMetaConfig()).andReturn(config);
        this.mocksControl.replay();
        final TopicPartitionRegInfo info = this.slaveOffsetStorage.load(topic, "ss", new Partition(0, partition));
        this.mocksControl.verify();

        Assert.assertEquals(555L, info.getOffset().get());
        Assert.assertEquals(partition, info.getPartition().getPartition());
        Assert.assertEquals(topic, info.getTopic());
View Full Code Here

        // EasyMock.expect(this.broker.getCommandProcessor()).andReturn(this.brokerCommandProcessor).anyTimes();
        EasyMock.expect(this.broker.getStoreManager()).andReturn(this.storeManager);
        EasyMock.expect(this.storeManager.getMessageStore(topic, partition)).andReturn(null);
        EasyMock.expect(this.slaveZooKeeper.getMasterServerUrl()).andReturn(null);
        this.mocksControl.replay();
        this.slaveOffsetStorage.load(topic, "ss", new Partition(0, partition));
        this.mocksControl.verify();
    }
View Full Code Here

        OpaqueGenerator.resetOpaque();
        final MetaConfig config = new MetaConfig();
        config.setSlaveConfig(new SlaveConfig(0, GROUP, 500, true));
        EasyMock.expect(this.broker.getMetaConfig()).andReturn(config);
        this.mocksControl.replay();
        final TopicPartitionRegInfo info = this.slaveOffsetStorage.load(topic, "ss", new Partition(0, partition));
        this.mocksControl.verify();
        Assert.assertEquals(0L, info.getOffset().get());
        Assert.assertEquals(partition, info.getPartition().getPartition());
        Assert.assertEquals(topic, info.getTopic());
    }
View Full Code Here

        EasyMock.expect(this.slaveZooKeeper.getMasterServerUrl()).andReturn(masterUrl);
        EasyMock.expect(this.remotingClient.isConnected(masterUrl)).andReturn(true);
        EasyMock.expect(this.remotingClient.invokeToGroup(masterUrl, new OffsetCommand(topic, GROUP, partition, 0, 0)))
        .andThrow(new Exception("unknown error when invoke"));
        this.mocksControl.replay();
        this.slaveOffsetStorage.load(topic, "ss", new Partition(0, partition));
        this.mocksControl.verify();
    }
View Full Code Here

        final MessageConsumer consumer = sessionFactory.createConsumer(new ConsumerConfig(group));
        // start offset
        long offset = 0;
        MessageIterator it = null;
        // fetch messages
        while ((it = consumer.get(topic, new Partition("100-0"), offset, 1024 * 1024)) != null) {
            while (it.hasNext()) {
                final Message msg = it.next();
                System.out.println("Receive message " + new String(msg.getData()));
            }
            // move offset forward
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.