parent
ac7ec41aa5
commit
fca424a84e
|
@ -6,6 +6,8 @@ dispose.split_char=,
|
||||||
dispose.request-timeout-second=5
|
dispose.request-timeout-second=5
|
||||||
# 是否开启隐私保护
|
# 是否开启隐私保护
|
||||||
dispose.used-privacy-protect=false
|
dispose.used-privacy-protect=false
|
||||||
|
# 集团一键处置设备状态轮询时间
|
||||||
|
dispose.cmhi-device-query-period=3
|
||||||
|
|
||||||
dispose.call-error-retry-times=3
|
dispose.call-error-retry-times=3
|
||||||
# 分页配置项
|
# 分页配置项
|
||||||
|
@ -52,4 +54,5 @@ trust.auth-hosts=127.0.0.12,::1
|
||||||
|
|
||||||
#需要调试的设备IP/IP+端口
|
#需要调试的设备IP/IP+端口
|
||||||
# 主机,多个主机逗号(,)分割
|
# 主机,多个主机逗号(,)分割
|
||||||
device.log-hosts=https://111.28.2.17:443,http://172.21.44.239
|
device.log-hosts=https://111.28.2.17:443,http://172.21.44.239,https://183.230.71.73:8888/
|
||||||
|
device.log-paths=login,logout,capacity,start,stop,get,linkstatus
|
|
@ -67,8 +67,18 @@ public class DisposeConfigValue {
|
||||||
*/
|
*/
|
||||||
public static final long HEART_PERIOD_OF_SECOND = 30;
|
public static final long HEART_PERIOD_OF_SECOND = 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 集团一键处置设备状态查询周期
|
||||||
|
*/
|
||||||
|
public static volatile int CMHI_DEVICE_QUERY_PERIOD = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constant LOG_HOSTS.
|
* The constant LOG_HOSTS.
|
||||||
*/
|
*/
|
||||||
public static final List<String> LOG_HOSTS = new ArrayList<>();
|
public static final List<String> LOG_HOSTS = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constant LOG_PATHS.
|
||||||
|
*/
|
||||||
|
public static final List<String> LOG_PATHS = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,10 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ -25,18 +27,24 @@ import java.util.Optional;
|
||||||
@ConfigurationProperties(prefix = "device")
|
@ConfigurationProperties(prefix = "device")
|
||||||
@Configuration
|
@Configuration
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DeviceLogConfigure {
|
public class DeviceLogConfigure implements WebMvcConfigurer {
|
||||||
/**
|
/**
|
||||||
* The Log hosts.
|
* The Log hosts.
|
||||||
*/
|
*/
|
||||||
private String[] logHosts;
|
private String[] logHosts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Log paths.
|
||||||
|
*/
|
||||||
|
private String[] logPaths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init global value.
|
* Init global value.
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initGlobalValue() {
|
private void initGlobalValue() {
|
||||||
DisposeConfigValue.LOG_HOSTS.clear();
|
DisposeConfigValue.LOG_HOSTS.clear();
|
||||||
|
DisposeConfigValue.LOG_PATHS.clear();
|
||||||
|
|
||||||
for (String s : Optional.ofNullable(logHosts).orElse(new String[]{""})) {
|
for (String s : Optional.ofNullable(logHosts).orElse(new String[]{""})) {
|
||||||
if (s.toLowerCase(Locale.ROOT).startsWith("http")) {
|
if (s.toLowerCase(Locale.ROOT).startsWith("http")) {
|
||||||
|
@ -44,6 +52,15 @@ public class DeviceLogConfigure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisposeConfigValue.LOG_PATHS.addAll(Arrays.asList(Optional.ofNullable(logPaths).orElse(new String[]{""})));
|
||||||
log.debug("Log device: {}", DisposeConfigValue.LOG_HOSTS);
|
log.debug("Log device: {}", DisposeConfigValue.LOG_HOSTS);
|
||||||
|
log.debug("Log path: {}", DisposeConfigValue.LOG_PATHS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh config value.
|
||||||
|
*/
|
||||||
|
public void refreshConfigValue() {
|
||||||
|
initGlobalValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,17 @@ public class DisposeConfigure {
|
||||||
*/
|
*/
|
||||||
private Integer minSplitPageSize;
|
private Integer minSplitPageSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Cmhi device query period.
|
||||||
|
*/
|
||||||
|
private Integer cmhiDeviceQueryPeriod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init global value.
|
* Init global value.
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initGlobalValue() {
|
private void initGlobalValue() {
|
||||||
|
DisposeConfigValue.CMHI_DEVICE_QUERY_PERIOD = Optional.ofNullable(cmhiDeviceQueryPeriod).orElse(1);
|
||||||
DisposeConfigValue.REQUEST_TIMEOUT_MS = Optional.ofNullable(requestTimeoutSecond).orElse((long) 5) * 1000;
|
DisposeConfigValue.REQUEST_TIMEOUT_MS = Optional.ofNullable(requestTimeoutSecond).orElse((long) 5) * 1000;
|
||||||
DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT = Optional.ofNullable(checkProtocolTimeout).orElse(true);
|
DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT = Optional.ofNullable(checkProtocolTimeout).orElse(true);
|
||||||
DisposeConfigValue.USED_PRIVACY_PROTECT = Optional.ofNullable(usedPrivacyProtect).orElse(true);
|
DisposeConfigValue.USED_PRIVACY_PROTECT = Optional.ofNullable(usedPrivacyProtect).orElse(true);
|
||||||
|
|
|
@ -225,7 +225,8 @@ public class RestfulInterface {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DisposeConfigValue.LOG_HOSTS.stream().anyMatch(url::startsWith)) {
|
if (DisposeConfigValue.LOG_HOSTS.stream().anyMatch(url::startsWith)
|
||||||
|
&& DisposeConfigValue.LOG_PATHS.stream().anyMatch(url::endsWith)) {
|
||||||
if(reqJson.length() > 0) {
|
if(reqJson.length() > 0) {
|
||||||
log.debug("Restful response: {} {}, {}: \n+++{}\n---{}", reqType.name(), url, token, reqJson, svrResp);
|
log.debug("Restful response: {} {}, {}: \n+++{}\n---{}", reqType.name(), url, token, reqJson, svrResp);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -60,6 +60,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
@Resource
|
@Resource
|
||||||
private DisposeAbilityRouterService disposeAbilityRouterService;
|
private DisposeAbilityRouterService disposeAbilityRouterService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Timer cnt.
|
||||||
|
*/
|
||||||
|
private long timerCnt = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is carry ip boolean.
|
* Is carry ip boolean.
|
||||||
|
@ -157,6 +162,14 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dp tech device exe.
|
||||||
|
*
|
||||||
|
* @param ai the ai
|
||||||
|
* @param deviceTask the device task
|
||||||
|
* @param disposeTask the dispose task
|
||||||
|
* @param netflowDirection the netflow direction
|
||||||
|
*/
|
||||||
private void dpTechDeviceExe(AbilityInfo ai,
|
private void dpTechDeviceExe(AbilityInfo ai,
|
||||||
DeviceTask deviceTask,
|
DeviceTask deviceTask,
|
||||||
DisposeTask disposeTask, NetflowDirection netflowDirection) {
|
DisposeTask disposeTask, NetflowDirection netflowDirection) {
|
||||||
|
@ -751,6 +764,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
deviceTaskStopSchedule();
|
deviceTaskStopSchedule();
|
||||||
|
|
||||||
// 定时刷新设备任务状态
|
// 定时刷新设备任务状态
|
||||||
|
if (timerCnt++ % DisposeConfigValue.CMHI_DEVICE_QUERY_PERIOD == 0) {
|
||||||
deviceTaskStatusSchedule();
|
deviceTaskStatusSchedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.dispose.task;
|
||||||
|
|
||||||
|
import com.dispose.common.DisposeConfigValue;
|
||||||
|
import com.dispose.config.DeviceLogConfigure;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Refresh config.
|
||||||
|
* @author xajhu
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class RefreshConfigTask {
|
||||||
|
/**
|
||||||
|
* The Device log configure.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private DeviceLogConfigure deviceLogConfigure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh config file task.
|
||||||
|
*/
|
||||||
|
@Async("bizExecutor")
|
||||||
|
@Scheduled(cron = "0/1 * * * * ?")
|
||||||
|
public void refreshConfigFileTask() {
|
||||||
|
deviceLogConfigure.refreshConfigValue();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue