Search in sources :

Example 1 with OddSecondLevelServiceIPInfo

use of beans.dbaccess.OddSecondLevelServiceIPInfo in project MSEC by Tencent.

the class MonitorBySvcOrIP method initMonitorIPAndPort.

public static void initMonitorIPAndPort() throws Exception {
    DBUtil util = new DBUtil();
    Logger logger = Logger.getLogger(MonitorBySvcOrIP.class);
    try {
        if (util.getConnection() == null) {
            Exception e = new Exception("connect db failed.");
            throw e;
        }
        String sql = sql = "select ip,port from t_second_level_service_ipinfo where second_level_service_name='monitor' and " + "first_level_service_name='RESERVED'  and status='enabled'";
        ArrayList<OddSecondLevelServiceIPInfo> list = util.findMoreRefResult(sql, null, OddSecondLevelServiceIPInfo.class);
        if (list == null || list.size() < 1) {
            throw new Exception("no db record exists.");
        }
        monitor_server_ip = list.get(0).getIp();
        //为什么加1,是个很长的故事,源于monitor的开发者将读写分离成两个端口
        monitor_server_port = list.get(0).getPort().intValue() + 1;
        logger.info(String.format("monitor server:%s:%d", monitor_server_ip, monitor_server_port));
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) ByteString(com.google.protobuf.ByteString) Logger(org.apache.log4j.Logger) ExecutionException(java.util.concurrent.ExecutionException) OddSecondLevelServiceIPInfo(beans.dbaccess.OddSecondLevelServiceIPInfo)

Example 2 with OddSecondLevelServiceIPInfo

use of beans.dbaccess.OddSecondLevelServiceIPInfo in project MSEC by Tencent.

the class DeleteAlarm method initMonitorIPAndPort.

public static void initMonitorIPAndPort() throws Exception {
    DBUtil util = new DBUtil();
    Logger logger = Logger.getLogger(MonitorBySvcOrIP.class);
    try {
        if (util.getConnection() == null) {
            Exception e = new Exception("connect db failed.");
            throw e;
        }
        String sql = sql = "select ip,port from t_second_level_service_ipinfo where second_level_service_name='monitor' " + "and first_level_service_name='RESERVED' and status='enabled'";
        ArrayList<OddSecondLevelServiceIPInfo> list = util.findMoreRefResult(sql, null, OddSecondLevelServiceIPInfo.class);
        if (list == null || list.size() < 1) {
            throw new Exception("no db record exists.");
        }
        monitor_server_ip = list.get(0).getIp();
        //为什么加1,是个很长的故事,源于monitor的开发者将读写分离成两个端口
        monitor_server_port = list.get(0).getPort().intValue() + 1;
        logger.info(String.format("monitor server:%s:%d", monitor_server_ip, monitor_server_port));
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) Logger(org.apache.log4j.Logger) OddSecondLevelServiceIPInfo(beans.dbaccess.OddSecondLevelServiceIPInfo)

Example 3 with OddSecondLevelServiceIPInfo

use of beans.dbaccess.OddSecondLevelServiceIPInfo in project MSEC by Tencent.

the class MonitorOneAttrAtDiffIP method initMonitorIPAndPort.

private static String initMonitorIPAndPort() {
    DBUtil util = new DBUtil();
    try {
        if (util.getConnection() == null) {
            return "connect db failed.";
        }
        String sql = sql = "select ip,port from t_second_level_service_ipinfo where second_level_service_name='monitor' and " + "first_level_service_name='RESERVED' and status='enabled'";
        ArrayList<OddSecondLevelServiceIPInfo> list = util.findMoreRefResult(sql, null, OddSecondLevelServiceIPInfo.class);
        if (list == null || list.size() < 1) {
            return "no db record exists.";
        }
        monitor_server_ip = list.get(0).getIp();
        //为什么加1,是个很长的故事,源于monitor的开发者将读写分离成两个端口
        monitor_server_port = list.get(0).getPort().intValue() + 1;
        return "success";
    } catch (Exception e) {
        e.printStackTrace();
        return e.getMessage();
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) OddSecondLevelServiceIPInfo(beans.dbaccess.OddSecondLevelServiceIPInfo)

Example 4 with OddSecondLevelServiceIPInfo

use of beans.dbaccess.OddSecondLevelServiceIPInfo in project MSEC by Tencent.

the class QueryAlarmList method initMonitorIPAndPort.

public static void initMonitorIPAndPort() throws Exception {
    DBUtil util = new DBUtil();
    Logger logger = Logger.getLogger(MonitorBySvcOrIP.class);
    try {
        if (util.getConnection() == null) {
            Exception e = new Exception("connect db failed.");
            throw e;
        }
        String sql = sql = "select ip,port from t_second_level_service_ipinfo where second_level_service_name='monitor' and " + "first_level_service_name='RESERVED' and status='enabled'";
        ArrayList<OddSecondLevelServiceIPInfo> list = util.findMoreRefResult(sql, null, OddSecondLevelServiceIPInfo.class);
        if (list == null || list.size() < 1) {
            throw new Exception("no db record exists.");
        }
        monitor_server_ip = list.get(0).getIp();
        //为什么加1,是个很长的故事,源于monitor的开发者将读写分离成两个端口
        monitor_server_port = list.get(0).getPort().intValue() + 1;
        logger.info(String.format("monitor server:%s:%d", monitor_server_ip, monitor_server_port));
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) Logger(org.apache.log4j.Logger) OddSecondLevelServiceIPInfo(beans.dbaccess.OddSecondLevelServiceIPInfo)

Example 5 with OddSecondLevelServiceIPInfo

use of beans.dbaccess.OddSecondLevelServiceIPInfo in project MSEC by Tencent.

the class DeleteAlarmSetting method initMonitorIPAndPort.

public static void initMonitorIPAndPort() throws Exception {
    DBUtil util = new DBUtil();
    Logger logger = Logger.getLogger(MonitorBySvcOrIP.class);
    try {
        if (util.getConnection() == null) {
            Exception e = new Exception("connect db failed.");
            throw e;
        }
        String sql = sql = "select ip,port from t_second_level_service_ipinfo where second_level_service_name='monitor' and " + "first_level_service_name='RESERVED' and status='enabled'";
        ArrayList<OddSecondLevelServiceIPInfo> list = util.findMoreRefResult(sql, null, OddSecondLevelServiceIPInfo.class);
        if (list == null || list.size() < 1) {
            throw new Exception("no db record exists.");
        }
        monitor_server_ip = list.get(0).getIp();
        //为什么加1,是个很长的故事,源于monitor的开发者将读写分离成两个端口
        monitor_server_port = list.get(0).getPort().intValue() + 1;
        logger.info(String.format("monitor server:%s:%d", monitor_server_ip, monitor_server_port));
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) Logger(org.apache.log4j.Logger) OddSecondLevelServiceIPInfo(beans.dbaccess.OddSecondLevelServiceIPInfo)

Aggregations

OddSecondLevelServiceIPInfo (beans.dbaccess.OddSecondLevelServiceIPInfo)7 DBUtil (ngse.org.DBUtil)7 Logger (org.apache.log4j.Logger)6 ByteString (com.google.protobuf.ByteString)1 ExecutionException (java.util.concurrent.ExecutionException)1