use of com.alibaba.otter.canal.instance.manager.model.CanalParameter in project otter by alibaba.
the class CanalServiceImpl method doToModel.
/**
* 用于DO对象转化为Model对象
*
* @param canalDo
* @return Canal
*/
private Canal doToModel(CanalDO canalDo) {
Canal canal = new Canal();
try {
canal.setId(canalDo.getId());
canal.setName(canalDo.getName());
canal.setStatus(canalDo.getStatus());
canal.setDesc(canalDo.getDescription());
CanalParameter parameter = canalDo.getParameters();
AutoKeeperCluster zkCluster = autoKeeperClusterService.findAutoKeeperClusterById(parameter.getZkClusterId());
if (zkCluster != null) {
parameter.setZkClusters(Arrays.asList(StringUtils.join(zkCluster.getServerList(), ',')));
}
canal.setCanalParameter(canalDo.getParameters());
canal.setGmtCreate(canalDo.getGmtCreate());
canal.setGmtModified(canalDo.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the canal Do to Model has an exception");
throw new ManagerException(e);
}
return canal;
}
use of com.alibaba.otter.canal.instance.manager.model.CanalParameter in project otter by alibaba.
the class SeniorCanal method getUrl.
public String getUrl() {
CanalParameter parameter = getCanalParameter();
if (parameter.getHaMode().isMedia()) {
return "media://" + parameter.getMediaGroup();
} else {
StringBuilder address = new StringBuilder("jdbc://");
for (List<DataSourcing> groupAddress : parameter.getGroupDbAddresses()) {
int i = 0;
for (DataSourcing dbAddress : groupAddress) {
++i;
address.append(dbAddress.getDbAddress().getAddress().getHostName()).append(":").append(dbAddress.getDbAddress().getPort());
if (i < groupAddress.size()) {
address.append(',');
}
}
address.append(';');
}
return address.toString();
}
}
Aggregations