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);
}
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");
}
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));
}
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);
}
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());
}
Aggregations