Package com.taobao.metamorphosis.server.utils

Examples of com.taobao.metamorphosis.server.utils.TopicConfig


     */
    public void registerTopicInZk(final String topic, boolean force) throws Exception {
        if (force) {
            // This block is not synchronized,because we don't force to register
            // topics frequently except reloading config file.
            TopicConfig oldConfig = this.cloneTopicConfigs.get(topic);
            TopicConfig newConfig = this.config.getTopicConfig(topic);
            if (this.compareTopicConfigs(newConfig, oldConfig)) {
                return;
            }
            else {
                this.unregisterTopic(topic);
View Full Code Here


        int brokerId = this.config.getBrokerId();
        int slaveId = this.config.getSlaveId();
        final String brokerTopicPath = this.metaZookeeper.brokerTopicsPathOf(topic, brokerId, slaveId);
        final String topicPubPath = this.metaZookeeper.brokerTopicsPathOf(topic, true, brokerId, slaveId);
        final String topicSubPath = this.metaZookeeper.brokerTopicsPathOf(topic, false, brokerId, slaveId);
        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);
        }

        if (topicConfig.isAcceptSubscribe()) {
            ZkUtils.createEphemeralPath(this.zkClient, topicSubPath, topicBrokerJson);
        }
        else {
            ZkUtils.deletePath(this.zkClient, topicSubPath);
        }
        this.cloneTopicConfigs.put(topic, topicConfig.clone());

        log.info("End registering broker topic " + brokerTopicPath);
    }
View Full Code Here

        private final Map<String, DeletePolicy> deletePolicyMap = new HashMap<String, DeletePolicy>();


        DeletePolicySelector(final MetaConfig metaConfig) {
            for (final String topic : metaConfig.getTopics()) {
                final TopicConfig topicConfig = metaConfig.getTopicConfig(topic);
                final String deletePolicy =
                        topicConfig != null ? topicConfig.getDeletePolicy() : metaConfig.getDeletePolicy();
                        this.deletePolicyMap.put(topic, DeletePolicyFactory.getDeletePolicy(deletePolicy));
            }
        }
View Full Code Here

                        sum += msgStore.getMessageCount();
                        bytes += msgStore.getSizeInBytes();
                    }
                }
            }
            TopicConfig topicConfig = this.metaConfig.getTopicConfig(topic);
            TopicStats stats =
                    new TopicStats(topic, partitionCount, topicConfig, sum, bytes,
                        this.realTimeStat.getGroupedRealTimeStatResult(StatConstants.CMD_PUT, topic),
                        this.realTimeStat.getGroupedRealTimeStatResult(StatConstants.CMD_GET, topic),
                        this.realTimeStat.getGroupedRealTimeStatResult(StatConstants.GET_MISS, topic),
View Full Code Here

                        sum += msgStore.getMessageCount();
                        bytes += msgStore.getSizeInBytes();
                    }
                }
            }
            TopicConfig topicConfig = this.metaConfig.getTopicConfig(topic);
            TopicStats stats =
                    new TopicStats(topic, partitionCount, topicConfig, sum, bytes,
                        this.realTimeStat.getGroupedRealTimeStatResult(StatConstants.CMD_PUT, topic),
                        this.realTimeStat.getGroupedRealTimeStatResult(StatConstants.CMD_GET, topic),
                        this.realTimeStat.getGroupedRealTimeStatResult(StatConstants.GET_MISS, topic),
View Full Code Here

    public void setUp() {
        this.metaConfig = new MetaConfig();
        final List<String> topics = new ArrayList<String>();
        topics.add("topic1");
        topics.add("topic2");
        final TopicConfig topicConfig = new TopicConfig("topic2", this.metaConfig);
        topicConfig.setNumPartitions(5);
        this.metaConfig.getTopicConfigMap().put("topic2", topicConfig);
        this.metaConfig.setTopics(topics);
        this.metaConfig.setBrokerId(77);
        this.metaConfig.setHostName("localhost");
        this.metaConfig.setServerPort(8199);
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.server.utils.TopicConfig

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.