REM:
1.  增加线上设备调试信息配置项
2.  增加线上设备请求、响应json调试信息
3.  版本更新到 2.0.8.9
This commit is contained in:
HuangXin 2021-10-28 09:16:26 +08:00
parent 50641d2a5f
commit 2ede6d0503
8 changed files with 74 additions and 27 deletions

View File

@ -49,3 +49,7 @@ trust.auth-white-list-check=true
trust.auth-host-token=165B2AA40395fA27278E59eEd4DD5EA490DA175344DE2673A5B17D3760E12F0 trust.auth-host-token=165B2AA40395fA27278E59eEd4DD5EA490DA175344DE2673A5B17D3760E12F0
# 白名单主机,多个主机逗号(,)分割 # 白名单主机,多个主机逗号(,)分割
trust.auth-hosts=127.0.0.12,::1 trust.auth-hosts=127.0.0.12,::1
#需要调试的设备IP/IP+端口
# 主机,多个主机逗号(,)分割
device.log-hosts=https://111.28.2.17:443,http://172.21.44.239

View File

@ -3,6 +3,7 @@
<property name="LOG_PATH" value="./logs"/> <property name="LOG_PATH" value="./logs"/>
<property name="LOG_LEVEL" value="info"/> <property name="LOG_LEVEL" value="info"/>
<property name="SVR_LOG_LEVEL" value="info"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder charset="UTF-8"> <encoder charset="UTF-8">
@ -45,10 +46,15 @@
</encoder> </encoder>
</appender> </appender>
<logger name="com.cmcc.hy.phoenix" level="${LOG_LEVEL}" additivity="false"> <logger name="com.dispose" level="${SVR_LOG_LEVEL}" additivity="false">
<appender-ref ref="BIZ"/> <appender-ref ref="BIZ"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
</logger>
<logger name="com.dispose.mapper" level="${LOG_LEVEL}"
additivity="false">
<appender-ref ref="DATA"/>
<appender-ref ref="CONSOLE"/>
</logger> </logger>
<logger name="com.cmcc.hy.phoenix.mapper" level="${LOG_LEVEL}" <logger name="com.cmcc.hy.phoenix.mapper" level="${LOG_LEVEL}"

View File

@ -17,7 +17,7 @@
</parent> </parent>
<groupId>com.dispose</groupId> <groupId>com.dispose</groupId>
<artifactId>dispose_platform</artifactId> <artifactId>dispose_platform</artifactId>
<version>2.0.8.8</version> <version>2.0.8.9</version>
<name>dispose_platform</name> <name>dispose_platform</name>
<description>Dispose Platform</description> <description>Dispose Platform</description>
<dependencies> <dependencies>

View File

@ -582,8 +582,6 @@ public class PengXinAbilityImpl implements DisposeAbility {
*/ */
@Override @Override
public void periodTaskRuntime() { public void periodTaskRuntime() {
log.debug("++++PengXin Period Task Running");
// 集团一键处置线上环境不再定时获取设备能力信息 // 集团一键处置线上环境不再定时获取设备能力信息
// 更新防护对象 // 更新防护对象
//getDisposeDeviceProtectObject(); //getDisposeDeviceProtectObject();
@ -592,8 +590,6 @@ public class PengXinAbilityImpl implements DisposeAbility {
if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) { if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {
devGetLinkStatus(); devGetLinkStatus();
} }
log.debug("----PengXin Period Task Running");
} }
/** /**

View File

@ -1,5 +1,8 @@
package com.dispose.common; package com.dispose.common;
import java.util.ArrayList;
import java.util.List;
/** /**
* The type Dispose config value. * The type Dispose config value.
* *
@ -63,4 +66,9 @@ public class DisposeConfigValue {
* The constant HEART_PERIOD_OF_SECOND. * The constant HEART_PERIOD_OF_SECOND.
*/ */
public static final long HEART_PERIOD_OF_SECOND = 30; public static final long HEART_PERIOD_OF_SECOND = 30;
/**
* The constant LOG_HOSTS.
*/
public static final List<String> LOG_HOSTS = new ArrayList<>();
} }

View File

@ -0,0 +1,30 @@
package com.dispose.config;
import com.dispose.common.DisposeConfigValue;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Locale;
import java.util.Optional;
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "device")
@Configuration
public class DeviceLogConfigure {
private String[] logHosts;
@PostConstruct
private void initGlobalValue() {
for (String s : Optional.ofNullable(logHosts).orElse(new String[]{""})) {
if (s.toLowerCase(Locale.ROOT).startsWith("http")) {
DisposeConfigValue.LOG_HOSTS.add(s);
}
}
}
}

View File

@ -29,16 +29,15 @@ public class RestfulInterface {
* The constant OBJECT_MAPPER. * The constant OBJECT_MAPPER.
*/ */
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
/**
* The constant timeOutValue.
*/
private static int timeOutValue = new Long(DisposeConfigValue.REQUEST_TIMEOUT_MS).intValue();
static { static {
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
} }
/**
* The constant timeOutValue.
*/
private static int timeOutValue = new Long(DisposeConfigValue.REQUEST_TIMEOUT_MS).intValue();
/** /**
* Instantiates a new Restful interface. * Instantiates a new Restful interface.
*/ */
@ -197,6 +196,7 @@ public class RestfulInterface {
public static <T, E> ProtocolRespDTO<T> baseProRun(String url, String token, E obj, Class<T> subClass, public static <T, E> ProtocolRespDTO<T> baseProRun(String url, String token, E obj, Class<T> subClass,
RequestMethod reqType) { RequestMethod reqType) {
String svrResp = null; String svrResp = null;
String reqJson = "";
try { try {
Map<String, String> httpHeadMap = new HashMap<>(2); Map<String, String> httpHeadMap = new HashMap<>(2);
@ -207,15 +207,12 @@ public class RestfulInterface {
httpHeadMap.put(String.valueOf(Header.AUTHORIZATION), ConstValue.STRING_HTTP_AUTH_HEAD + token); httpHeadMap.put(String.valueOf(Header.AUTHORIZATION), ConstValue.STRING_HTTP_AUTH_HEAD + token);
} }
String reqJson = OBJECT_MAPPER.writeValueAsString(obj);
log.debug("Restful request: {}, {}: {}", url, token, reqJson);
switch (reqType) { switch (reqType) {
case GET: case GET:
svrResp = getJson(url, httpHeadMap).body(); svrResp = getJson(url, httpHeadMap).body();
break; break;
case POST: case POST:
reqJson = OBJECT_MAPPER.writeValueAsString(obj);
svrResp = postJson(url, httpHeadMap, reqJson).body(); svrResp = postJson(url, httpHeadMap, reqJson).body();
break; break;
default: default:
@ -228,17 +225,23 @@ public class RestfulInterface {
return null; return null;
} }
log.debug("Restful response: {}, {}: {}", url, token, svrResp); if (DisposeConfigValue.LOG_HOSTS.stream().anyMatch(url::startsWith)) {
if(reqJson.length() > 0) {
log.debug("Restful response: {} {}, {}: \n+++{}\n---{}", reqType.name(), url, token, reqJson, svrResp);
} else {
log.debug("Restful response: {} {}, {}: \n{}", reqType.name(), url, token, svrResp);
}
}
return OBJECT_MAPPER.readValue(svrResp, return OBJECT_MAPPER.readValue(svrResp,
new TypeReference<ProtocolRespDTO<T>>() { new TypeReference<ProtocolRespDTO<T>>() {
@Override @Override
public Type getType() { public Type getType() {
return createRespType(subClass); return createRespType(subClass);
} }
}); });
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
log.error("System exception: \nRequest:{}, {}\nException{}", url, svrResp, e); log.error("System exception: Request:{}, \n+++{}\n---{} Exception {}", url, reqJson, svrResp, e);
return null; return null;
} }
} }
@ -307,11 +310,11 @@ public class RestfulInterface {
* *
* @param url the url * @param url the url
* @param token the token * @param token the token
* @param reqBody the obj * @param reqBody the obj
* @param reqType the req type * @param reqType the req type
* @return the t * @return the t
*/ */
public static HttpResponse huaWeiFireWallProRun(String url, String token, String reqBody, RequestMethod reqType) { public static HttpResponse huaWeiFireWallProRun(String url, String token, String reqBody, RequestMethod reqType) {
String body = ""; String body = "";
HttpResponse svrResp = null; HttpResponse svrResp = null;
@ -370,6 +373,6 @@ public class RestfulInterface {
Type[] types = new Type[1]; Type[] types = new Type[1];
types[0] = c; types[0] = c;
return ParameterizedTypeImpl.make(ProtocolRespDTO.class, types, return ParameterizedTypeImpl.make(ProtocolRespDTO.class, types,
ProtocolRespDTO.class.getDeclaringClass()); ProtocolRespDTO.class.getDeclaringClass());
} }
} }

View File

@ -97,7 +97,7 @@ public class PengXinInterface {
} }
try { try {
ErrorCode err = CommonEnumHandler.codeOf(ErrorCode.class, rspInfo.getCode()); ErrorCode err = CommonEnumHandler.codeOf(ErrorCode.class, rspInfo.getMsgContent().getStatus());
if (err == null) { if (err == null) {
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;