use of com.alibaba.otter.canal.admin.model.CanalConfig in project canal by alibaba.
the class NodeServerServiceImpl method save.
public void save(NodeServer nodeServer) {
int cnt = NodeServer.find.query().where().eq("ip", nodeServer.getIp()).eq("adminPort", nodeServer.getAdminPort()).findCount();
if (cnt > 0) {
throw new ServiceException("节点信息已存在");
}
nodeServer.save();
if (nodeServer.getClusterId() == null) {
// 单机模式
CanalConfig canalConfig = new CanalConfig();
canalConfig.setServerId(nodeServer.getId());
String configTmp = TemplateConfigLoader.loadCanalConfig();
canalConfig.setContent(configTmp);
try {
String contentMd5 = SecurityUtil.md5String(canalConfig.getContent());
canalConfig.setContentMd5(contentMd5);
} catch (NoSuchAlgorithmException e) {
}
canalConfig.save();
}
}
Aggregations