Search in sources :

Example 11 with ClusterDO

use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.

the class EditCobarPage method handleRequestInternal.

@SuppressWarnings("unchecked")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    long cobarId = 0;
    try {
        cobarId = Long.parseLong(request.getParameter("cobarId").trim());
    } catch (Exception e) {
        throw new IllegalArgumentException("parameter 'cobarId' is invalid:" + request.getParameter("cobarId"));
    }
    CobarDO cobar = xmlAccesser.getCobarDAO().getCobarById(cobarId);
    Map<String, Object> cobarMap = new PropertyUtilsBean().describe(cobar);
    cobarMap.remove("class");
    cobarMap.remove("name");
    cobarMap.put("name", CobarStringUtil.htmlEscapedString(cobar.getName()));
    List<ClusterDO> cList = xmlAccesser.getClusterDAO().listAllCluster();
    List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
    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);
    }
    return new ModelAndView("m_editCobar", new FluenceHashMap<String, Object>().putKeyValue("cluList", clusterList).putKeyValue("cobar", cobarMap));
}
Also used : PropertyUtilsBean(org.apache.commons.beanutils.PropertyUtilsBean) HashMap(java.util.HashMap) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap) 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) HashMap(java.util.HashMap) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap) Map(java.util.Map)

Example 12 with ClusterDO

use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.

the class Index method handleRequestInternal.

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<ClusterDO> list = xmlAccesser.getClusterDAO().listAllCluster();
    List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
    ListSortUtil.sortClusterBySortId(list);
    for (ClusterDO e : list) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", e.getId());
        map.put("name", CobarStringUtil.htmlEscapedString(e.getName()));
        map.put("maintContact", e.getMaintContact());
        map.put("onlineTime", e.getOnlineTime());
        clusterList.add(map);
    }
    String result = null;
    try {
        result = request.getParameter("result").trim();
    } catch (NullPointerException e) {
        result = "null";
    }
    if (result == null) {
        result = "null";
    }
    //remove attributes for login
    if (null != request.getSession(false)) {
        request.getSession().removeAttribute("click");
        request.getSession().removeAttribute("lastRequest");
    }
    return new ModelAndView("index", new FluenceHashMap<String, Object>().putKeyValue("clusterList", clusterList).putKeyValue("result", result));
}
Also used : ClusterDO(com.alibaba.cobar.manager.dataobject.xml.ClusterDO) HashMap(java.util.HashMap) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) HashMap(java.util.HashMap) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap) Map(java.util.Map)

Example 13 with ClusterDO

use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO 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 14 with ClusterDO

use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.

the class ClusterDaoTest method testAddFristCluster.

@Test
public void testAddFristCluster() {
    long testId = 1L;
    ClusterDO clusterTemp = clusterDao.getClusterById(testId);
    Assert.assertNull(clusterTemp);
    ClusterDO cluster = DOFactory.getCluster();
    clusterDao.addCluster(cluster);
    Assert.assertNotNull(clusterDao.getClusterById(testId));
    Assert.assertSame(cluster, clusterDao.getClusterById(testId));
    read();
    Assert.assertNotNull(clusterDao.getClusterById(testId));
}
Also used : ClusterDO(com.alibaba.cobar.manager.dataobject.xml.ClusterDO) Test(org.junit.Test)

Example 15 with ClusterDO

use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.

the class ClusterDaoTest method testAddManyCluster.

@Test
public void testAddManyCluster() {
    int insertClusterNum = 3;
    for (int i = 0; i < insertClusterNum; i++) {
        ClusterDO cluster = DOFactory.getCluster();
        cluster.setName("test" + i);
        clusterDao.addCluster(cluster);
    }
    read();
    List<ClusterDO> activeClusterList = clusterDao.listAllCluster();
    Assert.assertEquals(insertClusterNum, activeClusterList.size());
}
Also used : ClusterDO(com.alibaba.cobar.manager.dataobject.xml.ClusterDO) Test(org.junit.Test)

Aggregations

ClusterDO (com.alibaba.cobar.manager.dataobject.xml.ClusterDO)30 ModelAndView (org.springframework.web.servlet.ModelAndView)16 HashMap (java.util.HashMap)15 Map (java.util.Map)15 FluenceHashMap (com.alibaba.cobar.manager.util.FluenceHashMap)12 UserDO (com.alibaba.cobar.manager.dataobject.xml.UserDO)11 ArrayList (java.util.ArrayList)11 CobarDO (com.alibaba.cobar.manager.dataobject.xml.CobarDO)9 PropertyUtilsBean (org.apache.commons.beanutils.PropertyUtilsBean)7 Test (org.junit.Test)7 CobarAdapterDAO (com.alibaba.cobar.manager.dao.CobarAdapterDAO)5 IOException (java.io.IOException)5 Iterator (java.util.Iterator)3 Entry (java.util.Map.Entry)3 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)2 ClusterDAOImple (com.alibaba.cobar.manager.dao.xml.ClusterDAOImple)1 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 FileInputStream (java.io.FileInputStream)1