Search in sources :

Example 11 with FluenceHashMap

use of com.alibaba.cobar.manager.util.FluenceHashMap in project cobar by alibaba.

the class EditUserPage method handleRequestInternal.

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    long userId = 0;
    try {
        userId = Long.parseLong(request.getParameter("userId").trim());
    } catch (Exception e) {
        throw new IllegalArgumentException("parameter 'userId' is invalid:" + request.getParameter("cobarId"));
    }
    UserDO editUser = xmlAccesser.getUserDAO().getUserById(userId);
    UserDO u = new UserDO();
    u.setId(editUser.getId());
    u.setPassword(EncryptUtil.decrypt(editUser.getPassword()));
    u.setRealname(editUser.getRealname());
    u.setStatus(editUser.getStatus());
    u.setUser_role(editUser.getUser_role());
    u.setUsername(editUser.getUsername());
    return new ModelAndView("m_editUser", new FluenceHashMap<String, Object>().putKeyValue("editUser", u));
}
Also used : UserDO(com.alibaba.cobar.manager.dataobject.xml.UserDO) ModelAndView(org.springframework.web.servlet.ModelAndView) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap)

Example 12 with FluenceHashMap

use of com.alibaba.cobar.manager.util.FluenceHashMap in project cobar by alibaba.

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

Example 13 with FluenceHashMap

use of com.alibaba.cobar.manager.util.FluenceHashMap in project cobar by alibaba.

the class PropertyReloadScreen method handleRequestInternal.

@SuppressWarnings("unchecked")
@Override
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));
}
Also used : CobarAdapterDAO(com.alibaba.cobar.manager.dao.CobarAdapterDAO) HashMap(java.util.HashMap) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap) PropertyUtilsBean(org.apache.commons.beanutils.PropertyUtilsBean) UserDO(com.alibaba.cobar.manager.dataobject.xml.UserDO) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) CobarDO(com.alibaba.cobar.manager.dataobject.xml.CobarDO) ClusterDO(com.alibaba.cobar.manager.dataobject.xml.ClusterDO) ServerStatus(com.alibaba.cobar.manager.dataobject.cobarnode.ServerStatus) HashMap(java.util.HashMap) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap) Map(java.util.Map)

Aggregations

FluenceHashMap (com.alibaba.cobar.manager.util.FluenceHashMap)13 ModelAndView (org.springframework.web.servlet.ModelAndView)13 ClusterDO (com.alibaba.cobar.manager.dataobject.xml.ClusterDO)12 UserDO (com.alibaba.cobar.manager.dataobject.xml.UserDO)10 HashMap (java.util.HashMap)10 Map (java.util.Map)10 ArrayList (java.util.ArrayList)9 CobarDO (com.alibaba.cobar.manager.dataobject.xml.CobarDO)7 PropertyUtilsBean (org.apache.commons.beanutils.PropertyUtilsBean)7 CobarAdapterDAO (com.alibaba.cobar.manager.dao.CobarAdapterDAO)3 ConnectionStatus (com.alibaba.cobar.manager.dataobject.cobarnode.ConnectionStatus)1 DataNodesStatus (com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus)1 ServerStatus (com.alibaba.cobar.manager.dataobject.cobarnode.ServerStatus)1 List (java.util.List)1