Search in sources :

Example 6 with RepeatConfigureException

use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException in project otter by alibaba.

the class CanalAction method doAdd.

/**
     * 添加canal
     */
public void doAdd(@FormGroup("canalInfo") Group canalInfo, @FormGroup("canalParameterInfo") Group canalParameterInfo, @FormField(name = "formCanalError", group = "canalInfo") CustomErrors err, @FormField(name = "formHeartBeatError", group = "canalParameterInfo") CustomErrors heartBeatErr, Navigator nav) throws Exception {
    Canal canal = new Canal();
    CanalParameter parameter = new CanalParameter();
    canalInfo.setProperties(canal);
    canalParameterInfo.setProperties(parameter);
    String zkClustersString = canalParameterInfo.getField("zkClusters").getStringValue();
    String[] zkClusters = StringUtils.split(zkClustersString, ";");
    parameter.setZkClusters(Arrays.asList(zkClusters));
    Long zkClusterId = canalParameterInfo.getField("autoKeeperClusterId").getLongValue();
    parameter.setZkClusterId(zkClusterId);
    canal.setCanalParameter(parameter);
    String dbAddressesString = canalParameterInfo.getField("groupDbAddresses").getStringValue();
    // 第一层的分号代表主备概念,,第二层逗号代表分组概念
    if (StringUtils.isNotEmpty(dbAddressesString)) {
        List<List<DataSourcing>> dbSocketAddress = new ArrayList<List<DataSourcing>>();
        String[] dbAddresses = StringUtils.split(dbAddressesString, ";");
        for (String dbAddressString : dbAddresses) {
            List<DataSourcing> groupDbSocketAddress = new ArrayList<DataSourcing>();
            String[] groupDbAddresses = StringUtils.split(dbAddressString, ",");
            for (String groupDbAddress : groupDbAddresses) {
                String[] strs = StringUtils.split(groupDbAddress, ":");
                InetSocketAddress address = new InetSocketAddress(strs[0].trim(), Integer.valueOf(strs[1]));
                SourcingType type = parameter.getSourcingType();
                if (strs.length > 2) {
                    type = SourcingType.valueOf(strs[2]);
                }
                groupDbSocketAddress.add(new DataSourcing(type, address));
            }
            dbSocketAddress.add(groupDbSocketAddress);
        }
        parameter.setGroupDbAddresses(dbSocketAddress);
    }
    String positionsString = canalParameterInfo.getField("positions").getStringValue();
    if (StringUtils.isNotEmpty(positionsString)) {
        String[] positions = StringUtils.split(positionsString, ";");
        parameter.setPositions(Arrays.asList(positions));
    }
    if (parameter.getDetectingEnable() && StringUtils.startsWithIgnoreCase(parameter.getDetectingSQL(), "select")) {
        heartBeatErr.setMessage("invaliedHeartBeat");
        return;
    }
    try {
        canalService.create(canal);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidCanal");
        return;
    }
    if (parameter.getSourcingType().isMysql() && parameter.getSlaveId() == null) {
        parameter.setSlaveId(10000 + canal.getId());
        // 再次更新一下slaveId
        try {
            canalService.modify(canal);
        } catch (RepeatConfigureException rce) {
            err.setMessage("invalidCanal");
            return;
        }
    }
    nav.redirectTo(WebConstant.CANAL_LIST_LINK);
}
Also used : SourcingType(com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType) Canal(com.alibaba.otter.canal.instance.manager.model.Canal) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) CanalParameter(com.alibaba.otter.canal.instance.manager.model.CanalParameter) ArrayList(java.util.ArrayList) List(java.util.List) DataSourcing(com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing)

Example 7 with RepeatConfigureException

use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException in project otter by alibaba.

the class CanalAction method doEdit.

/**
     * 修改canal
     */
public void doEdit(@FormGroup("canalInfo") Group canalInfo, @FormGroup("canalParameterInfo") Group canalParameterInfo, @FormField(name = "formCanalError", group = "canalInfo") CustomErrors err, @FormField(name = "formHeartBeatError", group = "canalParameterInfo") CustomErrors heartBeatErr, Navigator nav) throws Exception {
    Canal canal = new Canal();
    CanalParameter parameter = new CanalParameter();
    canalInfo.setProperties(canal);
    canalParameterInfo.setProperties(parameter);
    String zkClustersString = canalParameterInfo.getField("zkClusters").getStringValue();
    String[] zkClusters = StringUtils.split(zkClustersString, ";");
    parameter.setZkClusters(Arrays.asList(zkClusters));
    Long zkClusterId = canalParameterInfo.getField("autoKeeperClusterId").getLongValue();
    parameter.setZkClusterId(zkClusterId);
    String dbAddressesString = canalParameterInfo.getField("groupDbAddresses").getStringValue();
    if (StringUtils.isNotEmpty(dbAddressesString)) {
        List<List<DataSourcing>> dbSocketAddress = new ArrayList<List<DataSourcing>>();
        String[] dbAddresses = StringUtils.split(dbAddressesString, ";");
        for (String dbAddressString : dbAddresses) {
            List<DataSourcing> groupDbSocketAddress = new ArrayList<DataSourcing>();
            String[] groupDbAddresses = StringUtils.split(dbAddressString, ",");
            for (String groupDbAddress : groupDbAddresses) {
                String[] strs = StringUtils.split(groupDbAddress, ":");
                InetSocketAddress address = new InetSocketAddress(strs[0].trim(), Integer.valueOf(strs[1]));
                SourcingType type = parameter.getSourcingType();
                if (strs.length > 2) {
                    type = SourcingType.valueOf(strs[2]);
                }
                groupDbSocketAddress.add(new DataSourcing(type, address));
            }
            dbSocketAddress.add(groupDbSocketAddress);
        }
        parameter.setGroupDbAddresses(dbSocketAddress);
    }
    String positionsString = canalParameterInfo.getField("positions").getStringValue();
    if (StringUtils.isNotEmpty(positionsString)) {
        String[] positions = StringUtils.split(positionsString, ";");
        parameter.setPositions(Arrays.asList(positions));
    }
    if (parameter.getDetectingEnable() && StringUtils.startsWithIgnoreCase(parameter.getDetectingSQL(), "select")) {
        heartBeatErr.setMessage("invaliedHeartBeat");
        return;
    }
    canal.setCanalParameter(parameter);
    try {
        canalService.modify(canal);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidCanal");
        return;
    }
    nav.redirectToLocation("canalList.htm");
}
Also used : SourcingType(com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType) Canal(com.alibaba.otter.canal.instance.manager.model.Canal) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) CanalParameter(com.alibaba.otter.canal.instance.manager.model.CanalParameter) ArrayList(java.util.ArrayList) List(java.util.List) DataSourcing(com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing)

Example 8 with RepeatConfigureException

use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException in project otter by alibaba.

the class ChannelAction method doEdit.

/**
     * 修改Channel
     * 
     * @param channelInfo
     * @param channelParameterInfo
     * @throws Exception
     */
public void doEdit(@FormGroup("channelInfo") Group channelInfo, @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @FormGroup("channelParameterInfo") Group channelParameterInfo, @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav) throws Exception {
    Channel channel = new Channel();
    ChannelParameter parameter = new ChannelParameter();
    channelInfo.setProperties(channel);
    channelParameterInfo.setProperties(parameter);
    channel.setStatus(channelService.findById(channel.getId()).getStatus());
    parameter.setChannelId(channel.getId());
    channel.setParameters(parameter);
    try {
        channelService.modify(channel);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidChannelName");
        return;
    }
    nav.redirectToLocation("channelList.htm?pageIndex=" + pageIndex + "&searchKey=" + urlEncode(searchKey));
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ChannelParameter(com.alibaba.otter.shared.common.model.config.channel.ChannelParameter) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel)

Example 9 with RepeatConfigureException

use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException in project otter by alibaba.

the class DataMatrixAction method doAdd.

public void doAdd(@FormGroup("dataMatrixInfo") Group dataMatrixInfo, @FormField(name = "formDataMatrixError", group = "dataMatrixInfo") CustomErrors err, Navigator nav) throws Exception {
    DataMatrix matrix = new DataMatrix();
    dataMatrixInfo.setProperties(matrix);
    try {
        dataMatrixService.create(matrix);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidDataMatrix");
        return;
    }
    nav.redirectTo(WebConstant.MATRIX_LIST_LINK);
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMatrix(com.alibaba.otter.shared.common.model.config.data.DataMatrix)

Example 10 with RepeatConfigureException

use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException in project otter by alibaba.

the class DataMatrixAction method doEdit.

public void doEdit(@FormGroup("dataMatrixInfo") Group dataMatrixInfo, @FormField(name = "formDataMatrixError", group = "dataMatrixInfo") CustomErrors err, Navigator nav) throws Exception {
    DataMatrix matrix = new DataMatrix();
    dataMatrixInfo.setProperties(matrix);
    try {
        dataMatrixService.modify(matrix);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidDataMatrix");
        return;
    }
    nav.redirectToLocation("dataMatrixList.htm?matrixId=" + matrix.getId());
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMatrix(com.alibaba.otter.shared.common.model.config.data.DataMatrix)

Aggregations

RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)46 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)23 TransactionStatus (org.springframework.transaction.TransactionStatus)8 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)8 ArrayList (java.util.ArrayList)7 Node (com.alibaba.otter.shared.common.model.config.node.Node)6 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)5 AutoKeeperCluster (com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster)4 DataColumnPairDO (com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)3 DataMediaDO (com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO)3 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)3 DataMediaSource (com.alibaba.otter.shared.common.model.config.data.DataMediaSource)3 MqMediaSource (com.alibaba.otter.shared.common.model.config.data.mq.MqMediaSource)3 List (java.util.List)3 Canal (com.alibaba.otter.canal.instance.manager.model.Canal)2 CanalParameter (com.alibaba.otter.canal.instance.manager.model.CanalParameter)2 DataSourcing (com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing)2 SourcingType (com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType)2 InvalidConfigureException (com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException)2 CanalDO (com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO)2