Commit 0493c149 authored by AfirSraftGarrier's avatar AfirSraftGarrier

修改

parent 239c324e
package iot.sixiang.license.consts;
public class Consts {
public class Constant {
public static final int CMD_LICENSE = 1;// 授权消息的cmd,十进制
public static final int CMD_UPLOAD_ERROR = 2;// 错误消息上报
public static final int EXECUTOR_THREAD_NUM = 30;
public static final int FORWARD_THREAD_NUM = 30;
public static final int OPERATE_THREAD_NUM = 5;
......
......@@ -4,7 +4,7 @@ import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutorGroup;
import iot.sixiang.license.consts.Consts;
import iot.sixiang.license.consts.Constant;
import iot.sixiang.license.net.BaseChannelInitializer;
import lombok.extern.slf4j.Slf4j;
......@@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit;
public class DeviceChannelInitializer extends BaseChannelInitializer {
private DeviceServerHandler handler;
static final EventExecutorGroup workGroup = new DefaultEventExecutorGroup(Consts.EXECUTOR_THREAD_NUM);
static final EventExecutorGroup workGroup = new DefaultEventExecutorGroup(Constant.EXECUTOR_THREAD_NUM);
public DeviceChannelInitializer(DeviceServerHandler handler) {
this.handler = handler;
......
package iot.sixiang.license.device;
import iot.sixiang.license.consts.Consts;
import iot.sixiang.license.consts.Constant;
import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.SessionContext;
import iot.sixiang.license.model.vo.DeviceDetailVo;
......@@ -142,7 +142,7 @@ public class DeviceManager {
if (targetSession.getChannelId().equals(channelId)) {
targetSession.setAuthStatus(false);
targetSession.setStatus(Consts.DEVICE_STATE_OFFLINE);
targetSession.setStatus(Constant.DEVICE_STATE_OFFLINE);
targetSession.setOffline(CommonUtil.getSystemTime());
return true;
}
......
......@@ -7,7 +7,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.SocketChannel;
import iot.sixiang.license.auth.AuthManager;
import iot.sixiang.license.consts.Consts;
import iot.sixiang.license.consts.Constant;
import iot.sixiang.license.event.CreateForwardClientEvent;
import iot.sixiang.license.event.DeviceClientInactiveEvent;
import iot.sixiang.license.event.EventPublisher;
......@@ -55,7 +55,7 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
int cmdInt = cmd & 0xFF;
boolean auth = false;
if (cmdInt == Consts.CMD_LICENSE) {
if (cmdInt == Constant.CMD_LICENSE) {
auth = handlerCheckAuth(channel, remoteIp, remotePort, protocol);
} else {
auth = handlerCheckAuthStatus(channel, remoteIp, remotePort, protocol);
......@@ -147,7 +147,7 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
session.setChannelId(channelId);
session.setClientChannel(channel);
session.setAuthStatus(true);
session.setStatus(Consts.DEVICE_STATE_ONLINE);
session.setStatus(Constant.DEVICE_STATE_ONLINE);
session.setOnline(CommonUtil.getSystemTime());
DeviceManager deviceManager = SpringUtil.getBean(DeviceManager.class);
......
......@@ -3,13 +3,13 @@ package iot.sixiang.license.forward;
import io.netty.channel.socket.SocketChannel;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutorGroup;
import iot.sixiang.license.consts.Consts;
import iot.sixiang.license.consts.Constant;
import iot.sixiang.license.net.BaseChannelInitializer;
public class ForwardChannelInitializer extends BaseChannelInitializer {
private ForwardClientHandler handler;
static final EventExecutorGroup workGroup = new DefaultEventExecutorGroup(Consts.FORWARD_THREAD_NUM);
static final EventExecutorGroup workGroup = new DefaultEventExecutorGroup(Constant.FORWARD_THREAD_NUM);
public ForwardChannelInitializer(ForwardClientHandler handler) {
this.handler = handler;
......
package iot.sixiang.license.forward;
import iot.sixiang.license.consts.Consts;
import iot.sixiang.license.consts.Constant;
import iot.sixiang.license.model.SessionContext;
import iot.sixiang.license.model.vo.ServerStatusVo;
import lombok.extern.slf4j.Slf4j;
......@@ -67,11 +67,11 @@ public class ForwardManager {
public ServerStatusVo getServerStatus() {
ServerStatusVo vo = new ServerStatusVo();
int size = sessionContexts.size();
int statue = Consts.SERVICE_DX_STATUS_FLUENT;
if (size >= Consts.SERVICE_DX_THRESHOLD_NORMAL) {
statue = Consts.SERVICE_DX_STATUS_NORMAL;
} else if (size > Consts.SERVICE_DX_THRESHOLD_BUSY) {
statue = Consts.SERVICE_DX_STATUS_BUSY;
int statue = Constant.SERVICE_DX_STATUS_FLUENT;
if (size >= Constant.SERVICE_DX_THRESHOLD_NORMAL) {
statue = Constant.SERVICE_DX_STATUS_NORMAL;
} else if (size > Constant.SERVICE_DX_THRESHOLD_BUSY) {
statue = Constant.SERVICE_DX_STATUS_BUSY;
}
vo.setCount(size);
vo.setStatus(statue);
......
......@@ -3,14 +3,14 @@ package iot.sixiang.license.operate;
import io.netty.channel.socket.SocketChannel;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutorGroup;
import iot.sixiang.license.consts.Consts;
import iot.sixiang.license.consts.Constant;
import iot.sixiang.license.net.BaseChannelInitializer;
public class OperateChannelInitializer extends BaseChannelInitializer {
private OperateClientHandler handler;
static final EventExecutorGroup workGroup = new DefaultEventExecutorGroup(Consts.OPERATE_THREAD_NUM);
static final EventExecutorGroup workGroup = new DefaultEventExecutorGroup(Constant.OPERATE_THREAD_NUM);
public OperateChannelInitializer(OperateClientHandler handler) {
this.handler = handler;
......
package iot.sixiang.license.util;
import iot.sixiang.license.consts.Consts;
import iot.sixiang.license.consts.Constant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.system.ApplicationHome;
......@@ -79,7 +79,7 @@ public class CommonUtil {
}
public static String getServerParentDirectory() {
return new File(new ApplicationHome(Consts.class).getSource().getParentFile().getPath()).getParent();
return new File(new ApplicationHome(Constant.class).getSource().getParentFile().getPath()).getParent();
}
public static String getLibFilePathByFileName(String fileName) {
......
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