use of org.apache.commons.beanutils.PropertyUtilsBean in project cobar by alibaba.
the class MClusterListScreen method handleRequestInternal.
@SuppressWarnings("unchecked")
@Override
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));
}
use of org.apache.commons.beanutils.PropertyUtilsBean in project checkstyle by checkstyle.
the class AutomaticBean method createBeanUtilsBean.
/**
* Creates a BeanUtilsBean that is configured to use
* type converters that throw a ConversionException
* instead of using the default value when something
* goes wrong.
*
* @return a configured BeanUtilsBean
*/
private static BeanUtilsBean createBeanUtilsBean() {
final ConvertUtilsBean cub = new ConvertUtilsBean();
registerIntegralTypes(cub);
registerCustomTypes(cub);
return new BeanUtilsBean(cub, new PropertyUtilsBean());
}
use of org.apache.commons.beanutils.PropertyUtilsBean in project databus by linkedin.
the class ConfigLoader method fillPropertyFromList.
private void fillPropertyFromList(Object bean, String propName, List<?> values) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
PropertyUtilsBean propUtils = _beanUtilsBean.getPropertyUtils();
int idx = 0;
for (Object elem : values) {
if (elem instanceof Map<?, ?>) {
Object subBean = propUtils.getIndexedProperty(bean, propName, idx);
fillBeanFromMap(subBean, (Map<?, ?>) elem);
} else {
propUtils.setIndexedProperty(bean, propName, idx, elem);
}
++idx;
}
}
use of org.apache.commons.beanutils.PropertyUtilsBean in project cobar by alibaba.
the class CobarNodeInstantPerfValueAjax method listDatanode.
@SuppressWarnings({ "unchecked" })
private List<Map<String, Object>> listDatanode(AjaxParams params) {
CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(params.getCobarNodeId());
if (!perfAccesser.checkConnection()) {
return null;
}
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;
}
use of org.apache.commons.beanutils.PropertyUtilsBean in project cobar by alibaba.
the class ClusterInstantPerfValueAjax method handleRequest.
@SuppressWarnings("unchecked")
@Override
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();
}
Aggregations