Canal Adapter1.1.5版本API操作服务,手动同步数据(4)

api类:com.alibaba.otter.canal.adapter.launcher.rest.CommonRest

  • 查看同步任务instance列表

curl http://127.0.0.1:8081/destinations
>>
[{"destination":"canal-test","status":"on"}]
  • 同步开关

curl http://127.0.0.1:8081/syncSwitch/canal-test/off -X PUT
>>
{"code":20000,"message":"实例: canal-test 关闭同步成功"}
    /**
     * 实例同步开关 curl http://127.0.0.1:8081/syncSwitch/example/off -X PUT
     *
     * @param destination 实例名称
     * @param status 开关状态: off on
     * @return
     */
    @PutMapping("/syncSwitch/{destination}/{status}")
    public Result etl(@PathVariable String destination, @PathVariable String status)
  • 查看开关状态

curl http://127.0.0.1:8081/syncSwitch/canal-test
>>
{"stauts":"off"}
    /**
     * 获取实例开关状态 curl http://127.0.0.1:8081/syncSwitch/example
     *
     * @param destination 实例名称
     * @return
     */
    @GetMapping("/syncSwitch/{destination}")
    public Map<String, String> etl(@PathVariable String destination)
  • 手动同步数据

#全量,不传参数
curl http://127.0.0.1:8081/etl/es7/test-user/test_user.yml -X POST
>>
{"succeeded":true,"resultMessage":"导入ES 数据:20 条"}
#部分同步,etlCondition: "where id between {} and {}"
curl http://127.0.0.1:8081/etl/es7/test-user/test_user.yml -X POST -d "params=1273;1275"
>>
{"succeeded":true,"resultMessage":"导入ES 数据:2 条"}
    /**
     * ETL curl http://127.0.0.1:8081/etl/rdb/oracle1/mytest_user.yml -X POST
     *
     * @param type 类型 hbase, es
     * @param key adapter key
     * @param task 任务名对应配置文件名 mytest_user.yml
     * @param params etl where条件参数, 为空全部导入,匹配etlCondition中的参数,使用;分号多个值
     */
    @PostMapping("/etl/{type}/{key}/{task}")
    public EtlResult etl(@PathVariable String type, @PathVariable String key, @PathVariable String task,
                         @RequestParam(name = "params", required = false) String params) 
  • 查询同步库中总数

curl http://127.0.0.1:8081/count/es7/test-user/test_user.yml
>>
{"esIndex":"test_user","count":5}

 

    /**
     * ETL curl http://127.0.0.1:8081/etl/rdb/oracle1/mytest_user.yml -X POST
     *
     * @param type 类型 hbase, es
     * @param key outerAdapters key
     * @param task 任务名对应配置文件名 mytest_user.yml
     * @param params etl where条件参数, 为空全部导入
     */
    @PostMapping("/etl/{type}/{key}/{task}")
    public EtlResult etl(@PathVariable String type, @PathVariable String key, @PathVariable String task,
                         @RequestParam(name = "params", required = false) String params) 

缺少key可能导致无法识别outerAdapters数据源

 

 

 

 

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lizz666

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值