當前位置: 首頁>>代碼示例>>Java>>正文


Java DataNodesStatus類代碼示例

本文整理匯總了Java中com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus的典型用法代碼示例。如果您正苦於以下問題:Java DataNodesStatus類的具體用法?Java DataNodesStatus怎麽用?Java DataNodesStatus使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataNodesStatus類屬於com.alibaba.cobar.manager.dataobject.cobarnode包,在下文中一共展示了DataNodesStatus類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mapRow

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
    DataNodesStatus ds = new DataNodesStatus();
    ds.setPoolName(rs.getString(POOL_NAME));
    ds.setDataSource(rs.getString(DS));
    if (null == rs.getString(TYPE)) {
        ds.setType("NULL");
        ds.setActive(-1);
        ds.setIdle(-1);
        ds.setIndex(-1);
        ds.setSize(-1);
    } else {
        ds.setType(rs.getString(TYPE));
        ds.setActive(rs.getInt(ACTIVE));
        ds.setIdle(rs.getInt(IDLE));
        ds.setSize(rs.getInt(SIZE));
        ds.setIndex(rs.getInt(INDEX));
    }
    ds.setExecuteCount(rs.getLong(EXECUTE));
    ds.setMaxTime(rs.getLong(MAX_TIME));
    ds.setMaxSQL(rs.getLong(MAX_SQL));
    ds.setRecoveryTime(rs.getLong(RECOVERY_TIME));
    ds.setTotalTime(rs.getLong(TOTAL_TIME));
    ds.setSampleTimeStamp(System.currentTimeMillis());
    return ds;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:27,代碼來源:CobarAdapter.java

示例2: compare

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public int compare(T arg0, T arg1) {
    if (arg0 instanceof DataNodesStatus) {
        return compareDatanodes((DataNodesStatus) arg0, (DataNodesStatus) arg1);
    } else if (arg0 instanceof ConnectionStatus) {
        return compareConnection((ConnectionStatus) arg0, (ConnectionStatus) arg1);
    } else if (arg0 instanceof CobarDO) {
        // cobar sort by name
        return ((CobarDO) arg0).getName().compareTo(((CobarDO) arg1).getName());
    } else if (arg0 instanceof ClusterDO) {
        // cluster sort by name
        return compareCluster((ClusterDO) arg0, (ClusterDO) arg1);
    } else if (arg0 instanceof Map) {
        // compare datanodes map
        return comparePoolName((String) ((Map<String, Object>) arg0).get("poolName"),
            (String) ((Map<String, Object>) arg1).get("poolName"));
    }

    return 0;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:22,代碼來源:SortUtil.java

示例3: testRecoverTime

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@Test
public void testRecoverTime() {
    int recoverTime = 10;
    dataNodeStatusList = cobarAdapter.listDataNodes();
    Assert.assertTrue(dataNodeStatusList.size() >= 1);
    String testDataNode = dataNodeStatusList.get(0).getPoolName();
    try {
        sCobarNode.excuteSQL(managerConnection, "stop @@heartbeat " + testDataNode + " : " + recoverTime);
    } catch (SQLException e) {
        logger.error(e.getMessage(), e);
        Assert.fail();
    }

    DataNodesStatus testDataNodeStatus = this.getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDataNodeStatus);
    double remainTime = testDataNodeStatus.getRecoveryTime();
    Assert.assertTrue((remainTime > 0) && (remainTime <= recoverTime));

    TestUtils.waitForMonment(recoverTime * 1000);
    testDataNodeStatus = this.getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDataNodeStatus);
    remainTime = testDataNodeStatus.getRecoveryTime();
    Assert.assertTrue(remainTime == -1);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:25,代碼來源:TestDataNodes.java

示例4: testExcute

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@Test
public void testExcute() {
    String testDataNode = "ddl_test";
    dataNodeStatusList = cobarAdapter.listDataNodes();
    DataNodesStatus testDNStatusBefore = getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDNStatusBefore);
    try {
        sCobarNode.excuteSQL(dmlConnection, "show tables");
    } catch (SQLException e) {
        logger.error(e.getMessage(), e);
        Assert.fail();
    }
    DataNodesStatus testDNStatusAfter = getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDNStatusAfter);

    Assert.assertEquals(testDNStatusBefore.getExecuteCount() + 1, testDNStatusAfter.getExecuteCount());
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:18,代碼來源:TestDataNodes.java

示例5: testExcuteAfterSwitchIndex

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@Test
public void testExcuteAfterSwitchIndex() {
    String testDataNode = "ddl_test";
    dataNodeStatusList = cobarAdapter.listDataNodes();
    DataNodesStatus testDNStatusBefore = getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDNStatusBefore);
    try {
        sCobarNode.excuteSQL(managerConnection, "switch @@dataSource " + testDataNode);
        sCobarNode.excuteSQL(dmlConnection, "show tables");
    } catch (SQLException e) {
        logger.error(e.getMessage(), e);
        Assert.fail();
    }
    DataNodesStatus testDNStatusAfter = getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDNStatusAfter);

    Assert.assertEquals(testDNStatusBefore.getExecuteCount() + 1, testDNStatusAfter.getExecuteCount());
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:19,代碼來源:TestDataNodes.java

示例6: compare

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public int compare(T arg0, T arg1) {
    if (arg0 instanceof DataNodesStatus) {
        return compareDatanodes((DataNodesStatus) arg0, (DataNodesStatus) arg1);
    } else if (arg0 instanceof ConnectionStatus) {
        return compareConnection((ConnectionStatus) arg0, (ConnectionStatus) arg1);
    } else if (arg0 instanceof CobarDO) {
        //cobar sort by name
        return ((CobarDO) arg0).getName().compareTo(((CobarDO) arg1).getName());
    } else if (arg0 instanceof ClusterDO) {
        //cluster sort by name
        return compareCluster((ClusterDO) arg0, (ClusterDO) arg1);
    } else if (arg0 instanceof Map) {
        //compare datanodes  map
        return comparePoolName((String) ((Map<String, Object>) arg0).get("poolName"),
                               (String) ((Map<String, Object>) arg1).get("poolName"));
    }

    return 0;
}
 
開發者ID:alibaba,項目名稱:cobar,代碼行數:22,代碼來源:SortUtil.java

示例7: testExcute

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@Test
public void testExcute(){
    String testDataNode = "ddl_test";
    dataNodeStatusList = cobarAdapter.listDataNodes();
    DataNodesStatus testDNStatusBefore= getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDNStatusBefore);
    try {
        sCobarNode.excuteSQL(dmlConnection, "show tables");
    } catch (SQLException e) {
        logger.error(e.getMessage(), e);
        Assert.fail();
    }
    DataNodesStatus testDNStatusAfter= getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDNStatusAfter);
    
    Assert.assertEquals(testDNStatusBefore.getExecuteCount() + 1, testDNStatusAfter.getExecuteCount());
}
 
開發者ID:alibaba,項目名稱:cobar,代碼行數:18,代碼來源:TestDataNodes.java

示例8: testExcuteAfterSwitchIndex

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@Test
public void testExcuteAfterSwitchIndex(){
    String testDataNode = "ddl_test";
    dataNodeStatusList = cobarAdapter.listDataNodes();
    DataNodesStatus testDNStatusBefore= getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDNStatusBefore);
    try {
        sCobarNode.excuteSQL(managerConnection, "switch @@dataSource " + testDataNode);
        sCobarNode.excuteSQL(dmlConnection, "show tables");
    } catch (SQLException e) {
        logger.error(e.getMessage(), e);
        Assert.fail();
    }
    DataNodesStatus testDNStatusAfter= getDataNodeStatus(testDataNode);
    Assert.assertNotNull(testDNStatusAfter);
    
    Assert.assertEquals(testDNStatusBefore.getExecuteCount() + 1, testDNStatusAfter.getExecuteCount());
}
 
開發者ID:alibaba,項目名稱:cobar,代碼行數:19,代碼來源:TestDataNodes.java

示例9: listDatanode

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@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;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:34,代碼來源:CobarNodeInstantPerfValueAjax.java

示例10: sortDataNodesByPoolName

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
public static void sortDataNodesByPoolName(List<DataNodesStatus> list) {
    Collections.sort(list, new Comparator<DataNodesStatus>() {

        @Override
        public int compare(DataNodesStatus o1, DataNodesStatus o2) {
            return comparePoolName(o1.getPoolName(), o2.getPoolName());
        }

    });
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:11,代碼來源:ListSortUtil.java

示例11: getDataNodeStatus

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
public DataNodesStatus getDataNodeStatus(String poolName) {
    DataNodesStatus dataNodeStatus = null;
    dataNodeStatusList = cobarAdapter.listDataNodes();
    for (DataNodesStatus data : dataNodeStatusList) {
        String dataNode = data.getPoolName();
        if (poolName.equals(dataNode)) {
            dataNodeStatus = data;
            break;
        }
    }
    return dataNodeStatus;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:13,代碼來源:TestDataNodes.java

示例12: listDatanode

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@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;
}
 
開發者ID:alibaba,項目名稱:cobar,代碼行數:33,代碼來源:CobarNodeInstantPerfValueAjax.java

示例13: listDataNodes

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@Override
public List<DataNodesStatus> listDataNodes() {
    return getJdbcTemplate().query(SHOW_DATANODE, dataNodesStatusRowMapper);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:5,代碼來源:CobarAdapter.java

示例14: compareDatanodes

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
public int compareDatanodes(DataNodesStatus arg0, DataNodesStatus arg1) {
    return comparePoolName((arg0).getPoolName(), (arg1).getPoolName());
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:4,代碼來源:SortUtil.java

示例15: testDataSourcesCommand

import com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus; //導入依賴的package包/類
@Test
public void testDataSourcesCommand() {
    List<DataNodesStatus> dsStatusList = cobarAdapter.listDataNodes();
    Assert.assertTrue(dsStatusList.size() > 0);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:6,代碼來源:TestDataSources.java


注:本文中的com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。