Commit edff05f0 authored by shaochangbin's avatar shaochangbin

Server_host_info信息添加删除

parent 5ab5371c
package com.yingxin.prms.api; package com.yingxin.prms.api;
import com.yingxin.prms.domain.FlowLine; import com.yingxin.prms.domain.Server_Host_Info;
import com.yingxin.prms.domain.FlowNode;
import com.yingxin.prms.service.business.Manager; import com.yingxin.prms.service.business.Manager;
import com.yingxin.prms.service.dao.CassandraDaoImpl;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.ws.rs.POST;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -21,11 +21,13 @@ public class ReliabilityApi { ...@@ -21,11 +21,13 @@ public class ReliabilityApi {
private final Manager manager; private final Manager manager;
private final AsyncTaskExecutor taskExecutor; private final AsyncTaskExecutor taskExecutor;
private final CassandraDaoImpl cassandraDao;
@Autowired @Autowired
public ReliabilityApi(Manager manager, AsyncTaskExecutor taskExecutor) { public ReliabilityApi(Manager manager, AsyncTaskExecutor taskExecutor, CassandraDaoImpl cassandraDao) {
this.manager = manager; this.manager = manager;
this.taskExecutor = taskExecutor; this.taskExecutor = taskExecutor;
this.cassandraDao = cassandraDao;
} }
/** /**
...@@ -126,4 +128,15 @@ public class ReliabilityApi { ...@@ -126,4 +128,15 @@ public class ReliabilityApi {
return manager.getSwitch(); return manager.getSwitch();
} }
//新建监控服务信息
@PostMapping("insertServerHostInfo")
public String insertServerHostInfo(@RequestBody String json){
return manager.insertServerHostInfo(json);
}
//删除监控服务信息
@PostMapping("delServerHostInfo")
public String delServerHostInfo(@RequestBody String json){
return manager.delServerHostInfo(json);
}
} }
...@@ -8,7 +8,9 @@ import com.yingxin.prms.service.asyncTask.QueryHostStatusTask; ...@@ -8,7 +8,9 @@ import com.yingxin.prms.service.asyncTask.QueryHostStatusTask;
import com.yingxin.prms.service.dao.CassandraDaoImpl; import com.yingxin.prms.service.dao.CassandraDaoImpl;
import com.yingxin.prms.service.dao.FlowDaoImpl; import com.yingxin.prms.service.dao.FlowDaoImpl;
import com.yingxin.prms.utils.*; import com.yingxin.prms.utils.*;
import net.sf.json.JSON;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.catalina.Server;
import org.kairosdb.client.HttpClient; import org.kairosdb.client.HttpClient;
import org.kairosdb.client.builder.*; import org.kairosdb.client.builder.*;
import org.kairosdb.client.response.QueryResponse; import org.kairosdb.client.response.QueryResponse;
...@@ -57,6 +59,8 @@ public class Manager { ...@@ -57,6 +59,8 @@ public class Manager {
private final CassandraDaoImpl cassandraDao; private final CassandraDaoImpl cassandraDao;
private static CassandraDaoImpl cassandraDaoStatic;
@Autowired @Autowired
private FlowDaoImpl flowDao; private FlowDaoImpl flowDao;
...@@ -723,6 +727,27 @@ public class Manager { ...@@ -723,6 +727,27 @@ public class Manager {
} }
return map; return map;
} }
//新建监控服务信息
public String insertServerHostInfo(String json){
JSONObject job = JSONObject.fromObject(json);
Server_Host_Info server_host_info = new Server_Host_Info(job.getString("service_method"),job.getString("cluster_name"),
job.getString("host_name"),job.getString("service_path"),job.getString("host_ip"),
Short.parseShort(job.getString("host_port")),job.getString("request_body"),job.getString("response_body"),
job.getString("service_password"),job.getString("layer"));
cassandraDao.insertServerHostInfo(server_host_info);
return server_host_info.toString();
}
//删除监控服务信息
public String delServerHostInfo(String json){
JSONObject job = JSONObject.fromObject(json);
Server_Host_Info server_host_info = new Server_Host_Info(job.getString("service_method"),job.getString("cluster_name"),
job.getString("host_name"),job.getString("service_path"),job.getString("host_ip"),
Short.parseShort(job.getString("host_port")),job.getString("request_body"),job.getString("response_body"),
job.getString("service_password"),job.getString("layer"));
cassandraDao.delServerHostInfo(server_host_info);
return server_host_info.toString();
}
public static void main(String[] args) { public static void main(String[] args) {
List<String> m = new ArrayList<>(); List<String> m = new ArrayList<>();
...@@ -734,6 +759,11 @@ public class Manager { ...@@ -734,6 +759,11 @@ public class Manager {
m.add("f"); m.add("f");
m = m.subList(1,4); m = m.subList(1,4);
System.out.println(m); System.out.println(m);
// cassandraDaoStatic.insertServerHostInfo();
// System.out.println("@@@@@@@@@@@@@@@@@@@@");
} }
// public Map<String, Object> searchLog(String json) { // public Map<String, Object> searchLog(String json) {
......
...@@ -38,6 +38,17 @@ public class CassandraDaoImpl { ...@@ -38,6 +38,17 @@ public class CassandraDaoImpl {
return template.select("select * from ctid_prof.server_host_info;", Server_Host_Info.class); return template.select("select * from ctid_prof.server_host_info;", Server_Host_Info.class);
} }
//插入server_host_info信息
public int insertServerHostInfo(Server_Host_Info server_host_info) {
template.insert(server_host_info);
return 1;
}
//删除server_host_info信息
public int delServerHostInfo(Server_Host_Info server_host_info) {
template.delete(server_host_info);
return 1;
}
public void saveReqBLV(CTID_Request_Perf_BaseLineValue entity) { public void saveReqBLV(CTID_Request_Perf_BaseLineValue entity) {
template.insert(entity); template.insert(entity);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment