Commit edff05f0 authored by shaochangbin's avatar shaochangbin

Server_host_info信息添加删除

parent 5ab5371c
package com.yingxin.prms.api;
import com.yingxin.prms.domain.FlowLine;
import com.yingxin.prms.domain.FlowNode;
import com.yingxin.prms.domain.Server_Host_Info;
import com.yingxin.prms.service.business.Manager;
import com.yingxin.prms.service.dao.CassandraDaoImpl;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.POST;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -21,11 +21,13 @@ public class ReliabilityApi {
private final Manager manager;
private final AsyncTaskExecutor taskExecutor;
private final CassandraDaoImpl cassandraDao;
@Autowired
public ReliabilityApi(Manager manager, AsyncTaskExecutor taskExecutor) {
public ReliabilityApi(Manager manager, AsyncTaskExecutor taskExecutor, CassandraDaoImpl cassandraDao) {
this.manager = manager;
this.taskExecutor = taskExecutor;
this.cassandraDao = cassandraDao;
}
/**
......@@ -126,4 +128,15 @@ public class ReliabilityApi {
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;
import com.yingxin.prms.service.dao.CassandraDaoImpl;
import com.yingxin.prms.service.dao.FlowDaoImpl;
import com.yingxin.prms.utils.*;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.apache.catalina.Server;
import org.kairosdb.client.HttpClient;
import org.kairosdb.client.builder.*;
import org.kairosdb.client.response.QueryResponse;
......@@ -57,6 +59,8 @@ public class Manager {
private final CassandraDaoImpl cassandraDao;
private static CassandraDaoImpl cassandraDaoStatic;
@Autowired
private FlowDaoImpl flowDao;
......@@ -723,6 +727,27 @@ public class Manager {
}
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) {
List<String> m = new ArrayList<>();
......@@ -734,6 +759,11 @@ public class Manager {
m.add("f");
m = m.subList(1,4);
System.out.println(m);
// cassandraDaoStatic.insertServerHostInfo();
// System.out.println("@@@@@@@@@@@@@@@@@@@@");
}
// public Map<String, Object> searchLog(String json) {
......
......@@ -38,6 +38,17 @@ public class CassandraDaoImpl {
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) {
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