Commit a7e9c41a authored by zengtianlai3's avatar zengtianlai3

Merge branch 'm33' into 'master'

M33

See merge request !19
parents cd38a6d8 87a136de
<component name="libraryTable">
<library name="Maven: com.auth0:java-jwt:3.8.2">
<CLASSES>
<root url="jar://C:/tools/Spring/mvn_repository/com/auth0/java-jwt/3.8.2/java-jwt-3.8.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://C:/tools/Spring/mvn_repository/com/auth0/java-jwt/3.8.2/java-jwt-3.8.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://C:/tools/Spring/mvn_repository/com/auth0/java-jwt/3.8.2/java-jwt-3.8.2-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: commons-codec:commons-codec:1.15">
<CLASSES>
<root url="jar://C:/tools/Spring/mvn_repository/commons-codec/commons-codec/1.15/commons-codec-1.15.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://C:/tools/Spring/mvn_repository/commons-codec/commons-codec/1.15/commons-codec-1.15-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://C:/tools/Spring/mvn_repository/commons-codec/commons-codec/1.15/commons-codec-1.15-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.apache.commons:commons-collections4:4.1">
<CLASSES>
<root url="jar://C:/tools/Spring/mvn_repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://C:/tools/Spring/mvn_repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://C:/tools/Spring/mvn_repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.apache.poi:poi:3.17">
<CLASSES>
<root url="jar://C:/tools/Spring/mvn_repository/org/apache/poi/poi/3.17/poi-3.17.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://C:/tools/Spring/mvn_repository/org/apache/poi/poi/3.17/poi-3.17-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://C:/tools/Spring/mvn_repository/org/apache/poi/poi/3.17/poi-3.17-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
...@@ -5,6 +5,7 @@ import iot.sixiang.license.device.DeviceProtocol; ...@@ -5,6 +5,7 @@ import iot.sixiang.license.device.DeviceProtocol;
import iot.sixiang.license.model.SamInfo; import iot.sixiang.license.model.SamInfo;
import iot.sixiang.license.model.SamMonitor; import iot.sixiang.license.model.SamMonitor;
import iot.sixiang.license.operate.OperateManager; import iot.sixiang.license.operate.OperateManager;
import iot.sixiang.license.service.AlarmService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
...@@ -22,6 +23,9 @@ public class OperateSAMStatusResponseEventHandler { ...@@ -22,6 +23,9 @@ public class OperateSAMStatusResponseEventHandler {
@Autowired @Autowired
public OperateManager operateManager; public OperateManager operateManager;
@Autowired
private AlarmService alarmService;
public OperateSAMStatusResponseEventHandler() { public OperateSAMStatusResponseEventHandler() {
} }
...@@ -36,6 +40,12 @@ public class OperateSAMStatusResponseEventHandler { ...@@ -36,6 +40,12 @@ public class OperateSAMStatusResponseEventHandler {
for (SamInfo samInfo : samInfoList) { for (SamInfo samInfo : samInfoList) {
if (samInfo.getStatus() == 0 || samInfo.getStatus() == 1 || samInfo.getStatus() == 2 || samInfo.getStatus() == 4) { if (samInfo.getStatus() == 0 || samInfo.getStatus() == 1 || samInfo.getStatus() == 2 || samInfo.getStatus() == 4) {
onlineCount++; onlineCount++;
} else {
int index = samInfo.getIndex();
int typeId = 2;
String title = "SAM故障";
String content = "index为" + index + "的SAM发生故障";
alarmService.addAlarm(typeId,title,content);
} }
} }
SamMonitor samMonitor = new SamMonitor(); SamMonitor samMonitor = new SamMonitor();
...@@ -43,5 +53,11 @@ public class OperateSAMStatusResponseEventHandler { ...@@ -43,5 +53,11 @@ public class OperateSAMStatusResponseEventHandler {
samMonitor.setOnlineCount(onlineCount); samMonitor.setOnlineCount(onlineCount);
samMonitor.setSamCount(samCount); samMonitor.setSamCount(samCount);
operateManager.putSamMonitorMap(serverIp, samMonitor); operateManager.putSamMonitorMap(serverIp, samMonitor);
if (onlineCount / samCount > 0.7) {
int typeId = 3;
String title = "SAM不足";
String content = "当前在线客户端已超过70%";
alarmService.addAlarm(typeId,title,content);
}
} }
} }
package iot.sixiang.license.forward; package iot.sixiang.license.forward;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoop;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import iot.sixiang.license.device.DeviceProtocol; import iot.sixiang.license.device.DeviceProtocol;
import iot.sixiang.license.event.DeviceClientBeForcedOfflineEvent; import iot.sixiang.license.event.DeviceClientBeForcedOfflineEvent;
...@@ -9,32 +8,31 @@ import iot.sixiang.license.event.DeviceClientLicenseEvent; ...@@ -9,32 +8,31 @@ import iot.sixiang.license.event.DeviceClientLicenseEvent;
import iot.sixiang.license.event.EventPublisher; import iot.sixiang.license.event.EventPublisher;
import iot.sixiang.license.event.ForwardClientConnectEvent; import iot.sixiang.license.event.ForwardClientConnectEvent;
import iot.sixiang.license.net.BaseConnectionListener; import iot.sixiang.license.net.BaseConnectionListener;
import iot.sixiang.license.service.AlarmService;
import iot.sixiang.license.util.SpringUtil; import iot.sixiang.license.util.SpringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.beans.factory.annotation.Autowired;
import java.util.concurrent.TimeUnit; import java.net.InetSocketAddress;
@Slf4j @Slf4j
public class ForwardConnectionListener extends BaseConnectionListener { public class ForwardConnectionListener extends BaseConnectionListener {
@Autowired
private AlarmService alarmService;
@Override @Override
public void operationComplete(ChannelFuture channelFuture) throws Exception { public void operationComplete(ChannelFuture channelFuture) throws Exception {
if (!channelFuture.isSuccess()) { if (!channelFuture.isSuccess()) {
// final EventLoop loop = channelFuture.channel().eventLoop(); //TODO 中转失败进行告警
// loop.schedule(new Runnable() { InetSocketAddress socketAddress = (InetSocketAddress)channelFuture.channel().remoteAddress();
// @Override String remoteIp = socketAddress.getHostString();
// public void run() { String remotePort = String.valueOf(socketAddress.getPort());
// log.debug("ForwardConnectionListener ...operationComplete"); int typeId = 1;
// log.info("forward client connect fail ..." + appId); String title = "中转失败";
//// ForwardManager forwardManager = SpringUtil.getBean(ForwardManager.class); String content = "中转到服务器:" + remoteIp + ":"+ remotePort +"失败";
//// log.debug("channelActive.forwardManager:" + forwardManager); alarmService.addAlarm(typeId,title,content);
//
//// log.warn("The client is not connected and starts to reconnect..." + forwardManager);
//// forwardManager.startTcpClient(appId);
// }
// }, 10L, TimeUnit.SECONDS);
//TODO forward client连接失败,则强制踢掉设备客户端 //TODO forward client连接失败,则强制踢掉设备客户端
DeviceClientBeForcedOfflineEvent deviceClientBeForcedOfflineEvent = new DeviceClientBeForcedOfflineEvent(); DeviceClientBeForcedOfflineEvent deviceClientBeForcedOfflineEvent = new DeviceClientBeForcedOfflineEvent();
......
...@@ -3,27 +3,36 @@ package iot.sixiang.license.operate; ...@@ -3,27 +3,36 @@ package iot.sixiang.license.operate;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import iot.sixiang.license.device.DeviceProtocol; import iot.sixiang.license.device.DeviceProtocol;
import iot.sixiang.license.event.*; import iot.sixiang.license.event.EventPublisher;
import iot.sixiang.license.event.OperateSAMStatusRequestEvent;
import iot.sixiang.license.net.BaseConnectionListener; import iot.sixiang.license.net.BaseConnectionListener;
import iot.sixiang.license.service.AlarmService;
import iot.sixiang.license.util.SpringUtil; import iot.sixiang.license.util.SpringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.net.InetSocketAddress;
@Slf4j @Slf4j
public class OperateConnectionListener extends BaseConnectionListener { public class OperateConnectionListener extends BaseConnectionListener {
@Autowired
private AlarmService alarmService;
@Override @Override
public void operationComplete(ChannelFuture channelFuture) throws Exception { public void operationComplete(ChannelFuture channelFuture) throws Exception {
if (!channelFuture.isSuccess()) { if (!channelFuture.isSuccess()) {
//TODO 失败进行告警 //TODO 失败进行告警
InetSocketAddress socketAddress = (InetSocketAddress)channelFuture.channel().remoteAddress();
String remoteIp = socketAddress.getHostString();
String remotePort = String.valueOf(socketAddress.getPort());
int typeId = 1;
String title = "连接服器失败";
String content = "连接服务器:" + remoteIp + ":"+ remotePort +"失败";
alarmService.addAlarm(typeId,title,content);
} else { } else {
//TODO 查询SAM状态 //TODO 查询SAM状态
OperateSAMStatusRequestEvent operateSAMStatusQueryEvent = new OperateSAMStatusRequestEvent(); OperateSAMStatusRequestEvent operateSAMStatusQueryEvent = new OperateSAMStatusRequestEvent();
short stx = 21930; short stx = 21930;
int len = 2; int len = 2;
byte cmd = 0x5f; byte cmd = 0x5f;
......
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