Package com.taobao.metamorphosis.server.utils

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


    @Before
    public void setUp() throws Exception {
        this.metaConfig = new MetaConfig();
        final String topic = "MessageStoreManagerUnitTest";
        this.metaConfig.getTopics().add(topic);
        final TopicConfig topicConfig = new TopicConfig(topic, this.metaConfig);
        topicConfig.setDeletePolicy("delete,10s");
        topicConfig.setDeleteWhen("0/1 * * * * ?");
        this.metaConfig.getTopicConfigMap().put(topic, topicConfig);
        FileUtils.deleteDirectory(new File(this.metaConfig.getDataPath()));
        this.messageStoreManager = new MessageStoreManager(this.metaConfig, null);
    }
View Full Code Here


    @Test
    public void testGetNumPartitions() {
        assertEquals(1, this.messageStoreManager.getNumPartitions("MessageStoreManagerUnitTest"));
        assertEquals(1, this.messageStoreManager.getNumPartitions("MessageStoreManagerUnitTest"));

        final TopicConfig topicConfig = new TopicConfig("MessageStoreManagerUnitTest", this.metaConfig);
        topicConfig.setNumPartitions(9999);
        this.metaConfig.getTopicConfigMap().put("MessageStoreManagerUnitTest", topicConfig);
        assertEquals(9999, this.messageStoreManager.getNumPartitions("MessageStoreManagerUnitTest"));
        assertEquals(9999, this.messageStoreManager.getNumPartitions("MessageStoreManagerUnitTest"));
    }
View Full Code Here


    private void testInit0(boolean inParallel) throws IOException, InterruptedException {
        final String topic = "MessageStoreManagerUnitTest";
        IdWorker idWorker = new IdWorker(0);
        final TopicConfig topicConfig = new TopicConfig(topic, this.metaConfig);
        topicConfig.setNumPartitions(10);
        this.metaConfig.getTopicConfigMap().put("MessageStoreManagerUnitTest", topicConfig);
        this.metaConfig.setLoadMessageStoresInParallel(inParallel);
        for (int i = 0; i < 10; i++) {
            final MessageStore store = this.messageStoreManager.getMessageStore(topic, i);
            Assert.assertNull(store);
View Full Code Here

        assertEquals(40000, config.getZkConfig().zkConnectionTimeoutMs);
        assertEquals(5000, config.getZkConfig().zkSyncTimeMs);

        assertEquals("delete,999", config.getDeletePolicy());

        final TopicConfig topicConfig1 = config.getTopicConfig("test1");
        final TopicConfig topicConfig2 = config.getTopicConfig("test2");
        assertEquals("/home/admin", topicConfig1.getDataPath());
        assertEquals("/test2", topicConfig2.getDataPath());
        assertFalse(topicConfig1.isStat());
        assertTrue(topicConfig2.isStat());
    }
View Full Code Here


    @Before
    public void setUp() throws Exception {
        MetaConfig metaConfig = new MetaConfig();
        TopicConfig topicConfig = metaConfig.getTopicConfig("test");
        topicConfig.addFilterClass("test-group1", "com.taobao.metamorphosis.server.filter.NotExistsFilter");
        topicConfig.addFilterClass("test-group2", "com.taobao.metamorphosis.server.filter.TestFilter");
        this.consumerFilterManager = new ConsumerFilterManager(metaConfig);
    }
View Full Code Here

    public MessageStore(final String topic, final int partition, final MetaConfig metaConfig,
            final DeletePolicy deletePolicy, final long offsetIfCreate) throws IOException {
        this.metaConfig = metaConfig;
        this.topic = topic;
        final TopicConfig topicConfig = this.metaConfig.getTopicConfig(this.topic);
        String dataPath = metaConfig.getDataPath();
        if (topicConfig != null) {
            dataPath = topicConfig.getDataPath();
        }
        final File parentDir = new File(dataPath);
        this.checkDir(parentDir);
        this.partitionDir = new File(dataPath + File.separator + topic + "-" + partition);
        this.checkDir(this.partitionDir);
        // this.topic = topic;
        this.partition = partition;
        this.unflushed = new AtomicInteger(0);
        this.lastFlushTime = new AtomicLong(SystemTimer.currentTimeMillis());
        this.unflushThreshold = topicConfig.getUnflushThreshold();
        this.deletePolicy = deletePolicy;

        // Make a copy to avoid getting it again and again.
        this.maxTransferSize = metaConfig.getMaxTransferSize();
        this.maxTransferSize = this.maxTransferSize > ONE_M_BYTES ? ONE_M_BYTES : this.maxTransferSize;
View Full Code Here

        final Set<String> paths = new HashSet<String>();
        // public data path
        paths.add(metaConfig.getDataPath());
        // topic data path
        for (final String topic : metaConfig.getTopics()) {
            final TopicConfig topicConfig = metaConfig.getTopicConfig(topic);
            if (topicConfig != null) {
                paths.add(topicConfig.getDataPath());
            }
        }
        final Set<File> fileSet = new HashSet<File>();
        for (final String path : paths) {
            fileSet.add(this.getDataDir(path));
View Full Code Here

        return this.random.nextInt(this.getNumPartitions(topic));
    }


    public int getNumPartitions(final String topic) {
        final TopicConfig topicConfig = this.metaConfig.getTopicConfig(topic);
        return topicConfig != null ? topicConfig.getNumPartitions() : this.metaConfig.getNumPartitions();
    }
View Full Code Here

    @Override
    public void init(final MetaMorphosisBroker metaMorphosisBroker, final Properties props) {
        final MetaConfig metaConfig = metaMorphosisBroker.getMetaConfig();
        // Added slave status topic for master to check it.
        TopicConfig topicConfig = new TopicConfig(Constants.TEST_SLAVE_TOPIC, metaConfig);
        topicConfig.setNumPartitions(1);
        metaConfig.addTopic(Constants.TEST_SLAVE_TOPIC, topicConfig);
        // slave��ע�ᵽzk,ǿ��
        metaMorphosisBroker.getBrokerZooKeeper().getZkConfig().zkEnable = false;
        this.orderedPutExecutor =
                new OrderedThreadPoolExecutor(metaConfig.getPutProcessThreadCount(),
View Full Code Here

    private void startScheduleDeleteJobs() {
        final Map<String/* deleteWhen */, JobInfo> jobs = new HashMap<String, MessageStoreManager.JobInfo>();
        // ����quartz job
        for (final String topic : this.getAllTopics()) {
            final TopicConfig topicConfig = this.metaConfig.getTopicConfig(topic);
            final String deleteWhen =
                    topicConfig != null ? topicConfig.getDeleteWhen() : this.metaConfig.getDeleteWhen();
                    JobInfo jobInfo = jobs.get(deleteWhen);
                    if (jobInfo == null) {
                        final JobDetail job = newJob(DeleteJob.class).build();
                        job.getJobDataMap().put(DeleteJob.TOPICS, new HashSet<String>());
                        job.getJobDataMap().put(DeleteJob.STORE_MGR, this);
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.