Package com.alibaba.otter.canal.protocol.position

Examples of com.alibaba.otter.canal.protocol.position.LogPosition


        metaManager.updateCursor(client2, range3.getEnd());

        PositionRange range4 = buildRange(4);
        metaManager.updateCursor(client2, range4.getEnd());

        LogPosition logPosition = logPositionManager.getLatestIndexBy(destination);
        Assert.assertEquals(range2.getEnd(), logPosition);

        metaManager.stop();
        logPositionManager.stop();
    }
View Full Code Here


        metaManager.stop();
        logPositionManager.stop();
    }

    private PositionRange<LogPosition> buildRange(int number) {
        LogPosition start = new LogPosition();
        start.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L));
        start.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime()));

        LogPosition end = new LogPosition();
        end.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L));
        end.setPostion(new EntryPosition("mysql-bin.000000" + (number + 1), 106L, (new Date().getTime()) + 1000 * 1000L));
        return new PositionRange<LogPosition>(start, end);
    }
View Full Code Here

            public void persistLogPosition(String destination, LogPosition logPosition) {
                System.out.println(logPosition);
            }

            public LogPosition getLatestIndexBy(String destination) {
                LogPosition masterLogPosition = new LogPosition();
                masterLogPosition.setIdentity(new LogIdentity(new InetSocketAddress("127.0.0.1", 3306), 1234L));
                masterLogPosition.setPostion(new EntryPosition(1322803601000L));
                return masterLogPosition;
            }
        });

        controller.start();
View Full Code Here

public class AbstractLogPositionManagerTest extends AbstractZkTest {

    private static final String MYSQL_ADDRESS = "127.0.0.1";

    public LogPosition doTest(CanalLogPositionManager logPositionManager) {
        LogPosition getPosition = logPositionManager.getLatestIndexBy(destination);
        Assert.assertNull(getPosition);

        LogPosition postion1 = buildPosition(1);
        logPositionManager.persistLogPosition(destination, postion1);
        LogPosition getPosition1 = logPositionManager.getLatestIndexBy(destination);
        Assert.assertEquals(postion1, getPosition1);

        LogPosition postion2 = buildPosition(2);
        logPositionManager.persistLogPosition(destination, postion2);
        LogPosition getPosition2 = logPositionManager.getLatestIndexBy(destination);
        Assert.assertEquals(postion2, getPosition2);
        return postion2;
    }
View Full Code Here

        Assert.assertEquals(postion2, getPosition2);
        return postion2;
    }

    protected LogPosition buildPosition(int number) {
        LogPosition position = new LogPosition();
        position.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L));
        position.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime()));
        return position;
    }
View Full Code Here

        zookeeperLogPositionManager.setZkClientx(zkclientx);

        logPositionManager.setZooKeeperLogPositionManager(zookeeperLogPositionManager);
        logPositionManager.start();

        LogPosition position2 = doTest(logPositionManager);
        sleep(1500);

        PeriodMixedLogPositionManager logPositionManager2 = new PeriodMixedLogPositionManager();
        logPositionManager2.setZooKeeperLogPositionManager(zookeeperLogPositionManager);
        logPositionManager2.start();

        LogPosition getPosition2 = logPositionManager2.getLatestIndexBy(destination);
        Assert.assertEquals(position2, getPosition2);

        logPositionManager.stop();
        logPositionManager2.stop();
    }
View Full Code Here

        }
        executor = Executors.newScheduledThreadPool(1);
        positions = new MapMaker().makeComputingMap(new Function<String, LogPosition>() {

            public LogPosition apply(String destination) {
                LogPosition logPosition = zooKeeperLogPositionManager.getLatestIndexBy(destination);
                if (logPosition == null) {
                    return nullPosition;
                } else {
                    return logPosition;
                }
View Full Code Here

        persistTasks.add(destination);// 添加到任务队列中进行触发
        super.persistLogPosition(destination, logPosition);
    }

    public LogPosition getLatestIndexBy(String destination) {
        LogPosition logPostion = super.getLatestIndexBy(destination);
        if (logPostion == nullPosition) {
            return null;
        } else {
            return logPostion;
        }
View Full Code Here

            failback.stop();
        }
    }

    public LogPosition getLatestIndexBy(String destination) {
        LogPosition logPosition = primary.getLatestIndexBy(destination);
        if (logPosition == null) {
            return failback.getLatestIndexBy(destination);
        } else {
            return logPosition;
        }
View Full Code Here

        logger.info("persist LogPosition:{}", destination, logPosition);
    }

    public LogPosition getLatestIndexBy(String destination) {
        List<ClientIdentity> clientIdentitys = metaManager.listAllSubscribeInfo(destination);
        LogPosition result = null;
        if (!CollectionUtils.isEmpty(clientIdentitys)) {
            // 尝试找到一个最小的logPosition
            for (ClientIdentity clientIdentity : clientIdentitys) {
                LogPosition position = (LogPosition) metaManager.getCursor(clientIdentity);
                if (position == null) {
                    continue;
                }

                if (result == null) {
View Full Code Here

TOP

Related Classes of com.alibaba.otter.canal.protocol.position.LogPosition

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.