use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster in project otter by alibaba.
the class AutoKeeperClusterAction method doEdit.
public void doEdit(@FormGroup("autokeeperClusterInfo") Group autokeeperClusterInfo, @FormField(name = "formAutokeeperClusterError", group = "autokeeperClusterInfo") CustomErrors err, Navigator nav) throws Exception {
AutoKeeperCluster autoKeeperCluster = new AutoKeeperCluster();
autokeeperClusterInfo.setProperties(autoKeeperCluster);
String zkClustersString = autokeeperClusterInfo.getField("zookeeperClusters").getStringValue();
String[] zkClusters = StringUtils.split(zkClustersString, ";");
autoKeeperCluster.setServerList(Arrays.asList(zkClusters));
try {
autoKeeperClusterService.modifyAutoKeeperCluster(autoKeeperCluster);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidChannelName");
return;
}
nav.redirectTo(WebConstant.AUTO_KEEPER_CLUSTERS_LINK);
}
use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster in project otter by alibaba.
the class AutoKeeperClusterAction method doAdd.
public void doAdd(@FormGroup("autokeeperClusterInfo") Group autokeeperClusterInfo, @FormField(name = "formAutokeeperClusterError", group = "autokeeperClusterInfo") CustomErrors err, Navigator nav) throws Exception {
AutoKeeperCluster autoKeeperCluster = new AutoKeeperCluster();
autokeeperClusterInfo.setProperties(autoKeeperCluster);
String zkClustersString = autokeeperClusterInfo.getField("zookeeperClusters").getStringValue();
String[] zkClusters = StringUtils.split(zkClustersString, ";");
autoKeeperCluster.setServerList(Arrays.asList(zkClusters));
try {
autoKeeperClusterService.createAutoKeeperCluster(autoKeeperCluster);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidNode");
return;
}
nav.redirectTo(WebConstant.AUTO_KEEPER_CLUSTERS_LINK);
}
use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster in project otter by alibaba.
the class NodeServiceImpl method doToModel.
/**
* 用于DO对象转化为Model对象
*
* @param nodeDo
* @return Node
*/
private Node doToModel(NodeDO nodeDo) {
Node node = new Node();
try {
node.setId(nodeDo.getId());
node.setIp(nodeDo.getIp());
node.setName(nodeDo.getName());
node.setPort(nodeDo.getPort());
node.setDescription(nodeDo.getDescription());
node.setStatus(nodeDo.getStatus());
// 处理下zk集群
NodeParameter parameter = nodeDo.getParameters();
if (parameter.getZkCluster() != null) {
AutoKeeperCluster zkCluster = autoKeeperClusterService.findAutoKeeperClusterById(parameter.getZkCluster().getId());
parameter.setZkCluster(zkCluster);
}
node.setParameters(parameter);
node.setGmtCreate(nodeDo.getGmtCreate());
node.setGmtModified(nodeDo.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the node Do to Model has an exception");
throw new ManagerException(e);
}
return node;
}
use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster in project otter by alibaba.
the class AutoKeeperClusterServiceImpl method doToModel.
private AutoKeeperCluster doToModel(AutoKeeperClusterDO autoKeeperClusterDo) {
AutoKeeperCluster autoKeeperCluster = new AutoKeeperCluster();
autoKeeperCluster.setId(autoKeeperClusterDo.getId());
autoKeeperCluster.setClusterName(autoKeeperClusterDo.getClusterName());
autoKeeperCluster.setDescription(autoKeeperClusterDo.getDescription());
autoKeeperCluster.setServerList(JsonUtils.unmarshalFromString(autoKeeperClusterDo.getServerList(), new TypeReference<List<String>>() {
}));
autoKeeperCluster.setGmtCreate(autoKeeperClusterDo.getGmtCreate());
autoKeeperCluster.setGmtModified(autoKeeperClusterDo.getGmtModified());
return autoKeeperCluster;
}
use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster in project otter by alibaba.
the class AutoKeeperClientPath method execute.
public void execute(@Param("clusterId") String clusterId, @Param("address") String address, Context context) throws Exception {
AutoKeeperCluster autoKeeperCluster = autoKeeperClusterService.findAutoKeeperClusterById(Long.valueOf(clusterId));
Set<AutoKeeperConnectionStat> autoKeeperConnectionStats = new HashSet<AutoKeeperConnectionStat>();
for (String ipAddress : autoKeeperCluster.getServerList()) {
if (ipAddress.equalsIgnoreCase(address)) {
AutoKeeperServerStat autoKeeperServerStat = autoKeeperStatService.findServerStat(ipAddress);
if (autoKeeperServerStat != null) {
autoKeeperConnectionStats = autoKeeperServerStat.getConnectionStats();
} else {
autoKeeperConnectionStats = new HashSet<AutoKeeperConnectionStat>();
}
}
}
context.put("autoKeeperConnectionStats", autoKeeperConnectionStats);
}
Aggregations