use of ngse.org.DBUtil in project MSEC by Tencent.
the class QueryMachineList method exec.
public QueryMachineListResponse exec(QueryMachineListRequest request) {
QueryMachineListResponse resp = new QueryMachineListResponse();
String result = checkIdentity();
if (!result.equals("success")) {
resp.setStatus(99);
resp.setMessage(result);
return resp;
}
DBUtil util = new DBUtil();
if (util.getConnection() == null) {
resp.setStatus(100);
resp.setMessage("db connect failed!");
return resp;
}
List<MachineInfo> machineInfoList;
//System.out.printf("name:%s, ip:%s\n", request.getMachine_name(), request.getMachine_ip());
String sql = "select machine_name, machine_ip, os_version, gcc_version, java_version from t_machine ";
List<Object> params = new ArrayList<Object>();
if (request.getMachine_name() != null && request.getMachine_name().length() > 0) {
sql += " where machine_name=? ";
params.add(request.getMachine_name());
} else if (request.getMachine_ip() != null && request.getMachine_ip().length() > 0) {
sql += " where machine_ip=? ";
params.add(request.getMachine_ip());
}
try {
machineInfoList = util.findMoreRefResult(sql, params, MachineInfo.class);
} catch (Exception e) {
resp.setStatus(100);
resp.setMessage("db query exception!");
e.printStackTrace();
return resp;
} finally {
util.releaseConn();
}
resp.setMachine_list((ArrayList<MachineInfo>) machineInfoList);
resp.setMessage("success");
resp.setStatus(0);
return resp;
}
use of ngse.org.DBUtil in project MSEC by Tencent.
the class QueryOddSecondLevelServiceDetail method exec.
public QueryOddSecondLevelServiceDetailResponse exec(OddSecondLevelService request) {
QueryOddSecondLevelServiceDetailResponse resp = new QueryOddSecondLevelServiceDetailResponse();
String result = checkIdentity();
if (!result.equals("success")) {
resp.setStatus(99);
resp.setMessage(result);
return resp;
}
DBUtil util = new DBUtil();
if (util.getConnection() == null) {
resp.setStatus(100);
resp.setMessage("db connect failed!");
return resp;
}
String sql;
List<Object> params;
List<OddSecondLevelServiceIPInfo> ipList;
try {
//查出ip列表
sql = "select ip,port,status,second_level_service_name,first_level_service_name,comm_proto from " + "t_second_level_service_ipinfo where second_level_service_name=? and first_level_service_name=?";
params = new ArrayList<Object>();
params.add(request.getSecond_level_service_name());
params.add(request.getFirst_level_service_name());
ipList = util.findMoreRefResult(sql, params, OddSecondLevelServiceIPInfo.class);
resp.setIpList((ArrayList<OddSecondLevelServiceIPInfo>) ipList);
resp.setMessage("success");
resp.setStatus(0);
return resp;
} catch (Exception e) {
resp.setStatus(100);
resp.setMessage("db query exception!");
e.printStackTrace();
return resp;
} finally {
util.releaseConn();
}
}
use of ngse.org.DBUtil 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();
}
}
use of ngse.org.DBUtil in project MSEC by Tencent.
the class ReleaseOnlyLibrary method CommitPlan.
private String CommitPlan(ReleasePlan plan) {
//产生发布用的文件,并记录到数据库里
DBUtil util = new DBUtil();
if (util.getConnection() == null) {
return "DB Connect Failed.";
}
String sql;
List<Object> params = new ArrayList<Object>();
try {
ObjectMapper objectMapper = new ObjectMapper();
String dest_ip_list_json_str = objectMapper.writeValueAsString(plan.getDest_ip_list());
//System.out.println(dest_ip_list_json_str);
sql = "insert into t_release_plan(plan_id, first_level_service_name,second_level_service_name," + "config_tag,idl_tag, sharedobject_tag, dest_ip_list,status,memo,release_type) values(?,?,?,?,?,?,?,'creating',?,?)";
params.add(plan.getPlan_id());
params.add(plan.getFirst_level_service_name());
params.add(plan.getSecond_level_service_name());
params.add("");
params.add("");
params.add("");
params.add(dest_ip_list_json_str);
params.add(plan.getMemo());
params.add(plan.getRelease_type());
int addNum = util.updateByPreparedStatement(sql, params);
if (addNum != 1) {
return "addNum is not 1:" + addNum;
}
//打包文件
new Thread(new PackReleaseFile(plan, getServlet().getServletContext())).start();
return "success";
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
} finally {
util.releaseConn();
;
}
}
use of ngse.org.DBUtil in project MSEC by Tencent.
the class ReleaseStepsGO method CommitPlan.
private String CommitPlan(ReleasePlan plan) {
//产生发布用的文件,并记录到数据库里
DBUtil util = new DBUtil();
if (util.getConnection() == null) {
return "DB Connect Failed.";
}
String sql;
List<Object> params = new ArrayList<Object>();
try {
ObjectMapper objectMapper = new ObjectMapper();
String dest_ip_list_json_str = objectMapper.writeValueAsString(plan.getDest_ip_list());
//System.out.println(dest_ip_list_json_str);
sql = "insert into t_release_plan(plan_id, first_level_service_name,second_level_service_name," + "config_tag,idl_tag, sharedobject_tag, dest_ip_list,status,memo,release_type) values(?,?,?,?,?,?,?,'creating',?,?)";
params.add(plan.getPlan_id());
params.add(plan.getFirst_level_service_name());
params.add(plan.getSecond_level_service_name());
params.add(plan.getConfig_tag());
params.add(plan.getIdl_tag());
params.add(plan.getSharedobject_tag());
params.add(dest_ip_list_json_str);
params.add(plan.getMemo());
params.add(plan.getRelease_type());
int addNum = util.updateByPreparedStatement(sql, params);
if (addNum != 1) {
return "addNum is not 1:" + addNum;
}
//打包文件
new Thread(new PackReleaseFile(plan, getServlet().getServletContext())).start();
return "success";
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
} finally {
util.releaseConn();
;
}
}
Aggregations