List of usage examples for org.apache.commons.beanutils PropertyUtilsBean describe
public Map describe(Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Return the entire set of properties for which the specified bean provides a read method.
From source file:com.alibaba.cobar.manager.web.screen.MCobarListScreen.java
@SuppressWarnings({ "unchecked" })
@Override//from ww w. jav a2 s.c o m
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));
}
From source file:com.alibaba.cobar.manager.web.screen.CobarDetailScreen.java
@SuppressWarnings("unchecked") @Override/*from ww w .jav a 2 s .com*/ 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)); }
From source file:com.alibaba.cobar.manager.web.screen.CobarListScreen.java
@SuppressWarnings({ "unchecked" })
@Override// w w w .j a va 2 s. co m
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));
}
From source file:com.alibaba.cobar.manager.web.screen.MClusterListScreen.java
@SuppressWarnings("unchecked") @Override// w w w . j av a 2s.c om protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { UserDO user = (UserDO) request.getSession().getAttribute("user"); List<ClusterDO> list = xmlAccesser.getClusterDAO().listAllCluster(); List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>(); ListSortUtil.sortClusterBySortId(list); PropertyUtilsBean util = new PropertyUtilsBean(); for (ClusterDO e : list) { int count = xmlAccesser.getCobarDAO().getCobarList(e.getId(), ConstantDefine.ACTIVE).size(); count += xmlAccesser.getCobarDAO().getCobarList(e.getId(), ConstantDefine.IN_ACTIVE).size(); Map<String, Object> map; try { map = util.describe(e); } catch (Exception ex) { throw new RuntimeException(ex); } map.remove("class"); map.remove("name"); map.remove("deployDesc"); map.put("name", CobarStringUtil.htmlEscapedString(e.getName())); map.put("deployContact", CobarStringUtil.htmlEscapedString(e.getDeployContact())); map.put("cobarNum", count); clusterList.add(map); } return new ModelAndView("m_clusterList", new FluenceHashMap<String, Object>() .putKeyValue("clusterList", clusterList).putKeyValue("user", user)); }
From source file:com.alibaba.cobar.manager.web.screen.PropertyReloadScreen.java
@SuppressWarnings("unchecked") @Override//from w w w . j a va 2s .c o m 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); } 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); } else { cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId); } } List<Map<String, Object>> cobarListMap = new ArrayList<Map<String, Object>>(); PropertyUtilsBean util = new PropertyUtilsBean(); if (null != cobarList) { ListSortUtil.sortCobarByName(cobarList); for (CobarDO c : cobarList) { CobarAdapterDAO perf = cobarAccesser.getAccesser(c.getId()); Map<String, Object> map; try { map = util.describe(c); } catch (Exception ex) { throw new RuntimeException(ex); } map.remove("class"); map.remove("name"); map.put("name", CobarStringUtil.htmlEscapedString(c.getName())); if (ConstantDefine.ACTIVE.equals(c.getStatus())) { if (!perf.checkConnection()) { map.remove("status"); map.put("status", ConstantDefine.ERROR); map.put("reloadTime", ""); map.put("rollbackTime", ""); } else { ServerStatus ss = perf.getServerStatus(); String rollbackTime = "NO"; String reloadTime = FormatUtil.fromMilliseconds2String(ss.getReloadTime()); if (ss.getRollbackTime() != -1) { rollbackTime = FormatUtil.fromMilliseconds2String(ss.getRollbackTime()); } map.put("reloadTime", reloadTime); map.put("rollbackTime", rollbackTime); } } else { map.put("reloadTime", ""); map.put("rollbackTime", ""); } cobarListMap.add(map); } } return new ModelAndView("c_propertyReload", new FluenceHashMap<String, Object>().putKeyValue("cList", clusterList) .putKeyValue("cobarList", cobarListMap).putKeyValue("clusterId", clusterId) .putKeyValue("user", user)); }
From source file:com.alibaba.cobar.manager.web.ajax.CobarNodeInstantPerfValueAjax.java
@SuppressWarnings({ "unchecked" })
private List<Map<String, Object>> listDatanode(AjaxParams params) {
CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(params.getCobarNodeId());
if (!perfAccesser.checkConnection()) {
return null;
}/*from www. j ava2 s . co m*/
PropertyUtilsBean util = new PropertyUtilsBean();
List<DataNodesStatus> list = perfAccesser.listDataNodes();
;
if (null != list) {
ListSortUtil.sortDataNodesByPoolName(list);
}
List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
for (DataNodesStatus c : list) {
Map<String, Object> map = null;
try {
map = util.describe(c);
} catch (Exception e1) {
throw new RuntimeException(e1);
}
map.remove("class");
map.remove("executeCount");
map.put("executeCount", FormatUtil.formatNumber(c.getExecuteCount()));
map.remove("recoveryTime");
if (-1 != c.getRecoveryTime()) {
map.put("recoveryTime", FormatUtil.formatTime(c.getRecoveryTime() * 1000, 2));
} else {
map.put("recoveryTime", c.getRecoveryTime());
}
returnList.add(map);
}
return returnList;
}
From source file:com.alibaba.cobar.manager.web.ajax.ClusterInstantPerfValueAjax.java
@SuppressWarnings("unchecked") @Override//from w w w . j a v a 2s . co m public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { AjaxParams params = new AjaxParams(request); String jsonRst = null; String st = params.getValueType(); if (null == st || st.equals("")) { throw new IllegalArgumentException("parameter 'cobarControlValueType' is unknown: " + st); } int type = valueTypeMap.get(st); PropertyUtilsBean util = new PropertyUtilsBean(); switch (type) { case TYPE_COBAR_MEMORY_USAGE: List<Pair<Long, Integer>> mList = listCobarMemoryUsage(params); JSONArray mArray = JSONArray.fromObject(mList); jsonRst = mArray.toString(2); break; case TYPE_CLUSTER_THROUGHPUT_INFO: List<Map<String, Object>> list1 = getClusterThroughput(params); JSONArray arrayMap = JSONArray.fromObject(list1); jsonRst = arrayMap.toString(2); break; case TYPE_CLUSTER_INFO: AjaxResult rs = getClusterInfo(params); Map<String, Object> map = null; try { map = util.describe(rs); } catch (Exception e) { logger.error(e); throw new RuntimeException(e); } jsonRst = JSONObject.fromObject(map).toString(2); break; case TYPE_STATUS: List<Pair<Long, String>> sList = getStatus(params); JSONArray sArray = JSONArray.fromObject(sList); jsonRst = sArray.toString(2); break; default: throw new IllegalArgumentException("parameter 'ValueType' is known: " + params.getValueType()); } response.setHeader("Content-Type", "text/json; charset=utf-8"); OutputStream out = response.getOutputStream(); out.write(jsonRst.getBytes("utf-8")); out.flush(); }
From source file:com.alibaba.cobar.manager.web.ajax.ClusterInstantPerfValueAjax.java
@SuppressWarnings("unchecked") private List<Map<String, Object>> getClusterThroughput(AjaxParams params) { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); JSONArray array = params.getArray(); JSONObject json = null;/* www . ja v a 2s. c om*/ Map<Long, JSONObject> cobarRequest = new HashMap<Long, JSONObject>(); for (int i = 0; i < array.size(); i++) { JSONObject js = array.getJSONObject(i); if ("cluster".equals(js.getString("flag"))) { json = js; } else if ("cobar".equals(js.getString("flag"))) { cobarRequest.put(js.getLong("id"), js); } } PropertyUtilsBean util = new PropertyUtilsBean(); long clusterId = params.getClusterId(); List<CobarDO> nodes = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.ACTIVE); AjaxResult cluster = new AjaxResult(); cluster.setId(clusterId); cluster.setFlag("cluster"); long timestamp = 0; for (CobarDO node : nodes) { CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(node.getId()); if (!perfAccesser.checkConnection()) { StringBuilder sb = new StringBuilder("getClusterThroughput: cobar connect error for Name:"); sb.append(node.getName()).append(" Host:").append(node.getHost()); logger.error(sb.toString()); continue; } AjaxResult re = new AjaxResult(); List<ProcessorStatus> list = perfAccesser.listProccessorStatus(); List<CommandStatus> cmdList = perfAccesser.listCommandStatus(); long cobarNetIn = groupByPList(list, NET_IN); long cobarNetOut = groupByPList(list, NET_OUT); long cobarRequestCount = groupByCList(cmdList, REQUEST_COUNT); cluster.addRequest(cobarRequestCount); cluster.addNetIn(cobarNetIn); cluster.addNetOut(cobarNetOut); re.setId(node.getId()); re.setFlag("cobar"); re.setNetIn(cobarNetIn); re.setNetOut(cobarNetOut); re.setConnection(groupByPList(list, CONNECTION)); re.setRequest(cobarRequestCount); timestamp = list.get(list.size() - 1).getSampleTimeStamp(); re.setTimestamp(timestamp); JSONObject jsonTmp = cobarRequest.get(node.getId()); if (jsonTmp != null) { re.setNetIn_deriv(FormatUtil.formatNetwork(Math.round(MathUtil.getDerivate(cobarNetIn, jsonTmp.getLong("netIn"), timestamp, jsonTmp.getLong("timestamp"), 1000.0)))); re.setNetOut_deriv(FormatUtil.formatNetwork(Math.round(MathUtil.getDerivate(cobarNetOut, jsonTmp.getLong("netOut"), timestamp, jsonTmp.getLong("timestamp"), 1000.0)))); re.setRequest_deriv(FormatUtil.formatNumber(Math.round(MathUtil.getDerivate(cobarRequestCount, jsonTmp.getLong("reCount"), timestamp, jsonTmp.getLong("timestamp"), 1000.0)))); } Map<String, Object> map = null; try { map = util.describe(re); } catch (Exception e) { logger.error(e); throw new RuntimeException(e); } if (null != map) { result.add(map); } } cluster.setTimestamp(timestamp); if (null != json && json.getLong("netIn") != -1) { long o_tiemstamp = json.getLong("timestamp"); cluster.setNetIn_deriv(FormatUtil.formatNetwork(Math.round(MathUtil.getDerivate(cluster.getNetIn(), json.getLong("netIn"), timestamp, o_tiemstamp, 1000.0)))); cluster.setNetOut_deriv(FormatUtil.formatNetwork(Math.round(MathUtil.getDerivate(cluster.getNetOut(), json.getLong("netOut"), timestamp, o_tiemstamp, 1000.0)))); cluster.setRequest_deriv(FormatUtil.formatNumber(Math.round(MathUtil.getDerivate(cluster.getRequest(), json.getLong("reCount"), timestamp, o_tiemstamp, 1000.0)))); } Map<String, Object> m = null; try { m = util.describe(cluster); } catch (Exception e) { logger.error(e); throw new RuntimeException(e); } if (null != m) { result.add(m); } return result; }
From source file:org.opentestsystem.authoring.testauth.service.impl.TenantEnforcementServiceImpl.java
@Override public Set<String> findAssociatedAssessmentIds(final Object verifyMe) { Set<String> assessmentIds = new HashSet<String>(); if (verifyMe != null) { if (verifyMe instanceof Collection) { Collection<?> collection = (Collection<?>) verifyMe; if (collection.size() > 0 && collection.iterator().next() instanceof TenantedByAssessment) { for (Object obj : collection) { assessmentIds.addAll(findAssociatedAssessmentIds(obj)); }// w w w .j a v a2s . c o m } } else { if (verifyMe instanceof TenantedByAssessment) { TenantedByAssessment obj = (TenantedByAssessment) verifyMe; assessmentIds.add(obj.getAssessmentId()); } PropertyUtilsBean pub = new PropertyUtilsBean(); try { Map<String, Object> properties = pub.describe(verifyMe); for (Entry<String, Object> entry : properties.entrySet()) { if (entry.getValue() != null && !(entry.getValue() instanceof Class)) { assessmentIds.addAll(findAssociatedAssessmentIds(entry.getValue())); } } } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e2) { //at this point if a bad thing happens due to reflection, that's ok...swallow the exceptins. } } } return assessmentIds; }
From source file:org.seasar.struts.bean.SuppressPropertyUtilsBeanTest.java
public void testDescribe() throws Exception { List classes = new ArrayList(); classes.add(FullName.class); PropertyUtilsBean propertyUtils = new SuppressPropertyUtilsBean(classes); Person person = new Person(); Map properties = propertyUtils.describe(person); assertEquals(3, properties.size());/*from ww w .j a v a 2s . c o m*/ assertTrue(properties.containsKey("address")); assertTrue(properties.containsKey("age")); assertTrue(properties.containsKey("fullName")); }