Search in sources :

Example 31 with CobarDO

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

the class CobarDaoTest method testAddManyCobar.

@Test
public void testAddManyCobar() {
    int cobarNum = 10;
    for (int i = 0; i < cobarNum; i++) {
        CobarDO cobar = DOFactory.getCobar();
        cobar.setName("" + i);
        cobarDao.addCobar(cobar);
    }
    //        int activeCobarNum = cobarDao.getCobarCountByStatus(1L, ConstantDefine.ACTIVE);
    int activeCobarNum = cobarDao.getCobarList(1L).size();
    Assert.assertEquals(cobarNum, activeCobarNum);
}
Also used : CobarDO(com.alibaba.cobar.manager.dataobject.xml.CobarDO) Test(org.junit.Test)

Example 32 with CobarDO

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

the class CobarDaoTest method testGetCobarList.

@Test
public void testGetCobarList() {
    long testClusterId = 1L;
    int testCobarNum = 3;
    int otherCobarNum = 4;
    for (int i = 0; i < testCobarNum; i++) {
        CobarDO cobar = DOFactory.getCobar();
        cobar.setName("test" + i);
        cobar.setClusterId(testClusterId);
        cobarDao.addCobar(cobar);
    }
    for (int i = testCobarNum; i < testCobarNum + otherCobarNum; i++) {
        CobarDO cobar = DOFactory.getCobar();
        cobar.setName("test" + i);
        cobar.setClusterId(testClusterId + 1L);
        cobarDao.addCobar(cobar);
    }
    Assert.assertEquals(testCobarNum, cobarDao.getCobarList(testClusterId).size());
    Assert.assertEquals(0, cobarDao.getCobarList(testClusterId + 3).size());
}
Also used : CobarDO(com.alibaba.cobar.manager.dataobject.xml.CobarDO) Test(org.junit.Test)

Example 33 with CobarDO

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

the class CobarDaoTest method testModifyNotExistCobarId.

// same as add cluster
@Test
public void testModifyNotExistCobarId() {
    CobarDO cobar = DOFactory.getCobar();
    cobar.setId(3);
    cobarDao.modifyCobar(cobar);
    read();
    Assert.assertNotNull(cobarDao.getCobarById(3));
    Assert.assertNull(cobarDao.getCobarById(1));
}
Also used : CobarDO(com.alibaba.cobar.manager.dataobject.xml.CobarDO) Test(org.junit.Test)

Example 34 with CobarDO

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

the class DOFactory method getCobar.

public static CobarDO getCobar() {
    CobarDO cobar = new CobarDO();
    cobar.setClusterId(1);
    cobar.setHost("1.1.1.1");
    cobar.setName("gxw");
    cobar.setPassword("gxw");
    cobar.setStatus(ConstantDefine.ACTIVE);
    cobar.setPort(9090);
    cobar.setTime_diff("time_diff");
    cobar.setUser("gxw");
    return cobar;
}
Also used : CobarDO(com.alibaba.cobar.manager.dataobject.xml.CobarDO)

Example 35 with CobarDO

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

the class CobarDAOImple method checkName.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public boolean checkName(String name, long clusterId) {
    Iterator it = map.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<Long, CobarDO> entry = (Entry<Long, CobarDO>) it.next();
        CobarDO cobar = entry.getValue();
        if (clusterId == cobar.getClusterId() && cobar.getName().equals(name)) {
            return false;
        }
    }
    return true;
}
Also used : Entry(java.util.Map.Entry) Iterator(java.util.Iterator) CobarDO(com.alibaba.cobar.manager.dataobject.xml.CobarDO) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

CobarDO (com.alibaba.cobar.manager.dataobject.xml.CobarDO)35 CobarAdapterDAO (com.alibaba.cobar.manager.dao.CobarAdapterDAO)16 HashMap (java.util.HashMap)16 Map (java.util.Map)15 ArrayList (java.util.ArrayList)14 ModelAndView (org.springframework.web.servlet.ModelAndView)13 UserDO (com.alibaba.cobar.manager.dataobject.xml.UserDO)10 ClusterDO (com.alibaba.cobar.manager.dataobject.xml.ClusterDO)9 FluenceHashMap (com.alibaba.cobar.manager.util.FluenceHashMap)7 Test (org.junit.Test)7 PropertyUtilsBean (org.apache.commons.beanutils.PropertyUtilsBean)6 IOException (java.io.IOException)5 Iterator (java.util.Iterator)4 Entry (java.util.Map.Entry)4 JSONObject (net.sf.json.JSONObject)3 CommandStatus (com.alibaba.cobar.manager.dataobject.cobarnode.CommandStatus)2 ProcessorStatus (com.alibaba.cobar.manager.dataobject.cobarnode.ProcessorStatus)2 ServerStatus (com.alibaba.cobar.manager.dataobject.cobarnode.ServerStatus)2 Pair (com.alibaba.cobar.manager.util.Pair)2 JSONArray (net.sf.json.JSONArray)2