use of beans.dbaccess.OddSecondLevelServiceIPInfo in project MSEC by Tencent.
the class AddAlarmSetting 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();
}
}
use of beans.dbaccess.OddSecondLevelServiceIPInfo in project MSEC by Tencent.
the class QueryAlarmSetting 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'";
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();
}
}
Aggregations