use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class CobarDetailScreen method handleRequestInternal.
@SuppressWarnings("unchecked")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
UserDO user = (UserDO) request.getSession().getAttribute("user");
long nodeId = 0;
try {
nodeId = Long.parseLong(request.getParameter("nodeId").trim());
} catch (Exception e) {
throw new IllegalArgumentException("parameter 'nodeId' is invalid: " + request.getParameter("nodeId"));
}
CobarDO cobar = xmlAccesser.getCobarDAO().getCobarById(nodeId);
if (null == cobar) {
throw new IllegalArgumentException("no cobar exsit for id : " + nodeId);
}
PropertyUtilsBean util = new PropertyUtilsBean();
Map<String, Object> cobarMap = null;
try {
cobarMap = util.describe(cobar);
} catch (Exception e1) {
throw new RuntimeException(e1);
}
cobarMap.remove("class");
cobarMap.remove("name");
cobarMap.put("name", CobarStringUtil.htmlEscapedString(cobar.getName()));
ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(cobar.getClusterId());
Map<String, Object> clusterMap = new HashMap<String, Object>();
clusterMap.put("id", cluster.getId());
clusterMap.put("name", CobarStringUtil.htmlEscapedString(cluster.getName()));
return new ModelAndView("v_cobarDetail", new FluenceHashMap<String, Object>().putKeyValue("user", user).putKeyValue("cluster", clusterMap).putKeyValue("cobarNode", cobarMap));
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class CobarListScreen method handleRequestInternal.
@SuppressWarnings({ "unchecked" })
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
UserDO user = (UserDO) request.getSession().getAttribute("user");
long clusterId = Long.parseLong(request.getParameter("clusterId"));
ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId);
List<CobarDO> cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId);
ListSortUtil.sortCobarByName(cobarList);
int aCount = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.ACTIVE).size();
int iCount = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.IN_ACTIVE).size();
Map<String, Integer> count = new HashMap<String, Integer>();
count.put("aCount", aCount);
count.put("iCount", iCount);
count.put("tCount", (aCount + iCount));
PropertyUtilsBean util = new PropertyUtilsBean();
Map<String, Object> clusterMap;
try {
clusterMap = util.describe(cluster);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
clusterMap.remove("class");
clusterMap.remove("name");
clusterMap.remove("deployDesc");
clusterMap.put("name", CobarStringUtil.htmlEscapedString(cluster.getName()));
clusterMap.put("deployDesc", CobarStringUtil.htmlEscapedString(cluster.getDeployDesc()));
List<Map<String, Object>> cobarListMap = new ArrayList<Map<String, Object>>();
for (CobarDO c : cobarList) {
Map<String, Object> cobarMap;
try {
cobarMap = util.describe(c);
} catch (Exception e) {
throw new RuntimeException(e);
}
cobarMap.remove("class");
cobarMap.remove("name");
cobarMap.put("name", CobarStringUtil.htmlEscapedString(c.getName()));
cobarListMap.add(cobarMap);
}
return new ModelAndView("v_cobarList", new FluenceHashMap<String, Object>().putKeyValue("cluster", clusterMap).putKeyValue("cobarList", cobarListMap).putKeyValue("count", count).putKeyValue("user", user));
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class ConnectionControlScreen method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
UserDO user = (UserDO) request.getSession().getAttribute("user");
String id = request.getParameter("clusterId");
long clusterId = -1;
if (null != id) {
clusterId = Long.parseLong(id);
}
String cobarNodeId = request.getParameter("cobarNodeId");
long cobarId = -1;
if (null != cobarNodeId) {
cobarId = Long.parseLong(cobarNodeId);
}
List<ClusterDO> cList = xmlAccesser.getClusterDAO().listAllCluster();
List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
ListSortUtil.sortClusterByName(cList);
for (ClusterDO e : cList) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", e.getId());
map.put("name", CobarStringUtil.htmlEscapedString(e.getName()));
clusterList.add(map);
}
List<CobarDO> cobarList = null;
if (null != cList && cList.size() > 0) {
if (-1 == clusterId) {
clusterId = cList.get(0).getId();
cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.ACTIVE);
} else {
cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.ACTIVE);
}
}
List<Map<String, Object>> cobarViewList = null;
if (null != cobarList && cobarList.size() > 0) {
ListSortUtil.sortCobarByName(cobarList);
cobarViewList = new ArrayList<Map<String, Object>>();
for (CobarDO c : cobarList) {
CobarAdapterDAO perf = cobarAccesser.getAccesser(c.getId());
if (perf.checkConnection()) {
Map<String, Object> cobarMap = new HashMap<String, Object>();
cobarMap.put("id", c.getId());
cobarMap.put("name", CobarStringUtil.htmlEscapedString(c.getName()));
cobarViewList.add(cobarMap);
}
}
}
/* cobarId=-2, cobar InActive; cobarId=-3, connection error */
List<ConnectionStatus> connecList = null;
if (cobarId > 0) {
CobarDO cobar = xmlAccesser.getCobarDAO().getCobarById(cobarId);
if (cobar.getStatus().equals(ConstantDefine.ACTIVE)) {
CobarAdapterDAO perf = cobarAccesser.getAccesser(cobarId);
if (!perf.checkConnection()) {
cobarId = -3;
} else {
connecList = perf.listConnectionStatus();
}
} else {
cobarId = -2;
}
}
List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
if (null != connecList) {
ListSortUtil.sortConnections(connecList);
for (ConnectionStatus c : connecList) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("processor", c.getProcessor());
map.put("id", c.getId());
map.put("host", c.getHost());
map.put("port", c.getPort());
map.put("local_port", c.getLocal_port());
map.put("schema", c.getSchema());
map.put("charset", c.getCharset());
map.put("netIn", FormatUtil.formatStore(c.getNetIn()));
map.put("netOut", FormatUtil.formatStore(c.getNetOut()));
map.put("aliveTime", FormatUtil.formatTime(c.getAliveTime() * 1000, 2));
map.put("attempsCount", FormatUtil.formatNumber(c.getAttempsCount()));
map.put("recvBuffer", FormatUtil.formatStore(c.getRecvBuffer()));
map.put("sendQueue", c.getSendQueue());
map.put("channel", c.getChannel());
returnList.add(map);
}
}
return new ModelAndView("c_connection", new FluenceHashMap<String, Object>().putKeyValue("cList", clusterList).putKeyValue("cobarList", cobarViewList).putKeyValue("clusterId", clusterId).putKeyValue("cobarId", cobarId).putKeyValue("connecList", returnList).putKeyValue("user", user));
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class AddCluster method onSubmit.
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
ClusterForm form = (ClusterForm) command;
ClusterDO cluster = new ClusterDO();
cluster.setDeployContact(form.getDeployName().trim());
cluster.setDeployDesc(form.getDeployDesc().trim());
cluster.setMaintContact(form.getMaintName().trim());
cluster.setName(form.getClusterName().trim());
cluster.setOnlineTime(form.getOnlineTime().trim());
cluster.setSortId(form.getSortId());
boolean flag = this.xmlAccesser.getClusterDAO().addCluster(cluster);
if (flag) {
return new ModelAndView("m_success", "info", "add cluster success");
} else {
String reason = form.getClusterName() + "add cluster fail";
return new ModelAndView("failure", "reason", reason);
}
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class ModifyCluster method onSubmit.
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
ClusterForm form = (ClusterForm) command;
ClusterDO cluster = new ClusterDO();
cluster.setId(form.getClusterId());
cluster.setDeployContact(form.getDeployName().trim());
cluster.setDeployDesc(form.getDeployDesc().trim());
cluster.setMaintContact(form.getMaintName().trim());
cluster.setName(form.getClusterName().trim());
cluster.setOnlineTime(form.getOnlineTime().trim());
cluster.setSortId(form.getSortId());
boolean flag = this.xmlAccesser.getClusterDAO().modifyCluster(cluster);
if (flag) {
return new ModelAndView("m_success", "info", "modify success");
} else {
String reason = form.getClusterName() + " exist";
return new ModelAndView("failure", "reason", reason);
}
}
Aggregations