Search in sources :

Example 6 with CanalParameter

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;
}
Also used : CanalParameter(com.alibaba.otter.canal.instance.manager.model.CanalParameter) Canal(com.alibaba.otter.canal.instance.manager.model.Canal) AutoKeeperCluster(com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 7 with CanalParameter

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();
    }
}
Also used : CanalParameter(com.alibaba.otter.canal.instance.manager.model.CanalParameter) DataSourcing(com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing)

Aggregations

CanalParameter (com.alibaba.otter.canal.instance.manager.model.CanalParameter)7 Canal (com.alibaba.otter.canal.instance.manager.model.Canal)6 InetSocketAddress (java.net.InetSocketAddress)5 DataSourcing (com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing)3 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)3 SourcingType (com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)1 AutoKeeperCluster (com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster)1