Package com.taobao.metamorphosis.cluster

Examples of com.taobao.metamorphosis.cluster.Partition


        Map<Partition, Partition> srcTargetPartitionMap =
                this.getSrcTargetPartitionMap(this.getSourcePartitions(src, start, end), target, targetStart);
        for (String group : groups) {

            for (Map.Entry<Partition, Partition> entry : srcTargetPartitionMap.entrySet()) {
                Partition oldPartition = entry.getKey();
                Partition newPartition = entry.getValue();

                String srcOffset = this.query.queryOffset(new OffsetQueryDO(topic, group, oldPartition.toString(), "zk"));
                if (!StringUtils.isBlank(srcOffset)) {
                    if (!StringUtils.isBlank(this.query.queryOffset(new OffsetQueryDO(topic, group, newPartition.toString(), "zk")))) {
                        this.println("topic=" + topic + ",group=" + group + ",partition[" + newPartition
                                + "] offset �Ѿ�����");
                        continue;
                    }
                    this.zkManager.setOffset(topic, group, newPartition, srcOffset);
View Full Code Here


    // }

    private List<Partition> getSourcePartitions(int brokerId, int startPartitionNo, int endPartitionNo) {
        List<Partition> list = new LinkedList<Partition>();
        for (int i = startPartitionNo; i <= endPartitionNo; i++) {
            list.add(new Partition(brokerId, i));
        }
        return list;
    }
View Full Code Here


    private Map<Partition, Partition> getSrcTargetPartitionMap(List<Partition> srcPartitions, int target, int start) {
        Map<Partition, Partition> map = new TreeMap<Partition, Partition>();
        for (int i = 0; i < srcPartitions.size(); i++) {
            map.put(srcPartitions.get(i), new Partition(target, i + start));
        }
        return map;
    }
View Full Code Here

    public void testBackwardCompatibility() throws IOException {
        OffsetStorage offsetStorage =
                new LocalOffsetStorage(ResourceUtils.getResourceAsFile("oldVersion_meta_offsets").getAbsolutePath());
        final String group = "test-grp";
        final String topic = "test-topic";
        Partition partition1 = new Partition("100-0");
        Partition partition2 = new Partition("101-0");
        TopicPartitionRegInfo info = offsetStorage.load(topic, group, partition1);
        assertEquals(topic, info.getTopic());
        assertEquals(partition1, info.getPartition());
        assertEquals(0, info.getOffset().get());
        // �����⼸��ֵ�����ļ�����û��,���ǰ���Ĭ�ϵ�
View Full Code Here

        final SimpleHttpConsumer client = new SimpleHttpConsumer(new HttpClientConfig("localhost", 8080));

        MessageIterator it = null;
        // get messages
        long syncOffSet = this.offset;
        while ((it = client.get("meta-test", new Partition(1, 1), syncOffSet, 99999)) != null) {
            while (it.hasNext()) {
                final Message msg = it.next();
                logger.info("Receive message:" + new String(msg.getData()));
                logger.info("message attribute:" + msg.getAttribute());
            }
View Full Code Here

    @Test
    public void testSendMessage() throws MetaClientException {
        final SimpleHttpProducer client = new SimpleHttpProducer(new HttpClientConfig("localhost", 8080));
        final Message message = new Message("meta-test", "world".getBytes());
        message.setAttribute(System.currentTimeMillis() + "");
        final SendResult result = client.sendMessage(message, new Partition(1, 1));
        logger.info("send message:" + result.isSuccess());
    }
View Full Code Here

        dataSource.setDriverUrl("jdbc:mysql://localhost:3306/meta");
        dataSource.setUser("root");
        dataSource.setPassword("1234QWER");
        httpClientConfig.setDataSource(dataSource);
        final SimpleHttpConsumer client = new SimpleHttpConsumer(httpClientConfig);
        client.subscribe("meta-test", new Partition(1, 1), 99999, new MessageListener() {

            @Override
            public void recieveMessages(final Message message) {
                logger.info(new String(message.getData()));
            }
View Full Code Here

    @Test
    public void testInitLoadCommitLoad() {
        final String topic = "test";
        final String group = "test-grp";
        final Partition partition = new Partition("0-1");
        this.offsetStorage.initOffset(topic, group, partition, 0);

        final TopicPartitionRegInfo info = this.offsetStorage.load(topic, group, partition);
        assertEquals(topic, info.getTopic());
        assertEquals(partition, info.getPartition());
View Full Code Here

    @Test
    public void initDuplicate() {
        final String topic = "test";
        final String group = "test-grp";
        final Partition partition = new Partition("0-1");
        this.offsetStorage.initOffset(topic, group, partition, 0);
        this.offsetStorage.initOffset(topic, group, partition, 0);
    }
View Full Code Here


    @Test
    public void testInitCommitMany() {
        final String group = "test-grp";
        final Partition partition = new Partition("0-1");
        this.offsetStorage.initOffset("test1", group, partition, 0);
        this.offsetStorage.initOffset("test2", group, partition, 0);
        this.offsetStorage.initOffset("test3", group, partition, 0);
        final Collection<TopicPartitionRegInfo> infoList = new ArrayList<TopicPartitionRegInfo>();
        for (int i = 0; i < 3; i++) {
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.