Package com.taobao.metamorphosis.cluster

Examples of com.taobao.metamorphosis.cluster.Partition


        if (this.messageRecoverer != null) {
            for (String name : names) {
                String[] tmps = name.split(SPLIT);
                String topic = tmps[0];
                Partition partition = new Partition(tmps[1]);
                if (!partition.equals(Partition.RandomPartiton) && this.getMessageCount(topic, partition) > 0) {
                    // RandomPartiton��������recover
                    this.recover(topic, partition, this.messageRecoverer);
                }
            }
        }
View Full Code Here



    private SelectPartitionResult trySelectPartition(Message message) throws MetaClientException {
        SelectPartitionResult result = new SelectPartitionResult();
        try {
            Partition partition = this.producer.selectPartition(message);
            if (partition == null) {
                throw new MetaClientException("selected null partition");
            }
            result.setSelectedPartition(partition);
            result.setPartitionWritable(true);
        }
        catch (AvailablePartitionNumException e) {
            String msg = e.getMessage();
            String partitionStr = msg.substring(msg.indexOf("[") + 1, msg.indexOf("]"));
            result.setSelectedPartition(new Partition(partitionStr));
            result.setPartitionWritable(false);
        }
        catch (MetaClientException e) {
            throw e;
        }
View Full Code Here

                final MessageListener listener, final ConsumerMessageFilter filter, final String group) {
            if (it != null && it.hasNext()) {
                if (this.processWhenRetryTooMany(request, it)) {
                    return;
                }
                final Partition partition = request.getPartitionObject();
                if (this.processReceiveMessage(request, it, listener, filter, partition, group)) {
                    return;
                }
                this.postReceiveMessage(request, it, partition);
            }
View Full Code Here

        this.copyOffsetInZk = new CopyOffsetInZk(System.out);
        this.query = this.copyOffsetInZk.getQuery();
        this.zkClient = this.query.getZkClient();
        for (int i = 1; i <= 2; i++) {
            ZkUtils.updatePersistentPath(this.zkClient,
                this.query.getOffsetPath(this.groupPrefix + i, this.topic, new Partition(1, 4)), "44" + i);
            ZkUtils.updatePersistentPath(this.zkClient,
                this.query.getOffsetPath(this.groupPrefix + i, this.topic, new Partition(1, 5)), "55" + i);
            ZkUtils.updatePersistentPath(this.zkClient,
                this.query.getOffsetPath(this.groupPrefix + i, this.topic, new Partition(1, 6)), "66" + i);
            ZkUtils.updatePersistentPath(this.zkClient,
                this.query.getOffsetPath(this.groupPrefix + i, this.topic, new Partition(1, 7)), "77" + i);
        }

    }
View Full Code Here

        this.copyOffsetInZk.doMain(("-topic " + this.topic + " -src 1 -target 2 -start 6 -end 7 ").split(" "));

        long offset =
                Long.parseLong(ZkUtils.readData(this.zkClient,
                    this.query.getOffsetPath(this.groupPrefix + 1, this.topic, new Partition(2, 0))));
        Assert.assertEquals(661, offset);
        offset =
                Long.parseLong(ZkUtils.readData(this.zkClient,
                    this.query.getOffsetPath(this.groupPrefix + 1, this.topic, new Partition(2, 1))));
        Assert.assertEquals(771, offset);

        offset =
                Long.parseLong(ZkUtils.readData(this.zkClient,
                    this.query.getOffsetPath(this.groupPrefix + 2, this.topic, new Partition(2, 0))));
        Assert.assertEquals(662, offset);

        offset =
                Long.parseLong(ZkUtils.readData(this.zkClient,
                    this.query.getOffsetPath(this.groupPrefix + 2, this.topic, new Partition(2, 1))));
        Assert.assertEquals(772, offset);

    }
View Full Code Here

            .split(" "));

        long offset;
        offset =
                Long.parseLong(ZkUtils.readData(this.zkClient,
                    this.query.getOffsetPath(this.groupPrefix + 1, this.topic, new Partition(2, 2))));
        Assert.assertEquals(661, offset);
        offset =
                Long.parseLong(ZkUtils.readData(this.zkClient,
                    this.query.getOffsetPath(this.groupPrefix + 1, this.topic, new Partition(2, 3))));
        Assert.assertEquals(771, offset);

        offset =
                Long.parseLong(ZkUtils.readData(this.zkClient,
                    this.query.getOffsetPath(this.groupPrefix + 2, this.topic, new Partition(2, 2))));
        Assert.assertEquals(662, offset);

        offset =
                Long.parseLong(ZkUtils.readData(this.zkClient,
                    this.query.getOffsetPath(this.groupPrefix + 2, this.topic, new Partition(2, 3))));
        Assert.assertEquals(772, offset);
    }
View Full Code Here

                if (infos != null) {
                    for (final Map<String, Object> infoMap : infos) {
                        final String topic = (String) infoMap.get("topic");
                        final long offset = Long.valueOf(String.valueOf(infoMap.get("offset")));
                        final Map<String, Integer> partMap = (Map<String, Integer>) infoMap.get("partition");
                        infoList.add(new TopicPartitionRegInfo(topic, new Partition(partMap.get("brokerId"), partMap
                            .get("partition")), offset));
                    }
                }
                this.groupInfoMap.put(group, infoList);
            }
View Full Code Here

                        loadBalanceListener.topicRegistry.get(topic);
                if (topicPartRegInfoMap == null) {
                    topicPartRegInfoMap = new ConcurrentHashMap<Partition, TopicPartitionRegInfo>();
                    loadBalanceListener.topicRegistry.put(topic, topicPartRegInfoMap);
                }
                final Partition partition = new Partition(loadBalanceListener.consumerConfig.getPartition());
                long offset = loadBalanceListener.consumerConfig.getOffset();
                if (loadBalanceListener.consumerConfig.isAlwaysConsumeFromMaxOffset()) {
                    offset = Long.MAX_VALUE;
                }
                final TopicPartitionRegInfo regInfo = new TopicPartitionRegInfo(topic, partition, offset);
View Full Code Here

            final Set<Broker> newBrokers = new HashSet<Broker>();
            for (final Map.Entry<String/* topic */, ConcurrentHashMap<Partition, TopicPartitionRegInfo>> entry : this.topicRegistry
                    .entrySet()) {
                final String topic = entry.getKey();
                for (final Map.Entry<Partition, TopicPartitionRegInfo> partEntry : entry.getValue().entrySet()) {
                    final Partition partition = partEntry.getKey();
                    final TopicPartitionRegInfo info = partEntry.getValue();
                    // ���ȡmaster��slave��һ����,wuhua
                    final Broker broker = cluster.getBrokerRandom(partition.getBrokerId());
                    if (broker != null) {
                        newBrokers.add(broker);
                        final SubscriberInfo subscriberInfo = this.topicSubcriberRegistry.get(topic);
                        // ���fetch����
                        this.fetchManager.addFetchRequest(new FetchRequest(broker, 0L, info, subscriberInfo
                            .getMaxSize()));
                    }
                    else {
                        log.error("Could not find broker for broker id " + partition.getBrokerId()
                            + ", it should not happen.");
                    }
                }
            }

View Full Code Here

                    }
                }

                for (final String partition : newParts) {
                    // ��ǰû�еķ�����������ȥ��Ҳ�����µ��У��ϵ�û��
                    if (!currentParts.contains(new Partition(partition))) {
                        log.warn(consumerId + " attempting to claim partition " + partition);
                        // ע�����owner��ϵ
                        if (!this.ownPartition(topicDirs, partition, topic, consumerId)) {
                            log.warn("Claim partition " + partition + " failed,retry...");
                            return false;
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.