Commit aaaf0177 authored by haozi's avatar haozi
Browse files

纠正命名、加线程池命令下发

parent 566d19fb
Showing with 62 additions and 16 deletions
+62 -16
......@@ -26,11 +26,11 @@ public class MessageHandler extends SimpleChannelInboundHandler<String> {
private static final Logger logger = LoggerFactory.getLogger(MessageHandler.class);
private final Map<Integer, ServerMessgaeProcess> processorMap;
private final Map<Integer, ServerMessageProcess> processorMap;
public MessageHandler(List<ServerMessgaeProcess> processors) {
ImmutableMap.Builder<Integer, ServerMessgaeProcess> builder = new ImmutableMap.Builder<>();
for (ServerMessgaeProcess processor : processors) {
public MessageHandler(List<ServerMessageProcess> processors) {
ImmutableMap.Builder<Integer, ServerMessageProcess> builder = new ImmutableMap.Builder<>();
for (ServerMessageProcess processor : processors) {
builder.put(processor.code(), processor);
}
processorMap = builder.build();
......@@ -44,7 +44,7 @@ public class MessageHandler extends SimpleChannelInboundHandler<String> {
if (code != CommandCode.HEARTBEAT.getCode()) {
logger.debug("接收到 id:{}, code:{} 数据请求 ctx:{},message size:{}", instanceUuid, code, ctx.channel(), message.length());
}
ServerMessgaeProcess messageProcessor = processorMap.get(code);
ServerMessageProcess messageProcessor = processorMap.get(code);
if (messageProcessor == null) {
logger.warn("can not process message code [{}], {}", code, ctx.channel());
return;
......
......@@ -9,7 +9,7 @@ import com.cubic.proxy.websocket.WebRequestHandler;
import com.cubic.proxy.websocket.process.SearchWebProcess;
import com.matrix.proxy.server.MatrixNettyServer;
import com.cubic.proxy.common.handler.MessageHandler;
import com.cubic.proxy.common.handler.ServerMessgaeProcess;
import com.cubic.proxy.common.handler.ServerMessageProcess;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -31,7 +31,7 @@ public class ServerConfig {
private List<WebProcess> webProcesses;
@Bean(initMethod = "start")
public MatrixNettyServer nettyServerForAgent(ServerProperties serverProperties, List<ServerMessgaeProcess> processors) {
public MatrixNettyServer nettyServerForAgent(ServerProperties serverProperties, List<ServerMessageProcess> processors) {
MessageHandler messageHandler = new MessageHandler(processors);
return new MatrixNettyServer(serverProperties.getAgentPort(), messageHandler);
}
......
package com.matrix.proxy.controller;
import com.alibaba.fastjson.JSONObject;
import com.cubic.proxy.common.constant.CommandCode;
import com.matrix.proxy.service.JdkCommandService;
import com.matrix.proxy.service.JvmDataService;
import com.matrix.proxy.vo.ThreadPoolQuery;
import com.matrix.proxy.vo.ThreadPoolCommandVo;
import com.matrix.proxy.vo.ThreadPoolQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -20,9 +24,33 @@ import org.springframework.web.bind.annotation.RestController;
public class JvmController {
@Autowired
private JvmDataService jvmDataService;
@Autowired
private JdkCommandService jdkCommandService;
/**
* 线程池列表
*
* @param query
* @return
*/
@RequestMapping("/threadpool/page")
public Object threadPoolPage(@RequestBody ThreadPoolQuery query) {
public Object threadPoolPage(@RequestBody ThreadPoolQueryVo query) {
return jvmDataService.threadPoolDataPage(query);
}
/**
* 线程池命令下发
*
* @param commandVo
* @return
*/
@RequestMapping("/threadpool/command")
public Object threadPoolCMD(@RequestBody ThreadPoolCommandVo commandVo) {
JSONObject command = new JSONObject();
command.put("key", commandVo.getKey());
command.put("name", commandVo.getName());
command.put("arg", commandVo.getArg());
return jdkCommandService.exeCommand(commandVo.getInstanceUuid(), CommandCode.JVM_THREAD_POOL.getCode(), command.toJSONString());
}
}
......@@ -2,7 +2,7 @@ package com.matrix.proxy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.proxy.entity.ThreadPoolEntity;
import com.matrix.proxy.vo.ThreadPoolQuery;
import com.matrix.proxy.vo.ThreadPoolQueryVo;
import java.util.List;
......@@ -19,5 +19,5 @@ public interface ThreadPoolMapper extends BaseMapper<ThreadPoolEntity> {
* @param query
* @return
*/
List<ThreadPoolEntity> selectByQuery(ThreadPoolQuery query);
List<ThreadPoolEntity> selectByQuery(ThreadPoolQueryVo query);
}
......@@ -2,7 +2,7 @@ package com.matrix.proxy.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.matrix.proxy.entity.ThreadPoolEntity;
import com.matrix.proxy.vo.ThreadPoolQuery;
import com.matrix.proxy.vo.ThreadPoolQueryVo;
/**
* JVM数据采集服务
......@@ -17,5 +17,5 @@ public interface JvmDataService {
* @param query
* @return
*/
IPage<ThreadPoolEntity> threadPoolDataPage(ThreadPoolQuery query);
IPage<ThreadPoolEntity> threadPoolDataPage(ThreadPoolQueryVo query);
}
......@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.proxy.entity.ThreadPoolEntity;
import com.matrix.proxy.mapper.ThreadPoolMapper;
import com.matrix.proxy.vo.ThreadPoolQuery;
import com.matrix.proxy.vo.ThreadPoolQueryVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -28,7 +28,7 @@ public class JvmDataServiceImpl implements JvmDataService {
* @return
*/
@Override
public IPage<ThreadPoolEntity> threadPoolDataPage(ThreadPoolQuery query) {
public IPage<ThreadPoolEntity> threadPoolDataPage(ThreadPoolQueryVo query) {
Page<ThreadPoolEntity> page = new Page<>(query.getPageNo(),query.getPageSize());
IPage<ThreadPoolEntity> iPages =threadPoolMapper.selectPage(page,new QueryWrapper<>());
......
package com.matrix.proxy.vo;
import lombok.Data;
/**
* 线程池下发命名
*
* @author zhanghao
* @date 2021/4/75:56 下午
*/
@Data
public class ThreadPoolCommandVo {
private String instanceUuid;
private String key;
private String name;
private Object arg;
}
......@@ -11,7 +11,7 @@ import java.util.Date;
* @date 2021/4/75:56 下午
*/
@Data
public class ThreadPoolQuery {
public class ThreadPoolQueryVo {
int pageNo = 1;
int pageSize = 20;
......
Supports Markdown
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