Search in sources :

Example 6 with PropertyUtilsBean

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));
}
Also used : PropertyUtilsBean(org.apache.commons.beanutils.PropertyUtilsBean) UserDO(com.alibaba.cobar.manager.dataobject.xml.UserDO) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ClusterDO(com.alibaba.cobar.manager.dataobject.xml.ClusterDO) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap) Map(java.util.Map)

Example 7 with PropertyUtilsBean

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());
}
Also used : BeanUtilsBean(org.apache.commons.beanutils.BeanUtilsBean) PropertyUtilsBean(org.apache.commons.beanutils.PropertyUtilsBean) ConvertUtilsBean(org.apache.commons.beanutils.ConvertUtilsBean)

Example 8 with 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;
    }
}
Also used : PropertyUtilsBean(org.apache.commons.beanutils.PropertyUtilsBean) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with PropertyUtilsBean

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;
}
Also used : CobarAdapterDAO(com.alibaba.cobar.manager.dao.CobarAdapterDAO) DataNodesStatus(com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus) PropertyUtilsBean(org.apache.commons.beanutils.PropertyUtilsBean) ArrayList(java.util.ArrayList) JSONObject(net.sf.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 10 with PropertyUtilsBean

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();
}
Also used : PropertyUtilsBean(org.apache.commons.beanutils.PropertyUtilsBean) OutputStream(java.io.OutputStream) JSONArray(net.sf.json.JSONArray) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) JSONObject(net.sf.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) Pair(com.alibaba.cobar.manager.util.Pair)

Aggregations

PropertyUtilsBean (org.apache.commons.beanutils.PropertyUtilsBean)14 HashMap (java.util.HashMap)10 Map (java.util.Map)10 ClusterDO (com.alibaba.cobar.manager.dataobject.xml.ClusterDO)7 FluenceHashMap (com.alibaba.cobar.manager.util.FluenceHashMap)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7 CobarDO (com.alibaba.cobar.manager.dataobject.xml.CobarDO)6 ArrayList (java.util.ArrayList)6 UserDO (com.alibaba.cobar.manager.dataobject.xml.UserDO)5 CobarAdapterDAO (com.alibaba.cobar.manager.dao.CobarAdapterDAO)3 IOException (java.io.IOException)3 ServletException (javax.servlet.ServletException)3 JSONObject (net.sf.json.JSONObject)3 JSONArray (net.sf.json.JSONArray)2 BeanUtilsBean (org.apache.commons.beanutils.BeanUtilsBean)2 CommandStatus (com.alibaba.cobar.manager.dataobject.cobarnode.CommandStatus)1 DataNodesStatus (com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus)1 ProcessorStatus (com.alibaba.cobar.manager.dataobject.cobarnode.ProcessorStatus)1 ServerStatus (com.alibaba.cobar.manager.dataobject.cobarnode.ServerStatus)1 Pair (com.alibaba.cobar.manager.util.Pair)1