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

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


        });

        cursors = new MapMaker().makeComputingMap(new Function<ClientIdentity, Position>() {

            public Position apply(ClientIdentity clientIdentity) {
                Position position = loadCursor(clientIdentity.getDestination(), clientIdentity);
                if (position == null) {
                    return nullCursor; // 返回一个空对象标识,避免出现异常
                } else {
                    return position;
                }
View Full Code Here


        updateCursorTasks.add(clientIdentity);// 添加到任务队列中进行触发
        super.updateCursor(clientIdentity, position);
    }

    public Position getCursor(ClientIdentity clientIdentity) throws CanalMetaManagerException {
        Position position = super.getCursor(clientIdentity);
        if (position == nullCursor) {
            return null;
        } else {
            return position;
        }
View Full Code Here

                List<FileMetaClientIdentityData> clientDatas = Lists.newArrayList();
                List<ClientIdentity> clientIdentitys = destinations.get(destination);
                for (ClientIdentity clientIdentity : clientIdentitys) {
                    FileMetaClientIdentityData clientData = new FileMetaClientIdentityData();
                    clientData.setClientIdentity(clientIdentity);
                    Position position = cursors.get(clientIdentity);
                    if (position != null && position != nullCursor) {
                        clientData.setCursor((LogPosition) position);
                    }
                    clientData.setBatch(batches.get(clientIdentity));
View Full Code Here

            sleep(100L);
            Assert.assertTrue(result);
        }

        sleep(50L);
        Position first = eventStore.getFirstPosition();
        Position lastest = eventStore.getLatestPosition();
        Assert.assertEquals(first, CanalEventUtils.createPosition(buildEvent("1", 1L, 1L)));
        Assert.assertEquals(lastest, CanalEventUtils.createPosition(buildEvent("1", 1L, 1L + bufferSize / 2 - 1)));

        System.out.println("start get");
        Events<Event> entrys1 = eventStore.tryGet(first, bufferSize);
View Full Code Here

            sleep(100L);
            Assert.assertTrue(result);
        }

        sleep(50L);
        Position first = eventStore.getFirstPosition();
        Position lastest = eventStore.getLatestPosition();
        Assert.assertEquals(first, CanalEventUtils.createPosition(buildEvent("1", 1L, 1L)));
        Assert.assertEquals(lastest, CanalEventUtils.createPosition(buildEvent("1", 1L, 1L + bufferSize / 2 - 1)));

        System.out.println("start get");
        Events<Event> entrys1 = eventStore.tryGet(first, bufferSize);
View Full Code Here

    }

    public Position doCursorTest(CanalMetaManager metaManager) {
        metaManager.subscribe(clientIdentity);

        Position position1 = metaManager.getCursor(clientIdentity);
        Assert.assertNull(position1);

        PositionRange range = buildRange(1);

        metaManager.updateCursor(clientIdentity, range.getStart());
        Position position2 = metaManager.getCursor(clientIdentity);
        Assert.assertEquals(range.getStart(), position2);

        metaManager.updateCursor(clientIdentity, range.getEnd());
        Position position3 = metaManager.getCursor(clientIdentity);
        Assert.assertEquals(range.getEnd(), position3);

        return position3;
    }
View Full Code Here

        FileMixedMetaManager metaManager = new FileMixedMetaManager();
        metaManager.setDataDir(dataDir);
        metaManager.setPeriod(100);
        metaManager.start();

        Position lastPosition = doCursorTest(metaManager);

        sleep(1000L);
        // 重新构建一次,能获得上一次zk上的记录
        FileMixedMetaManager metaManager2 = new FileMixedMetaManager();
        metaManager2.setDataDir(dataDir);
        metaManager2.setPeriod(100);
        metaManager2.start();

        Position position = metaManager2.getCursor(clientIdentity);
        Assert.assertEquals(position, lastPosition);
        metaManager.stop();
    }
View Full Code Here

        ZooKeeperMetaManager zooKeeperMetaManager = new ZooKeeperMetaManager();
        zooKeeperMetaManager.setZkClientx(zkclientx);

        metaManager.setZooKeeperMetaManager(zooKeeperMetaManager);
        metaManager.start();
        Position lastPosition = doCursorTest(metaManager);

        sleep(1000L);
        // 重新构建一次,能获得上一次zk上的记录
        MixedMetaManager metaManager2 = new MixedMetaManager();
        metaManager2.setZooKeeperMetaManager(zooKeeperMetaManager);
        metaManager2.start();

        Position position = metaManager2.getCursor(clientIdentity);
        Assert.assertEquals(position, lastPosition);
        metaManager.stop();
    }
View Full Code Here

            canalInstance.getMetaManager().start();
        }

        canalInstance.getMetaManager().subscribe(clientIdentity); // 执行一下meta订阅

        Position position = canalInstance.getMetaManager().getCursor(clientIdentity);
        if (position == null) {
            position = canalInstance.getEventStore().getFirstPosition();// 获取一下store中的第一条
            if (position != null) {
                canalInstance.getMetaManager().updateCursor(clientIdentity, position); // 更新一下cursor
            }
View Full Code Here

                                               String.format("clientId:%s has last batch:[%s] isn't ack , maybe loss data",
                                                             clientIdentity.getClientId(), positionRanges));
            }

            Events<Event> events = null;
            Position start = canalInstance.getMetaManager().getCursor(clientIdentity);
            events = getEvents(canalInstance.getEventStore(), start, batchSize, timeout, unit);

            if (CollectionUtils.isEmpty(events.getEvents())) {
                logger.debug("get successfully, clientId:{} batchSize:{} but result is null", new Object[] {
                        clientIdentity.getClientId(), batchSize });
View Full Code Here

TOP

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

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.