use of com.alibaba.cobar.manager.dataobject.xml.UserDO in project cobar by alibaba.
the class StopHeartbeat method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
UserDO user = (UserDO) request.getSession().getAttribute("user");
String datanodes = request.getParameter("datanodes");
int time = Integer.parseInt(request.getParameter("stoptime"));
long clusterId = Long.parseLong(request.getParameter("clusterIdK"));
ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId);
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
if (logger.isWarnEnabled()) {
StringBuilder log = new StringBuilder();
log.append(user.getUsername()).append(" | stop heartbeat | cluster:");
log.append(cluster.getName()).append(" | ");
log.append(datanodes).append(" | time:");
log.append(time);
logger.warn(log.toString());
}
List<CobarDO> cobarList = null;
lock.lock();
try {
cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.ACTIVE);
for (CobarDO c : cobarList) {
CobarAdapterDAO control = cobarAccesser.getAccesser(c.getId());
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", CobarStringUtil.htmlEscapedString(c.getName()));
if (control.checkConnection()) {
int num = control.stopHeartbeat(datanodes, time);
map.put("result", num + " rows");
} else {
map.put("result", "connction error!");
}
resultList.add(map);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "UNKNOWN ERROR");
map.put("result", "unknown exception occurs when stopping heartbeat");
resultList.clear();
resultList.add(map);
} finally {
lock.unlock();
}
return new ModelAndView("c_result", "resultList", resultList);
}
use of com.alibaba.cobar.manager.dataobject.xml.UserDO in project cobar by alibaba.
the class SwitchDatanodes method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String datanodes = request.getParameter("datanodes");
int index = Integer.parseInt(request.getParameter("index"));
long clusterId = Long.parseLong(request.getParameter("clusterIdK"));
UserDO user = (UserDO) request.getSession().getAttribute("user");
ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId);
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
List<CobarDO> cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.ACTIVE);
if (logger.isWarnEnabled()) {
StringBuilder log = new StringBuilder();
log.append(user.getUsername()).append(" | switch datanodes | cluster:");
log.append(cluster.getName()).append(" | ");
log.append(datanodes).append(" | index:");
log.append(index);
logger.warn(log.toString());
}
lock.lock();
try {
for (CobarDO c : cobarList) {
CobarAdapterDAO control = cobarAccesser.getAccesser(c.getId());
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", CobarStringUtil.htmlEscapedString(c.getName()));
if (control.checkConnection()) {
int num = control.switchDataNode(datanodes, index);
map.put("result", num + " rows");
} else {
map.put("result", "connction error!");
}
resultList.add(map);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "UNKNOWN ERROR");
map.put("result", "unknown exception occurs when switching");
resultList.clear();
resultList.add(map);
} finally {
lock.unlock();
}
return new ModelAndView("c_result", "resultList", resultList);
}
use of com.alibaba.cobar.manager.dataobject.xml.UserDO in project cobar by alibaba.
the class ClusterListScreen method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
UserDO user = (UserDO) request.getSession().getAttribute("user");
List<ClusterDO> list = xmlAccesser.getClusterDAO().listAllCluster();
ListSortUtil.sortClusterBySortId(list);
List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
for (ClusterDO e : list) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", e.getId());
map.put("name", CobarStringUtil.htmlEscapedString(e.getName()));
map.put("maintContact", e.getMaintContact());
map.put("onlineTime", e.getOnlineTime());
clusterList.add(map);
}
return new ModelAndView("v_clusterList", new FluenceHashMap<String, Object>().putKeyValue("clusterList", clusterList).putKeyValue("user", user));
}
use of com.alibaba.cobar.manager.dataobject.xml.UserDO 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.UserDO 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));
}
Aggregations