perf: 优化线程池和关机处理

dev
huangfeng 7 months ago
parent 1d355af372
commit 00166e3a04

@ -3,6 +3,7 @@ package com.xydl.cac.iec;
import com.beanit.iec61850bean.*; import com.beanit.iec61850bean.*;
import com.xydl.cac.entity.IcdIed; import com.xydl.cac.entity.IcdIed;
import com.xydl.cac.entity.constants.Constants; import com.xydl.cac.entity.constants.Constants;
import com.xydl.cac.model.StaticVariable;
import com.xydl.cac.socket.WebSocketServer; import com.xydl.cac.socket.WebSocketServer;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -82,6 +83,9 @@ public class IecClient implements ClientEventListener {
} }
private void reconnect() throws Exception { private void reconnect() throws Exception {
if (StaticVariable.shutdown == 1) {
return;
}
clientAssociation = clientSap.associate(InetAddress.getByName(ied.getIp()), ied.getPort(), null, this); clientAssociation = clientSap.associate(InetAddress.getByName(ied.getIp()), ied.getPort(), null, this);
clientAssociation.setServerModel(serverModel); clientAssociation.setServerModel(serverModel);
log.info("61850订阅断线重连成功, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", port=" + ied.getPort()); log.info("61850订阅断线重连成功, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", port=" + ied.getPort());
@ -165,7 +169,7 @@ public class IecClient implements ClientEventListener {
if (keep) { if (keep) {
this.disableReporting(); this.disableReporting();
this.disconnect(); this.disconnect();
while (retry > 0) { while (retry > 0 && StaticVariable.shutdown == 0) {
retry--; retry--;
try { try {
if (retry >= 5) { if (retry >= 5) {

@ -102,6 +102,7 @@ public class RealTimeDataService {
@PreDestroy @PreDestroy
private void stop() { private void stop() {
log.info("关闭61850订阅服务."); log.info("关闭61850订阅服务.");
StaticVariable.shutdown = 1;
List<Integer> idList = new ArrayList<>(); List<Integer> idList = new ArrayList<>();
Iterator<Integer> it = StaticVariable.realTimeClientMap.keySet().iterator(); Iterator<Integer> it = StaticVariable.realTimeClientMap.keySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {

@ -18,6 +18,7 @@ public class StaticVariable {
public static HashMap<String, String> paramRelationMap = new HashMap<>(); public static HashMap<String, String> paramRelationMap = new HashMap<>();
public static HashMap<String, String> doneWarnMap = new HashMap<>(); public static HashMap<String, String> doneWarnMap = new HashMap<>();
public static HashMap<Integer, IecClient> realTimeClientMap = new HashMap<>(); public static HashMap<Integer, IecClient> realTimeClientMap = new HashMap<>();
public static int shutdown = 0;
public static HashMap<String, String> unit_Cache = new HashMap<>(); public static HashMap<String, String> unit_Cache = new HashMap<>();
public static List<ModevType> modevType_Cache = null; public static List<ModevType> modevType_Cache = null;

@ -30,6 +30,9 @@ spring:
max-file-size: 100MB max-file-size: 100MB
max-request-size: 100MB max-request-size: 100MB
task: task:
execution:
pool:
core-size: 10
scheduling: scheduling:
pool: pool:
size: 10 size: 10

@ -30,6 +30,9 @@ spring:
max-file-size: 100MB max-file-size: 100MB
max-request-size: 100MB max-request-size: 100MB
task: task:
execution:
pool:
core-size: 10
scheduling: scheduling:
pool: pool:
size: 10 size: 10

Loading…
Cancel
Save