增加http协议到master
parent
d518e5fbcc
commit
5867b06535
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
package com.leaper.web.controller;
|
||||
|
||||
import com.leaper.web.service.CommandHandler;
|
||||
import com.leaper.web.service.ksec.KsecInfo;
|
||||
import com.zhehekeji.core.pojo.Result;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(value = "monitor",tags = "监控接口 HTTP协议")
|
||||
@RestController
|
||||
@RequestMapping("/monitor")
|
||||
@Slf4j
|
||||
public class MonitorController {
|
||||
|
||||
@PostMapping("/task")
|
||||
public Result monitorTask(@RequestBody KsecInfo ksecInfo){
|
||||
CommandHandler.exec(ksecInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.leaper.web.service;
|
||||
|
||||
import com.leaper.common.util.FileUtil;
|
||||
import com.leaper.web.service.ksec.KsecDecoder;
|
||||
import com.leaper.web.service.ksec.KsecInfo;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
public class CommandHandler {
|
||||
|
||||
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(7,21,30, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<>(20000));
|
||||
|
||||
static {
|
||||
String lotnum = FileUtil.getText("lastLotnum");
|
||||
if(lotnum != null){
|
||||
CommandRunnable.setLastLotnum(lotnum);
|
||||
}
|
||||
log.info("read lastLotnum:{}",lotnum);
|
||||
}
|
||||
|
||||
public static void exec(ChannelHandlerContext ctx, ByteBuf in){
|
||||
CommandRunnable commandRunnable = new CommandRunnable(in,ctx);
|
||||
threadPoolExecutor.execute(commandRunnable);
|
||||
}
|
||||
|
||||
public static void exec(KsecInfo ksecInfo){
|
||||
CommandRunnable commandRunnable = new CommandRunnable(ksecInfo);
|
||||
threadPoolExecutor.execute(commandRunnable);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue