当前位置: 首页>>代码示例>>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;未经允许,请勿转载。