Package com.taobao.metamorphosis.cluster

Examples of com.taobao.metamorphosis.cluster.Partition


    @Test
    public void testCommitNotExists_NoError() {
        final String topic = "test";
        final String group = "test-grp";
        final Partition partition = new Partition("0-1");
        final TopicPartitionRegInfo info = new TopicPartitionRegInfo(topic, partition, 1999);
        final Collection<TopicPartitionRegInfo> infoList = new ArrayList<TopicPartitionRegInfo>();
        infoList.add(info);
        assertNull(this.offsetStorage.load(topic, group, partition));
        this.offsetStorage.commitOffset(group, infoList);
View Full Code Here


    public void testSendOrderedMessage() 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");
        EasyMock.expect(this.producerZooKeeper.selectPartition(topic, message, this.partitionSelector))
        .andReturn(partition).times(2);
        EasyMock.expect(this.producerZooKeeper.selectBroker(topic, partition)).andReturn(url);
        EasyMock.expect(this.localMessageStorageManager.getMessageCount(topic, partition)).andReturn(0);
        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(200, "1111 1 1024", Integer.MIN_VALUE));
        this.mocksControl.replay();
        assertEquals(0, message.getId());
        final SendResult sendResult = this.producer.sendMessage(message);
View Full Code Here

    public void testSendMessage_swichToNomal() throws Exception {
        final Message message = this.createDefaultMessage();
        // �����Ѿ�����,���ػ������Ϣ����Ϊ0���л�Ϊ��������ģʽ�����ѱ�����Ϣд�������

        EasyMock.expect(this.producer.getLocalMessageCount(message.getTopic(), this.partition)).andReturn(0);
        EasyMock.expect(this.producer.selectPartition(message)).andReturn(new Partition("0-0"));
        EasyMock.expect(this.producer.sendMessageToServer(message, 10000, TimeUnit.MILLISECONDS, true)).andReturn(null);

        this.mocksControl.replay();
        this.sender.sendMessage(message, 10000, TimeUnit.MILLISECONDS);
        this.mocksControl.verify();
View Full Code Here

    public void testSendMessage_PartitionNumRight_butHaveFewLocalMessage() throws Exception {
        // �����Ѿ�����,���ػ�������������Ϣ��ͣ��һ���ټ��,����n�κ󻹽�������·���Ļ�,������Ϣд����

        final Message message = this.createDefaultMessage();
        EasyMock.expect(this.producer.getLocalMessageCount(message.getTopic(), this.partition)).andReturn(10).times(3);
        EasyMock.expect(this.producer.selectPartition(message)).andReturn(new Partition("0-0")).times(3);
        EasyMock.expect(this.producer.saveMessageToLocal(message, this.partition, 10000, TimeUnit.MILLISECONDS))
            .andReturn(null);
        this.producer.tryRecoverMessage(message.getTopic(), this.partition);
        EasyMock.expectLastCall().times(3);
        this.mocksControl.replay();
View Full Code Here

        // �����Ѿ�����,���ػ�������������Ϣ��ͣ��һ���ټ��,�ڶ��μ�⵽������Ϣ�ָ����,������Ϣд������,�л�����������ģʽ

        final Message message = this.createDefaultMessage();
        EasyMock.expect(this.producer.getLocalMessageCount(message.getTopic(), this.partition)).andReturn(10);
        EasyMock.expect(this.producer.getLocalMessageCount(message.getTopic(), this.partition)).andReturn(0);
        EasyMock.expect(this.producer.selectPartition(message)).andReturn(new Partition("0-0")).times(2);
        EasyMock.expect(this.producer.sendMessageToServer(message, 10000, TimeUnit.MILLISECONDS, true)).andReturn(null);
        this.producer.tryRecoverMessage(message.getTopic(), this.partition);
        EasyMock.expectLastCall().times(1);
        this.mocksControl.replay();
        this.sender.sendMessage(message, 10000, TimeUnit.MILLISECONDS);
View Full Code Here


    @Test
    public void testHandle() throws Exception {
        String topic = "test-topic";
        Partition partition = new Partition(0, 0);
        Message message = new Message(topic, "test".getBytes());
        MessageAccessor.setPartition(message, partition);
        processor.setStorageManager(messageRecoverManager);
        EasyMock.expect(messageRecoverManager.getMessageCount(topic, partition)).andReturn(499999);
        messageRecoverManager.append(message, partition);
View Full Code Here

        if (configPartitionsNum == 0) {
            throw new MetaClientException("There is no config partitions for topic " + topic
                    + ",maybe you don't config it at first?");
        }

        Partition selectedPartition = this.choosePartition(topic, configPartitions, message);
        if (selectedPartition == null) {
            throw new MetaClientException("selected null partition");
        }

        // ���÷�����Ϊ0,����˳����Ϣ��Ϊ����ʱû�п��÷���(����ֻ��һ̨������,������������),����Ϊ��û����topic,
View Full Code Here

                if (tmps.length != 2) {
                    continue;
                }

                log.info("����local message storage " + name + " ...");
                this.getOrCreateStore(tmps[0], new Partition(tmps[1]));
            }
        }
    }
View Full Code Here

        if (this.messageRecoverer != null) {
            for (final String name : names) {
                final String[] tmps = name.split(SPLIT);
                final String topic = tmps[0];
                final Partition partition = new Partition(tmps[1]);
                final int count = this.getMessageCount(topic, partition);
                log.info(name + "��Ҫ�ָ�������:" + count);
                if (count > 0) {
                    if (!this.recover(topic, partition, this.messageRecoverer)) {
                        log.info("SendRecover���ͻָ�������������,����Ҫ��������,name=" + name);
View Full Code Here

    /**
     * ��Ϣ���뱾�ش��̲����ڻָ�
     */
    @Override
    public boolean handle(Message message) throws Exception {
        Partition partition = message.getPartition();
        partition = (partition != null ? partition : Partition.RandomPartiton);
        int count = this.storageManager.getMessageCount(message.getTopic(), partition);
        if (count < this.messageCountLimit) {
            this.storageManager.append(message, partition);
            return true;
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.