use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class ClusterInstantPerfValueAjax method listCobarMemoryUsage.
private List<Pair<Long, Integer>> listCobarMemoryUsage(AjaxParams params) {
List<Pair<Long, Integer>> result = new ArrayList<Pair<Long, Integer>>();
List<CobarDO> nodes = xmlAccesser.getCobarDAO().getCobarList(params.getClusterId(), ConstantDefine.ACTIVE);
for (CobarDO node : nodes) {
CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(node.getId());
if (!perfAccesser.checkConnection()) {
StringBuilder sb = new StringBuilder("listCobarMemoryUsage: cobar connect error for Name:");
sb.append(node.getName()).append(" Host:").append(node.getHost());
logger.error(sb.toString());
continue;
}
ServerStatus ss = perfAccesser.getServerStatus();
int memoryUsage = 0;
if (ss.getTotalMemory() != 0)
memoryUsage = Math.round(ss.getUsedMemory() * 100 / ss.getTotalMemory());
result.add(new Pair<Long, Integer>(node.getId(), memoryUsage));
}
return result;
}
use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class CobarControlAjax method killConnections.
private boolean killConnections(AjaxParams params) {
long cobarId = params.getCobarNodeId();
long connecId = params.getConnectionId();
CobarDO cobar = xmlAccesser.getCobarDAO().getCobarById(cobarId);
if (!cobar.getStatus().equals(ConstantDefine.ACTIVE)) {
return false;
}
CobarAdapterDAO control = cobarAccesser.getAccesser(cobarId);
if (control.checkConnection()) {
control.killConnection(connecId);
return true;
}
return false;
}
use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class CobarControlAjax method getCobarList.
private List<Map<String, Object>> getCobarList(AjaxParams params) {
long clusterId = params.getClusterId();
List<CobarDO> cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.ACTIVE);
ListSortUtil.sortCobarByName(cobarList);
List<Map<String, Object>> 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", c.getName());
cobarViewList.add(cobarMap);
}
}
return cobarViewList;
}
use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class CobarAccesser method getAccesser.
public CobarAdapterDAO getAccesser(long cobarId) {
final CobarDO cobar = xmlAccesser.getCobarDAO().getCobarById(cobarId);
if (cobar == null) {
logger.error(new StringBuilder("Fail to get cobar information which id = ").append(cobarId).toString());
}
CobarAdapterDAO accesser = cobarAdapterDelegate.getCobarNodeAccesser(cobar.getHost(), cobar.getPort(), cobar.getUser(), cobar.getPassword());
return accesser;
}
use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class MCobarListScreen 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);
List<Map<String, Object>> cobarViewList = null;
if (null != cobarList) {
ListSortUtil.sortCobarByName(cobarList);
cobarViewList = new ArrayList<Map<String, Object>>();
PropertyUtilsBean util = new PropertyUtilsBean();
for (CobarDO c : cobarList) {
Map<String, Object> map = util.describe(c);
map.remove("class");
map.remove("name");
map.put("name", CobarStringUtil.htmlEscapedString(c.getName()));
cobarViewList.add(map);
}
}
Map<String, Object> clusterView = new HashMap<String, Object>();
clusterView.put("id", cluster.getId());
clusterView.put("name", CobarStringUtil.htmlEscapedString(cluster.getName()));
return new ModelAndView("m_cobarList", new FluenceHashMap<String, Object>().putKeyValue("cobarList", cobarViewList).putKeyValue("user", user).putKeyValue("cluster", clusterView));
}
Aggregations