Package com.taobao.metamorphosis.cluster.json

Examples of com.taobao.metamorphosis.cluster.json.TopicBroker


                final String[] brokerStrs = StringUtils.split(broker, "-");
                if (this.isMaster(brokerStrs)) {
                    String path = this.brokerTopicsPubPath + "/" + topic + "/" + broker;
                    String brokerData = ZkUtils.readData(this.zkClient, path);
                    try {
                        final TopicBroker topicBroker = TopicBroker.parse(brokerData);
                        if (topicBroker == null) {
                            logger.warn("Null broker data for path:" + path);
                            continue;
                        }
                        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)) {
View Full Code Here


                        ZkUtils.readDataMaybeNull(this.zkClient, this.brokerTopicsPathOf(topic, false, brokerId, -1));
                if (StringUtils.isBlank(dataString)) {
                    continue;
                }
                try {
                    final TopicBroker topicBroker = TopicBroker.parse(dataString);
                    if (topicBroker == null) {
                        continue;
                    }
                    for (int part = 0; part < topicBroker.getNumParts(); part++) {
                        if (partList == null) {
                            partList = new ArrayList<Partition>();
                        }
                        partList.add(new Partition(brokerId, part));
                    }
View Full Code Here

                final String[] tmp = StringUtils.split(broker, "-");
                if (tmp != null && tmp.length == 2) {
                    String path = this.brokerTopicsSubPath + "/" + topic + "/" + broker;
                    String brokerData = ZkUtils.readData(this.zkClient, path);
                    try {
                        final TopicBroker topicBroker = TopicBroker.parse(brokerData);
                        if (topicBroker == null) {
                            logger.warn("Null broker data for path:" + path);
                            continue;
                        }
                        for (int part = 0; part < topicBroker.getNumParts(); part++) {
                            if (partList == null) {
                                partList = new ArrayList<String>();
                            }

                            final String partitionString = tmp[0] + "-" + part;
View Full Code Here

        // ���輯Ⱥ������̨master,topic1��master����3������;
        // topic2��master����1������,����һ������ص�master����1������
        ZkUtils.createEphemeralPath(this.client, this.metaZookeeper.brokerIdsPath + "/0/master", "meta://localhost:0");
        ZkUtils.createEphemeralPath(this.client, this.metaZookeeper.brokerIdsPath + "/1/master", "meta://localhost:1");
        this.client.createEphemeral(this.metaZookeeper.brokerTopicsSubPath + "/topic1/0-m",
            new TopicBroker(3, "0-m").toJson());
        this.client.createEphemeral(this.metaZookeeper.brokerTopicsSubPath + "/topic2/0-m",
            new TopicBroker(1, "0-m").toJson());
        this.client.createEphemeral(this.metaZookeeper.brokerTopicsSubPath + "/topic2/1-m",
            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"));
View Full Code Here

            "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());
        this.client.createEphemeral(this.metaZookeeper.brokerTopicsSubPath + "/topic2/0-m",
            new TopicBroker(1, "0-m").toJson());
        Thread.sleep(5000);
        this.mocksControl.verify();

        // �ָ���testReigsterSlaveConsumerʱ��״̬
        final SlaveZKLoadRebalanceListener listener = this.checkTopic();
View Full Code Here

        ZkUtils.createEphemeralPath(this.getZkClient(), this.metaZookeeper.brokerIdsPathOf(this.brokerId, -1),
            "meta://1.1.1.1:222");
        ZkUtils.createEphemeralPath(this.getZkClient(),
            this.metaZookeeper.brokerTopicsPathOf("topictest", false, this.brokerId, -1),
            new TopicBroker(2, null).toJson());
        Assert.assertTrue(this.subscribeHandler.getSlaveZooKeeper().getPartitionsForTopicsFromMaster().size() > 0);
        this.subscribeHandler.start();
        Assert.assertFalse(this.subscribeHandler.isStarted());
    }
View Full Code Here

        final TopicConfig topicConfig = this.config.getTopicConfig(topic);
        Integer numParts = topicConfig != null ? topicConfig.getNumPartitions() : this.config.getNumPartitions();
        numParts = numParts == null ? this.config.getNumPartitions() : numParts;
        log.info("Begin registering broker topic " + brokerTopicPath + " with " + numParts + " partitions");

        final TopicBroker topicBroker = new TopicBroker(numParts, brokerId + (slaveId >= 0 ? "-s" + slaveId : "-m"));
        log.info("Register broker for topic:" + topicBroker);
        // Be compatible with the version before 1.4.3
        ZkUtils.createEphemeralPath(this.zkClient, brokerTopicPath, String.valueOf(numParts));

        // added by dennis,since 1.4.3
        String topicBrokerJson = topicBroker.toJson();
        if (topicConfig.isAcceptPublish()) {
            ZkUtils.createEphemeralPath(this.zkClient, topicPubPath, topicBrokerJson);
        }
        else {
            ZkUtils.deletePath(this.zkClient, topicPubPath);
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.cluster.json.TopicBroker

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.