Java Code Examples for org.apache.commons.beanutils.PropertyUtilsBean#describe()

The following examples show how to use org.apache.commons.beanutils.PropertyUtilsBean#describe() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CobarNodeInstantPerfValueAjax.java    From tddl5 with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 2
Source File: MClusterListScreen.java    From tddl5 with Apache License 2.0 5 votes vote down vote up
@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));

}
 
Example 3
Source File: MCobarListScreen.java    From tddl5 with Apache License 2.0 5 votes vote down vote up
@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));

}
 
Example 4
Source File: ClusterInstantPerfValueAjax.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
@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);
            jsonRst = JSON.toJSONString(mList);
            break;
        case TYPE_CLUSTER_THROUGHPUT_INFO:
            List<Map<String, Object>> list1 = getClusterThroughput(params);
            jsonRst = JSON.toJSONString(list1);
            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 = JSON.toJSONString(map);
            break;
        case TYPE_STATUS:
            List<Pair<Long, String>> sList = getStatus(params);
            jsonRst = JSON.toJSONString(sList);
            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();
}
 
Example 5
Source File: MVipCobarManager.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
                                                                                                      throws Exception {
    UserDO user = (UserDO) request.getSession().getAttribute("user");
    long vipId = Long.parseLong(request.getParameter("vipIdK"));

    VipDO vip = xmlAccesser.getVipMapDAO().getVipById(vipId);
    PropertyUtilsBean util = new PropertyUtilsBean();

    Set<Long> set = new HashSet<Long>();

    long cobarIds[] = vip.getCobarIds();
    for (int i = 0; i < cobarIds.length; i++) {
        set.add(cobarIds[i]);
    }

    List<CobarDO> cList = xmlAccesser.getCobarDAO().listAllCobar();
    List<Map<String, Object>> cobarList = new ArrayList<Map<String, Object>>();
    for (CobarDO c : cList) {
        Map<String, Object> map;
        try {
            map = util.describe(c);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        map.remove("class");
        map.remove("buId");
        map.remove("user");
        map.remove("password");
        map.remove("time_diff");
        map.remove("name");
        if (set.contains(c.getId())) {
            map.put("choose", true);
        } else {
            map.put("choose", false);
        }
        map.put("name", CobarStringUtil.htmlEscapedString(c.getName()));

        String clusterName = xmlAccesser.getClusterDAO().getClusterById(c.getClusterId()).getName();
        map.put("clusterName", CobarStringUtil.htmlEscapedString(clusterName));
        cobarList.add(map);
    }

    return new ModelAndView("m_vipCobarList", new FluenceHashMap<String, Object>().putKeyValue("user", user)
        .putKeyValue("vip", vip)
        .putKeyValue("cobarList", cobarList));
}
 
Example 6
Source File: CobarListScreen.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
@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().getCobarCountByStatus(clusterId,
    // ConstantDefine.ACTIVE);
    // int iCount =
    // xmlAccesser.getCobarDAO().getCobarCountByStatus(clusterId,
    // ConstantDefine.IN_ACTIVE);
    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()));

        /*
         * if (c.getStatus().equals(ConstantDefine.ACTIVE)) {
         * CobarAdapterDAO perf = cobarAccesser.getAccesser(c); if
         * (!perf.checkConnection()) { cobarMap.remove("status");
         * cobarMap.put("status", ConstantDefine.ERROR); } }
         */
        cobarListMap.add(cobarMap);
    }

    return new ModelAndView("v_cobarList", new FluenceHashMap<String, Object>().putKeyValue("cluster", clusterMap)
        .putKeyValue("cobarList", cobarListMap)
        .putKeyValue("count", count)
        .putKeyValue("user", user));
}
 
Example 7
Source File: CobarDetailScreen.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
@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()));

    /*
     * CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(nodeId);
     * String startTime = null; String version = "UNKNOWN"; String status =
     * "RUNNING"; if (perfAccesser.checkConnection()) { status =
     * perfAccesser.getServerStatus().getStatus(); startTime =
     * perfAccesser.getStartUpTime().getFormatTime(); version =
     * FormatUtil.formatVersion(perfAccesser.getVersion()); } else { status
     * = "ERROR"; }
     */
    return new ModelAndView("v_cobarDetail", new FluenceHashMap<String, Object>().putKeyValue("user", user)
        .putKeyValue("cluster", clusterMap)
        .putKeyValue("cobarNode", cobarMap));
}