现状
manager 管理node,manager还提供了界面来配置同步链路。但是界面操作依赖人工,manager没有提供HTTP接口,其它服务想通过接口来创建任务的话,不可行。
计划改造成能够通过接口调用来创建同步链路。
项目改造
基于Otter master分支最新提交,增加springboot client工程,目标是为公司内springboot项目通过HTTP调用或者Dubbo调用操作Otter manager,实现任务创建和启动停止等
改造内容:
- 新增springboot client工程
- jdk版本升级为1.8
- 使用springboot 2.3.2.RELEASE,大家可通过RESTful接口调用 Otter manager模块
打包:
- 进入$otter_home目录
- 执行:mvn clean install -Dmaven.test.skip -Denv=release
- 发布包位置:$otter_home/target
部署Otter manager:
- 按照官方文档部署Otter的manager和node,https://github.com/alibaba/otter/wiki/QuickStart
部署Otter client::
- 进入$otter_home/target目录
- 执行:mkdir client && tar -xf client.deployer-4.2.19-SNAPSHOT.tar.gz -C client
- 启动脚本位置:$otter_home/target/client/bin/start.sh
- 修改manager端口:$otter_home/target/client/conf/application.yml,默认是 127.0.0.1:1099,请改成你部署的Otter manager地址
启动 springboot client:
- 进入$otter_home/target/client目录
- 启动脚本位置:bin/startup.sh
- 执行启动脚本:sh bin/startup.sh
- 测试调用:在命令行窗口输入curl --location 'http://localhost:8100/nodetest/node/1' 或者 浏览器地址栏输入 http://localhost:8100/nodetest/node/1,
返回 node 节点的信息表示成功:
Node[id=1,name=test-node1,ip=127.0.0.1,port=2088,status=START,description=,parameters=NodeParameter[mbeanPort=2090,downloadPort=2089,zkCluster=AutoKeeperCluster[id=1,clusterName=test-zk,serverList=[10.23.104.43:2181],description=,gmtCreate=2023-07-29 14:55:06,gmtModified=2023-08-23 19:48:22],externalIp=127.0.0.1,useExternalIp=false],gmtCreate=2023-07-29 14:56:14,gmtModified=2023-08-01 10:51:56] - 执行关闭脚本停止client:sh bin/stop.sh
Oook! cost:2
改造代码已经开源到个人github,注意是 feature- springboot分支:https://github.com/quanllong/otter/tree/feature-springboot