diff --git a/src/main/java/com/dispose/ability/DisposeAbility.java b/src/main/java/com/dispose/ability/DisposeAbility.java index db8a1ac0..07aa8e98 100644 --- a/src/main/java/com/dispose/ability/DisposeAbility.java +++ b/src/main/java/com/dispose/ability/DisposeAbility.java @@ -1,6 +1,5 @@ package com.dispose.ability; -import com.dispose.common.DDoSAttackType; import com.dispose.common.DisposeCapacityType; import com.dispose.common.ErrorCode; import com.dispose.common.NetflowDirection; @@ -14,7 +13,7 @@ import javax.annotation.Nullable; * * @author */ -public interface DisposeAbility { +public interface DisposeAbility { /** * Init device env. @@ -35,9 +34,9 @@ public interface DisposeAbility { * @param duration the duration * @return the mul return type */ - T runDispose(String ip, DisposeCapacityType capType, + MulReturnType runDispose(String ip, DisposeCapacityType capType, @Nullable NetflowDirection nfDirection, - @Nullable DDoSAttackType attackType, + @Nullable Integer attackType, @Nullable Long duration); /** @@ -50,9 +49,9 @@ public interface DisposeAbility { * @param taskId the task id * @return the mul return type */ - T stopDispose(String ip, DisposeCapacityType capType, + MulReturnType stopDispose(String ip, DisposeCapacityType capType, @Nullable NetflowDirection nfDirection, - @Nullable DDoSAttackType attackType, + @Nullable Integer attackType, @Nullable Long taskId); /** diff --git a/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java index 71dd58a5..5060684d 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java @@ -1,9 +1,7 @@ package com.dispose.ability.impl; -import com.dispose.ability.DeviceDisposeAbility; import com.dispose.ability.DisposeAbility; -import com.dispose.ability.DisposeTaskCallback; -import com.dispose.common.DDoSAttackType; +import com.dispose.common.CommonEnumHandler; import com.dispose.common.DisposeCapacityType; import com.dispose.common.DpTechAttackType; import com.dispose.common.DpTechConfigValue; @@ -22,21 +20,18 @@ import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; import org.apache.wss4j.dom.WSConstants; import org.apache.wss4j.dom.handler.WSHandlerConstants; -import org.springframework.stereotype.Component; import javax.xml.ws.BindingProvider; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.CompletableFuture; /** * The type Dp tech ability. * * @author */ -@Component @Slf4j -public class DpTechAbilityImpl implements DisposeAbility, DeviceDisposeAbility { +public class DpTechAbilityImpl implements DisposeAbility { /** * The Clean type port. */ @@ -94,29 +89,35 @@ public class DpTechAbilityImpl implements DisposeAbility, DeviceDispo * @return the mul return type */ @Override - public ErrorCode runDispose(String ip, DisposeCapacityType capType, - NetflowDirection nfDirection, - DDoSAttackType attackType, - Long duration) { + public MulReturnType runDispose(String ip, DisposeCapacityType capType, + NetflowDirection nfDirection, + Integer attackType, + Long duration) { ErrorCode err = ErrorCode.ERR_OK; try { log.info("++++Begging DPTech Start Cleanup Task: {}, {}, {} ", ip, attackType, nfDirection); - NtcRequestResultInfo ret = cleanTypePort.startAbnormalTaskForUMC(ip, attackType.getValue(), + NtcRequestResultInfo ret = cleanTypePort.startAbnormalTaskForUMC(ip, attackType, nfDirection.getValue()); if (ret.getResultRetVal() != 0) { err = ErrorCode.ERR_CALLDEVICE; + log.error("----Error DPTech Start Cleanup Task: {}, {}, {}, {}", ip, nfDirection, + CommonEnumHandler.codeOf(DpTechAttackType.class, attackType), + ret.getResultInfo().getValue()); } else { - log.error("----Finish DPTech Start Cleanup Task: {} status {}", ip, err); + log.info("----Finish DPTech Start Cleanup Task: {}, {}, {}, {}", ip, nfDirection, + CommonEnumHandler.codeOf(DpTechAttackType.class, attackType), + ret.getResultInfo().getValue()); } } catch (Exception ex) { err = ErrorCode.ERR_SYSTEMEXCEPTION; - log.error("----Exception Error DPTech Start Cleanup Task: {}", ip); + log.error("----Exception DPTech Start Cleanup Task: {}, {}, {}", ip, nfDirection, + CommonEnumHandler.codeOf(DpTechAttackType.class, attackType)); } - return err; + return new MulReturnType<>(err, null); } @@ -131,31 +132,36 @@ public class DpTechAbilityImpl implements DisposeAbility, DeviceDispo * @return the mul return type */ @Override - public ErrorCode stopDispose(String ip, - DisposeCapacityType capType, - NetflowDirection nfDirection, - DDoSAttackType attackType, - Long taskId) { + public MulReturnType stopDispose(String ip, + DisposeCapacityType capType, + NetflowDirection nfDirection, + Integer attackType, + Long taskId) { ErrorCode err = ErrorCode.ERR_OK; try { log.info("++++Begging DPTech Stop Cleanup Task: {}, {}, {} ", ip, attackType, nfDirection); - NtcRequestResultInfo ret = cleanTypePort.stopAbnormalTaskForUMC(ip, attackType.getValue(), + NtcRequestResultInfo ret = cleanTypePort.stopAbnormalTaskForUMC(ip, attackType, nfDirection.getValue()); if (ret.getResultRetVal() != 0) { err = ErrorCode.ERR_CALLDEVICE; - log.error("----Finish DPTech Stop Cleanup Task: {} status {}", ip, err); + log.error("----Error DPTech Stop Cleanup Task: {}, {}, {}, {}", ip, nfDirection, + CommonEnumHandler.codeOf(DpTechAttackType.class, attackType), + ret.getResultInfo().getValue()); } else { - log.info("----Finish DPTech Stop Cleanup Task: {} status {}", ip, err); + log.info("----Finish DPTech Stop Cleanup Task: {}, {}, {}, {}", ip, nfDirection, + CommonEnumHandler.codeOf(DpTechAttackType.class, attackType), + ret.getResultInfo().getValue()); } } catch (Exception ex) { err = ErrorCode.ERR_SYSTEMEXCEPTION; - log.error("----Exception Error DPTech Stop Cleanup Task: {}", ip); + log.error("----Exception DPTech Stop Cleanup Task: {}, {}, {}", ip, nfDirection, + CommonEnumHandler.codeOf(DpTechAttackType.class, attackType)); } - return err; + return new MulReturnType<>(err, null); } /** @@ -208,52 +214,4 @@ public class DpTechAbilityImpl implements DisposeAbility, DeviceDispo public Long toDeviceAttackType(Long ddosAttackTypeMask) { return DpTechAttackType.formDdosAttackTypeMaks(ddosAttackTypeMask); } - - /** - * Device dispose exec error code. - * - * @param callback the callback - * @param capType the cap type - * @param ipAddr the ip addr - * @param args the args - * @return the error code - */ - @Override - public ErrorCode deviceDisposeExec(DisposeTaskCallback callback, DisposeCapacityType capType, String ipAddr, - Object... args) { - CompletableFuture.supplyAsync(() -> runDispose(ipAddr, capType, (NetflowDirection) args[0], - (DDoSAttackType) args[1], null)) - .whenComplete((v, ex) -> { - if (ex != null) { - callback.upgradeStatusCallback(ErrorCode.ERR_SYSTEMEXCEPTION); - } else { - callback.upgradeStatusCallback(v); - } - }); - - return ErrorCode.ERR_OK; - } - - /** - * Device dispose stop error code. - * - * @param callback the callback - * @param capType the cap type - * @param args the args - * @return the error code - */ - @Override - public ErrorCode deviceDisposeStop(DisposeTaskCallback callback, DisposeCapacityType capType, Object... args) { - CompletableFuture.supplyAsync(() -> stopDispose((String) args[0], capType, (NetflowDirection) args[1], - (DDoSAttackType) args[2], null)) - .whenComplete((v, ex) -> { - if (ex != null) { - callback.upgradeStatusCallback(ErrorCode.ERR_SYSTEMEXCEPTION); - } else { - callback.upgradeStatusCallback(v); - } - }); - - return ErrorCode.ERR_OK; - } } diff --git a/src/main/java/com/dispose/ability/impl/HaoHanAbilityImpl.java b/src/main/java/com/dispose/ability/impl/HaoHanAbilityImpl.java index 90a1b93d..53b96606 100644 --- a/src/main/java/com/dispose/ability/impl/HaoHanAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/HaoHanAbilityImpl.java @@ -1,9 +1,6 @@ package com.dispose.ability.impl; -import com.dispose.ability.DeviceDisposeAbility; import com.dispose.ability.DisposeAbility; -import com.dispose.ability.DisposeTaskCallback; -import com.dispose.common.DDoSAttackType; import com.dispose.common.DisposeCapacityType; import com.dispose.common.ErrorCode; import com.dispose.common.NetflowDirection; @@ -24,8 +21,7 @@ import javax.annotation.Nullable; */ @Component @Slf4j -public class HaoHanAbilityImpl implements DisposeAbility>, - DeviceDisposeAbility> { +public class HaoHanAbilityImpl implements DisposeAbility { /** * The constant DISPOSE_PLATFORM_NAME. @@ -65,7 +61,7 @@ public class HaoHanAbilityImpl implements DisposeAbility runDispose(String ip, DisposeCapacityType capType, @Nullable NetflowDirection nfDirection, - @Nullable DDoSAttackType attackType, + @Nullable Integer attackType, @Nullable Long duration) { log.info("++++Begging Haohan Start Cleanup Task: {}", ip); @@ -104,7 +100,7 @@ public class HaoHanAbilityImpl implements DisposeAbility stopDispose(String ip, DisposeCapacityType capType, @Nullable NetflowDirection nfDirection, - @Nullable DDoSAttackType attackType, + @Nullable Integer attackType, @Nullable Long taskId) { log.info("++++Begging Haohan Stop Cleanup Task: {}", taskId); @@ -167,50 +163,4 @@ public class HaoHanAbilityImpl implements DisposeAbility deviceDisposeExec(DisposeTaskCallback callback, - DisposeCapacityType capType, - String ipAddr, - Object... duration) { - MulReturnType ret = runDispose(ipAddr, - capType, - null, - DDoSAttackType.ALL_ATTACKS, - (long) duration[0]); - - callback.upgradeStatusCallback(ret.getFirstParam()); - - return ret; - } - - /** - * Device dispose stop mul return type. - * - * @param capType the cap type - * @param taskId the task id - * @return the mul return type - */ - @Override - public MulReturnType deviceDisposeStop(DisposeTaskCallback callback, - DisposeCapacityType capType, - Object... taskId) { - MulReturnType ret = stopDispose(null, - null, - null, - DDoSAttackType.ALL_ATTACKS, - (long) taskId[0]); - - callback.upgradeStatusCallback(ret.getFirstParam()); - - return ret; - } } diff --git a/src/main/java/com/dispose/ability/impl/VirtualAbilityImpl.java b/src/main/java/com/dispose/ability/impl/VirtualAbilityImpl.java index f3de9e86..349051e2 100644 --- a/src/main/java/com/dispose/ability/impl/VirtualAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/VirtualAbilityImpl.java @@ -1,9 +1,6 @@ package com.dispose.ability.impl; -import com.dispose.ability.DeviceDisposeAbility; import com.dispose.ability.DisposeAbility; -import com.dispose.ability.DisposeTaskCallback; -import com.dispose.common.DDoSAttackType; import com.dispose.common.DisposeCapacityType; import com.dispose.common.ErrorCode; import com.dispose.common.NetflowDirection; @@ -17,7 +14,7 @@ import javax.annotation.Nullable; * * @author */ -public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility { +public class VirtualAbilityImpl implements DisposeAbility { /** * Init device env. * @@ -41,10 +38,10 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisp * @return the mul return type */ @Override - public ErrorCode runDispose(String ip, DisposeCapacityType capType, + public MulReturnType runDispose(String ip, DisposeCapacityType capType, @Nullable NetflowDirection nfDirection, - @Nullable DDoSAttackType attackType, @Nullable Long duration) { - return ErrorCode.ERR_OK; + @Nullable Integer attackType, @Nullable Long duration) { + return new MulReturnType<>(ErrorCode.ERR_OK, null); } /** @@ -58,10 +55,10 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisp * @return the mul return type */ @Override - public ErrorCode stopDispose(String ip, DisposeCapacityType capType, + public MulReturnType stopDispose(String ip, DisposeCapacityType capType, @Nullable NetflowDirection nfDirection, - @Nullable DDoSAttackType attackType, @Nullable Long taskId) { - return ErrorCode.ERR_OK; + @Nullable Integer attackType, @Nullable Long taskId) { + return new MulReturnType<>(ErrorCode.ERR_OK, null); } /** @@ -106,46 +103,4 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisp public Long toDeviceAttackType(Long ddosAttackTypeMask) { return ddosAttackTypeMask; } - - /** - * Device dispose exec error code. - * - * @param capType the cap type - * @param ipAddr the ip addr - * @param duration the duration - * @return the error code - */ - @Override - public ErrorCode deviceDisposeExec(DisposeTaskCallback callback, DisposeCapacityType capType, String ipAddr, - Object... duration) { - ErrorCode ret = runDispose(ipAddr, - capType, - null, - DDoSAttackType.ALL_ATTACKS, - null); - - callback.upgradeStatusCallback(ret); - - return ret; - } - - /** - * Device dispose stop error code. - * - * @param capType the cap type - * @param taskId the task id - * @return the error code - */ - @Override - public ErrorCode deviceDisposeStop(DisposeTaskCallback callback, DisposeCapacityType capType, Object... taskId) { - ErrorCode ret = stopDispose(null, - capType, - null, - DDoSAttackType.ALL_ATTACKS, - null); - - callback.upgradeStatusCallback(ret); - - return ret; - } } diff --git a/src/main/java/com/dispose/common/DisposeCapacityType.java b/src/main/java/com/dispose/common/DisposeCapacityType.java index b83ccd4c..6fadf132 100644 --- a/src/main/java/com/dispose/common/DisposeCapacityType.java +++ b/src/main/java/com/dispose/common/DisposeCapacityType.java @@ -6,27 +6,24 @@ package com.dispose.common; * @author */ public enum DisposeCapacityType implements BaseEnum { + //1.清洗,2.压制,3.高防 /** * The Cleanup. */ CLEANUP(0, "清洗能力"), + /** + * Blackhool dispose capacity type. + */ + BLACKHOOL(1, "压制能力"), /** * The Hidepend. */ - HIDEPEND(1, "高防能力"), - /** - * The Blackhool. - */ - BLACKHOOL(2, "黑洞能力"), + HIDEPEND(2, "高防能力"), /** * The Detecive. */ DETECIVE(3, "检测能力"), - - /** - * Blocking dispose capacity type. - */ - BLOCKING(4, "封堵"); + ; /** * The Code. @@ -49,9 +46,9 @@ public enum DisposeCapacityType implements BaseEnum { } /** - * Gets code. + * Gets value. * - * @return the code + * @return the value */ @Override public Integer getValue() { @@ -59,12 +56,13 @@ public enum DisposeCapacityType implements BaseEnum { } /** - * Gets readme. + * Gets description. * - * @return the readme + * @return the description */ @Override public String getDescription() { return this.readme; } } + diff --git a/src/main/java/com/dispose/common/DpTechAttackType.java b/src/main/java/com/dispose/common/DpTechAttackType.java index d047b4eb..00dfc5c9 100644 --- a/src/main/java/com/dispose/common/DpTechAttackType.java +++ b/src/main/java/com/dispose/common/DpTechAttackType.java @@ -109,6 +109,24 @@ public enum DpTechAttackType implements BaseEnum { .distinct().toArray(DpTechAttackType[]::new)); } + /** + * Mask to ddos attack type list. + * + * @param attackTypeMask the attack type mask + * @return the list + */ + public static List maskToDdosAttackType(Long attackTypeMask) { + List attackTypes = new ArrayList<>(); + + for(DpTechAttackType t : DpTechAttackType.values()) { + if((((long)1 << t.getValue()) & attackTypeMask) != 0) { + attackTypes.add(t); + } + } + + return attackTypes; + } + /** * From ddos attack type value stream. * @@ -223,4 +241,13 @@ public enum DpTechAttackType implements BaseEnum { public String getDescription() { return this.readme; } + + /** + * Gets attack type mask. + * + * @return the attack type mask + */ + public Long getAttackTypeMask() { + return (long)1 << this.code; + } } diff --git a/src/main/java/com/dispose/common/DpTechConfigValue.java b/src/main/java/com/dispose/common/DpTechConfigValue.java index 86883027..898d3aa3 100644 --- a/src/main/java/com/dispose/common/DpTechConfigValue.java +++ b/src/main/java/com/dispose/common/DpTechConfigValue.java @@ -9,9 +9,9 @@ public class DpTechConfigValue { /** * The constant SOAP_CONNECT_TIMEOUT. */ - public static volatile int SOAP_CONNECT_TIMEOUT_SECOND = 60; + public static volatile long SOAP_CONNECT_TIMEOUT_SECOND = 60; /** * The constant SOAP_RECEIVE_TIMEOUT. */ - public static volatile int SOAP_RECEIVE_TIMEOUT_SECOND = 60; + public static volatile long SOAP_RECEIVE_TIMEOUT_SECOND = 60; } diff --git a/src/main/java/com/dispose/config/AuthConfigure.java b/src/main/java/com/dispose/config/AuthConfigure.java index d10d46d4..43163302 100644 --- a/src/main/java/com/dispose/config/AuthConfigure.java +++ b/src/main/java/com/dispose/config/AuthConfigure.java @@ -1,10 +1,15 @@ package com.dispose.config; +import com.dispose.common.AuthConfigValue; 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.Optional; + /** * The type Auth configure. * @@ -14,14 +19,24 @@ import org.springframework.stereotype.Component; @Setter @Component @ConfigurationProperties(prefix = "auth") +@Configuration public class AuthConfigure { /** * The Token timeout minute. */ - private String tokenTimeoutMinute; + private Long tokenTimeoutMinute; /** * The Verify request token. */ - private String verifyRequestToken; + private Boolean verifyRequestToken; + + /** + * Init global value. + */ + @PostConstruct + private void initGlobalValue() { + AuthConfigValue.TOKEN_EXPIRED_TIME_MS = Optional.ofNullable(tokenTimeoutMinute).orElse((long) 30 * 60 * 1000); + AuthConfigValue.VERIFY_REQUEST_TOKEN = Optional.ofNullable(verifyRequestToken).orElse(true); + } } diff --git a/src/main/java/com/dispose/config/DisposeConfigure.java b/src/main/java/com/dispose/config/DisposeConfigure.java index 61d5ce4e..a790478b 100644 --- a/src/main/java/com/dispose/config/DisposeConfigure.java +++ b/src/main/java/com/dispose/config/DisposeConfigure.java @@ -1,10 +1,15 @@ 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.Optional; + /** * The type Dispose configure. * @@ -14,29 +19,38 @@ import org.springframework.stereotype.Component; @Setter @Component @ConfigurationProperties(prefix = "dispose") +@Configuration public class DisposeConfigure { + /** + * The Call error retry times. + */ + public Integer callErrorRetryTimes; /** * The Check protocol timeout. */ - private String checkProtocolTimeout; - + private Boolean checkProtocolTimeout; /** * The Split char. */ private String splitChar; - /** * The Request timeout second. */ - private String requestTimeoutSecond; - + private Long requestTimeoutSecond; /** * The Used privacy protect. */ - private String usedPrivacyProtect; + private Boolean usedPrivacyProtect; /** - * The Call error retry times. + * Init global value. */ - public String callErrorRetryTimes; + @PostConstruct + private void initGlobalValue() { + DisposeConfigValue.REQUEST_TIMEOUT_MS = Optional.ofNullable(requestTimeoutSecond).orElse((long) 5 * 1000); + DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT = Optional.ofNullable(checkProtocolTimeout).orElse(true); + DisposeConfigValue.USED_PRIVACY_PROTECT = Optional.ofNullable(usedPrivacyProtect).orElse(true); + DisposeConfigValue.CALL_ERROR_RETRY_TIMES = Optional.ofNullable(callErrorRetryTimes).orElse(5); + + } } diff --git a/src/main/java/com/dispose/config/DpTechConfigure.java b/src/main/java/com/dispose/config/DpTechConfigure.java index 0316a152..01b02e99 100644 --- a/src/main/java/com/dispose/config/DpTechConfigure.java +++ b/src/main/java/com/dispose/config/DpTechConfigure.java @@ -1,10 +1,15 @@ package com.dispose.config; +import com.dispose.common.DpTechConfigValue; 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.Optional; + /** * The type Dp tech configure. * @@ -14,14 +19,26 @@ import org.springframework.stereotype.Component; @Setter @Component @ConfigurationProperties(prefix = "dptech") +@Configuration public class DpTechConfigure { /** - * The Soap conn timeout. + * The Soap conn timeout second. */ - private String soapConnTimeoutSecond; + private Integer soapConnTimeoutSecond; /** - * The Soap recv timeout. + * The Soap recv timeout second. */ - private String soapRecvTimeoutSecond; + private Integer soapRecvTimeoutSecond; + + + /** + * Init global value. + */ + @PostConstruct + private void initGlobalValue() { + DpTechConfigValue.SOAP_CONNECT_TIMEOUT_SECOND = Optional.ofNullable(soapConnTimeoutSecond).orElse(50) * 1000; + DpTechConfigValue.SOAP_RECEIVE_TIMEOUT_SECOND = Optional.ofNullable(soapRecvTimeoutSecond).orElse(50) * 1000; + } } + diff --git a/src/main/java/com/dispose/manager/DeviceTaskManager.java b/src/main/java/com/dispose/manager/DeviceTaskManager.java index ecf3bdf5..e63f6e57 100644 --- a/src/main/java/com/dispose/manager/DeviceTaskManager.java +++ b/src/main/java/com/dispose/manager/DeviceTaskManager.java @@ -48,6 +48,24 @@ public interface DeviceTaskManager { */ boolean setExecAttackType(Long id, NetflowDirection nf, Long attackTypeMask); + /** + * Exec attack type clean bit. + * + * @param id the id + * @param nf the nf + * @param bit the bit + */ + void execAttackTypeCleanBit(Long id, NetflowDirection nf, Integer bit); + + /** + * Exec attack type set bit. + * + * @param id the id + * @param nf the nf + * @param bit the bit + */ + void execAttackTypeSetBit(Long id, NetflowDirection nf, Integer bit); + /** * Sets attack type status. * @@ -58,6 +76,24 @@ public interface DeviceTaskManager { */ boolean setAttackTypeStatus(Long id, NetflowDirection nf, Long attackTypeMask); + /** + * Attack type status clean bit. + * + * @param id the id + * @param nf the nf + * @param bit the bit + */ + void attackTypeStatusCleanBit(Long id, NetflowDirection nf, Integer bit); + + /** + * Attack type status set bit. + * + * @param id the id + * @param nf the nf + * @param bit the bit + */ + void attackTypeStatusSetBit(Long id, NetflowDirection nf, Integer bit); + /** * Sets task err retry times. * @@ -75,4 +111,12 @@ public interface DeviceTaskManager { * @return the task extern id */ boolean setTaskExternId(Long id, Long externId); + + /** + * Gets task by id. + * + * @param id the id + * @return the task by id + */ + DeviceTask getTaskById(Long id); } diff --git a/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java b/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java index f7f1ee67..df62c916 100644 --- a/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java +++ b/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java @@ -41,10 +41,10 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { } return deviceTaskMapper.addNewTaskInfo(DeviceTask.builder() - .taskId(taskId) - .deviceId(deviceId) - .taskAttackType(attackTypeMask) - .build()) == 1; + .taskId(taskId) + .deviceId(deviceId) + .taskAttackType(attackTypeMask) + .build()) == 1; } /** @@ -81,17 +81,79 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { public boolean setExecAttackType(Long id, NetflowDirection nf, Long attackTypeMask) { int ret = 0; - if(nf != NetflowDirection.DIRECTION_IN) { + if (nf != NetflowDirection.DIRECTION_IN) { ret = deviceTaskMapper.changeExecAttackTypeOutValue(id, attackTypeMask); } - if(nf != NetflowDirection.DIRECTION_OUT) { - ret = deviceTaskMapper.changeAttackTypeStatusInValue(id, attackTypeMask); + if (nf != NetflowDirection.DIRECTION_OUT) { + ret = deviceTaskMapper.changeExecAttackTypeInValue(id, attackTypeMask); } return ret == 1; } + /** + * Exec attack type clean bit. + * + * @param id the id + * @param nf the nf + * @param bit the bit + */ + @Override + public void execAttackTypeCleanBit(Long id, NetflowDirection nf, Integer bit) { + Long execAttackTypeMask; + long bitMask = (long)1 << bit; + + DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id); + + if (devTask == null) { + return; + } + + if (nf != NetflowDirection.DIRECTION_IN) { + execAttackTypeMask = devTask.getExecAttackTypeOut(); + execAttackTypeMask &= ~bitMask; + setExecAttackType(id, NetflowDirection.DIRECTION_OUT, execAttackTypeMask); + } + + if (nf != NetflowDirection.DIRECTION_OUT) { + execAttackTypeMask = devTask.getExecAttackTypeIn(); + execAttackTypeMask &= ~bitMask; + setExecAttackType(id, NetflowDirection.DIRECTION_IN, execAttackTypeMask); + } + } + + /** + * Exec attack type set bit. + * + * @param id the id + * @param nf the nf + * @param bit the bit + */ + @Override + public void execAttackTypeSetBit(Long id, NetflowDirection nf, Integer bit) { + Long execAttackTypeMask; + long bitMask = (long)1 << bit; + + DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id); + + if (devTask == null) { + return; + } + + if (nf != NetflowDirection.DIRECTION_IN) { + execAttackTypeMask = devTask.getExecAttackTypeOut(); + execAttackTypeMask |= bitMask; + setExecAttackType(id, NetflowDirection.DIRECTION_OUT, execAttackTypeMask); + } + + if (nf != NetflowDirection.DIRECTION_OUT) { + execAttackTypeMask = devTask.getExecAttackTypeIn(); + execAttackTypeMask |= bitMask; + setExecAttackType(id, NetflowDirection.DIRECTION_IN, execAttackTypeMask); + } + } + /** * Sets attack type status. * @@ -104,17 +166,79 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { public boolean setAttackTypeStatus(Long id, NetflowDirection nf, Long attackTypeMask) { int ret = 0; - if(nf != NetflowDirection.DIRECTION_IN) { + if (nf != NetflowDirection.DIRECTION_IN) { ret = deviceTaskMapper.changeAttackTypeStatusOutValue(id, attackTypeMask); } - if(nf != NetflowDirection.DIRECTION_OUT) { + if (nf != NetflowDirection.DIRECTION_OUT) { ret = deviceTaskMapper.changeAttackTypeStatusInValue(id, attackTypeMask); } return ret == 1; } + /** + * Attack type status clean bit. + * + * @param id the id + * @param nf the nf + * @param bit the bit + */ + @Override + public void attackTypeStatusCleanBit(Long id, NetflowDirection nf, Integer bit) { + Long attackTypeStatusMask; + long bitMask = (long)1 << bit; + + DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id); + + if (devTask == null) { + return; + } + + if (nf != NetflowDirection.DIRECTION_IN) { + attackTypeStatusMask = devTask.getAttackTypeStatusOut(); + attackTypeStatusMask &= ~bitMask; + setAttackTypeStatus(id, NetflowDirection.DIRECTION_OUT, attackTypeStatusMask); + } + + if (nf != NetflowDirection.DIRECTION_OUT) { + attackTypeStatusMask = devTask.getAttackTypeStatusIn(); + attackTypeStatusMask &= ~bitMask; + setAttackTypeStatus(id, NetflowDirection.DIRECTION_IN, attackTypeStatusMask); + } + } + + /** + * Attack type status set bit. + * + * @param id the id + * @param nf the nf + * @param bit the bit + */ + @Override + public void attackTypeStatusSetBit(Long id, NetflowDirection nf, Integer bit) { + Long attackTypeStatusMask; + long bitMask = (long)1 << bit; + + DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id); + + if (devTask == null) { + return; + } + + if (nf != NetflowDirection.DIRECTION_IN) { + attackTypeStatusMask = devTask.getAttackTypeStatusOut(); + attackTypeStatusMask |= bitMask; + setAttackTypeStatus(id, NetflowDirection.DIRECTION_OUT, attackTypeStatusMask); + } + + if (nf != NetflowDirection.DIRECTION_OUT) { + attackTypeStatusMask = devTask.getAttackTypeStatusIn(); + attackTypeStatusMask |= bitMask; + setAttackTypeStatus(id, NetflowDirection.DIRECTION_IN, attackTypeStatusMask); + } + } + /** * Sets task err retry times. * @@ -138,4 +262,15 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { public boolean setTaskExternId(Long id, Long externId) { return deviceTaskMapper.changeExternId(id, externId) == 1; } + + /** + * Gets task by id. + * + * @param id the id + * @return the task by id + */ + @Override + public DeviceTask getTaskById(Long id) { + return deviceTaskMapper.getTaskInfoById(id); + } } diff --git a/src/main/java/com/dispose/mapper/DeviceTaskMapper.java b/src/main/java/com/dispose/mapper/DeviceTaskMapper.java index d9f8355d..1d0542c8 100644 --- a/src/main/java/com/dispose/mapper/DeviceTaskMapper.java +++ b/src/main/java/com/dispose/mapper/DeviceTaskMapper.java @@ -27,6 +27,14 @@ public interface DeviceTaskMapper { */ List getTaskInfoByTaskId(@Param("taskId") Long taskId); + /** + * Gets task info by id. + * + * @param id the id + * @return the task info by id + */ + DeviceTask getTaskInfoById(@Param("id") Long id); + /** * Add new task info list int. * @@ -90,7 +98,7 @@ public interface DeviceTaskMapper { * @return the int */ int changeExecAttackTypeOutValue(@Param("id") Long id, - @Param("attackTypeValue") Long attackTypeValue); + @Param("attackTypeValue") Long attackTypeValue); /** * Change attack type status in value int. @@ -100,7 +108,7 @@ public interface DeviceTaskMapper { * @return the int */ int changeAttackTypeStatusInValue(@Param("id") Long id, - @Param("attackStatsValue") Long attackStatsValue); + @Param("attackStatsValue") Long attackStatsValue); /** * Change attack type status out value int. @@ -110,7 +118,7 @@ public interface DeviceTaskMapper { * @return the int */ int changeAttackTypeStatusOutValue(@Param("id") Long id, - @Param("attackTypeValue") Long attackStatsValue); + @Param("attackStatsValue") Long attackStatsValue); /** * Change err retry int. diff --git a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java index adcb7ebd..05dfe4bb 100644 --- a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java @@ -1,14 +1,14 @@ package com.dispose.service.impl; -import com.dispose.ability.impl.HaoHanAbilityImpl; -import com.dispose.ability.impl.VirtualAbilityImpl; import com.dispose.common.DisposeConfigValue; import com.dispose.common.DisposeTaskStatus; +import com.dispose.common.DpTechAttackType; import com.dispose.common.ErrorCode; import com.dispose.common.Helper; import com.dispose.common.NetflowDirection; import com.dispose.manager.DeviceTaskManager; import com.dispose.manager.DisposeTaskManager; +import com.dispose.pojo.entity.DeviceTask; import com.dispose.pojo.entity.DisposeTask; import com.dispose.pojo.po.AbilityInfo; import com.dispose.pojo.po.MulReturnType; @@ -95,12 +95,118 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { deviceTaskManager.getNewDisposeDeviceTaskInfo().forEach(v -> { DisposeTask task = disposeTaskManager.getDisposeTaskById(v.getTaskId()); assert task != null; - log.info("Run task {}", task); + log.info("Run task {}, {}", task, v); + MulReturnType ret; AbilityInfo ai = disposeAbilityRouterService.getAbilityDevice(task.getDeviceId()); switch (ai.getDev().getDeviceType()) { case DPTECH_UMC: + // 设置任务状态为启动中 + deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), DisposeTaskStatus.TASK_STARTING); + + // 遍历设备攻击类型 + for (DpTechAttackType t : DpTechAttackType.maskToDdosAttackType(v.getTaskAttackType())) { + // 入方向 + if (task.getFlowDirection() != NetflowDirection.DIRECTION_IN) { + // 已经启动过的任务不再重复启动 + if ((v.getExecAttackTypeOut() & t.getAttackTypeMask()) != 0) { + continue; + } + // 设置启动任务攻击类型状态 + deviceTaskManager.execAttackTypeSetBit(v.getId(), NetflowDirection.DIRECTION_OUT, + t.getValue()); + // 调用迪普设备启动处置任务 + ret = ai.getDb().runDispose(task.getDisposeIp(), task.getDisposeCapacity(), + NetflowDirection.DIRECTION_OUT, t.getValue(), null); + + if (ret.getFirstParam() == ErrorCode.ERR_OK) { + // 标志启动成功 + deviceTaskManager.attackTypeStatusSetBit(v.getId(), NetflowDirection.DIRECTION_OUT, + t.getValue()); + + log.info("DPTECH_UMC setup task {}, {} succeed: {}", t, + NetflowDirection.DIRECTION_OUT, v); + + deviceTaskManager.setTaskErrRetryTimes(v.getId(), 0); + } else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) { + // 设置该任务为新任务,待下次重试启动 + // 记录任务出错重试次数 + v.setErrRetry(v.getErrRetry() + 1); + deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry()); + //清除任务攻击类型启动标志 + deviceTaskManager.execAttackTypeCleanBit(v.getId(), NetflowDirection.DIRECTION_OUT, + t.getValue()); + log.error("DPTECH_UMC setup task {}, {} times {} error: {}", t, + NetflowDirection.DIRECTION_OUT, v.getErrRetry(), v); + } else { + log.info("DPTECH_UMC setup task {}, {} error {}: {}", t, + NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), v); + } + } + + // 出方向 + if (task.getFlowDirection() != NetflowDirection.DIRECTION_OUT) { + // 已经启动过的任务不再重复启动 + if ((v.getExecAttackTypeIn() & t.getAttackTypeMask()) != 0) { + continue; + } + // 设置启动任务攻击类型状态 + deviceTaskManager.execAttackTypeSetBit(v.getId(), NetflowDirection.DIRECTION_IN, + t.getValue()); + // 调用迪普设备启动处置任务 + ret = ai.getDb().runDispose(task.getDisposeIp(), task.getDisposeCapacity(), + NetflowDirection.DIRECTION_IN, t.getValue(), null); + + if (ret.getFirstParam() == ErrorCode.ERR_OK) { + // 标志启动成功 + deviceTaskManager.attackTypeStatusSetBit(v.getId(), NetflowDirection.DIRECTION_IN, + t.getValue()); + + log.info("DPTECH_UMC setup task {}, {} succeed: {}", t, + NetflowDirection.DIRECTION_IN, v); + + deviceTaskManager.setTaskErrRetryTimes(v.getId(), 0); + } else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) { + // 设置该任务为新任务,待下次重试启动 + // 记录任务出错重试次数 + v.setErrRetry(v.getErrRetry() + 1); + deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry()); + //清除任务攻击类型启动标志 + deviceTaskManager.execAttackTypeCleanBit(v.getId(), NetflowDirection.DIRECTION_IN, + t.getValue()); + log.error("DPTECH_UMC setup task {}, {} times {} error: {}", t, + NetflowDirection.DIRECTION_IN, v.getErrRetry(), v); + } else { + log.info("DPTECH_UMC setup task {}, {} error {}: {}", t, + NetflowDirection.DIRECTION_IN, ret.getFirstParam(), v); + } + } + } + + boolean taskSetupSuccessed = true; + DeviceTask devTask = deviceTaskManager.getTaskById(v.getId()); + + if (task.getFlowDirection() != NetflowDirection.DIRECTION_IN) { + if (!devTask.getExecAttackTypeOut().equals(devTask.getTaskAttackType()) + || !devTask.getExecAttackTypeOut().equals(devTask.getAttackTypeStatusOut())) { + taskSetupSuccessed = false; + } + } + + if (task.getFlowDirection() != NetflowDirection.DIRECTION_OUT) { + if (!devTask.getExecAttackTypeIn().equals(devTask.getTaskAttackType()) + || !devTask.getExecAttackTypeIn().equals(devTask.getAttackTypeStatusIn())) { + taskSetupSuccessed = false; + } + } + + if (taskSetupSuccessed) { + // 更改处置任务状态为处置中 + deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), + DisposeTaskStatus.TASK_STARTED); + log.info("DPTECH_UMC setup task succeed: {}", v); + } break; case HAOHAN_PLATFORM: @@ -109,40 +215,35 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { // 设置启动任务攻击类型状态 deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI, v.getTaskAttackType()); - // 调用设备处置能力 - MulReturnType ret = ((HaoHanAbilityImpl) ai.getDb()).deviceDisposeExec( - errorCode -> { - // 启动处置任务成功 - if (errorCode == ErrorCode.ERR_OK) { - // 设置攻击类型任务启动结果 - deviceTaskManager.setAttackTypeStatus(v.getId(), - task.getFlowDirection(), v.getTaskAttackType()); - // 更改处置任务状态为处置中 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), - DisposeTaskStatus.TASK_STARTED); - log.info("HAOHAN_PLATFORM setup task succeed: {}", v); - } else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - // 设置该任务为新任务,待下次重试启动 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), - DisposeTaskStatus.TASK_NEW); - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry() + 1); - log.error("HAOHAN_PLATFORM setup task times {} error {}: {}", - v.getErrRetry(), errorCode, v); - } else { - // 任务出错,不在重试,当做失败任务处理 - deviceTaskManager.setAttackTypeStatus(v.getId(), - task.getFlowDirection(), ~v.getTaskAttackType()); - log.error("HAOHAN_PLATFORM setup task error {}: {}", errorCode, v); - } - }, - task.getDisposeCapacity(), - task.getDisposeIp(), + + ret = ai.getDb().runDispose(task.getDisposeIp(), task.getDisposeCapacity(), null, null, (long) Helper.getTimestampDiffNow(task.getPlanEndTime())); - // 启动任务成功,保存浩瀚任务ID到数据库 if (ret.getFirstParam() == ErrorCode.ERR_OK) { + // 设置攻击类型任务启动结果 + deviceTaskManager.setAttackTypeStatus(v.getId(), + task.getFlowDirection(), v.getTaskAttackType()); + // 更改处置任务状态为处置中 + deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), + DisposeTaskStatus.TASK_STARTED); + + // 记录浩瀚设备返回的任务ID deviceTaskManager.setTaskExternId(v.getId(), ret.getSecondParam()); + + log.info("HAOHAN_PLATFORM setup task succeed: {}, device taskId {}", v, ret.getSecondParam()); + } else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { + // 设置该任务为新任务,待下次重试启动 + deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), + DisposeTaskStatus.TASK_NEW); + // 记录任务出错重试次数 + deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry() + 1); + log.error("HAOHAN_PLATFORM setup task times {} error {}: {}", v.getErrRetry(), + ret.getSecondParam(), v); + } else { + // 任务出错,不在重试,当做失败任务处理 + deviceTaskManager.setAttackTypeStatus(v.getId(), + task.getFlowDirection(), ~v.getTaskAttackType()); + log.error("HAOHAN_PLATFORM setup task error {}: {}", ret.getFirstParam(), v); } break; @@ -153,26 +254,23 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI, v.getTaskAttackType()); - ((VirtualAbilityImpl) ai.getDb()).deviceDisposeExec( - errorCode -> { - // 启动处置任务成功 - if (errorCode == ErrorCode.ERR_OK) { - // 设置攻击类型任务启动结果 - deviceTaskManager.setAttackTypeStatus(v.getId(), - task.getFlowDirection(), v.getTaskAttackType()); - // 更改处置任务状态为处置中 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), - DisposeTaskStatus.TASK_STARTED); - log.info("VIRTUAL_DISPOSE setup task succeed: {}", v); - } else { - // 任务出错,不在重试,当做失败任务处理 - deviceTaskManager.setAttackTypeStatus(v.getId(), - task.getFlowDirection(), ~v.getTaskAttackType()); - log.error("VIRTUAL_DISPOSE setup task error {}: {}", errorCode, v); - } - }, - task.getDisposeCapacity(), - task.getDisposeIp()); + // 调用设备执行处置任务 + ret = ai.getDb().runDispose(task.getDisposeIp(), task.getDisposeCapacity(), null, null, null); + + if (ret.getFirstParam() == ErrorCode.ERR_OK) { + // 设置攻击类型任务启动结果 + deviceTaskManager.setAttackTypeStatus(v.getId(), + task.getFlowDirection(), v.getTaskAttackType()); + // 更改处置任务状态为处置中 + deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), + DisposeTaskStatus.TASK_STARTED); + log.info("VIRTUAL_DISPOSE setup task succeed: {}", v); + } else { + // 任务出错,不在重试,当做失败任务处理 + deviceTaskManager.setAttackTypeStatus(v.getId(), + task.getFlowDirection(), ~v.getTaskAttackType()); + log.error("VIRTUAL_DISPOSE setup task error {}: {}", ret.getFirstParam(), v); + } break; default: diff --git a/src/main/java/com/dispose/setup/SystemInitial.java b/src/main/java/com/dispose/setup/SystemInitial.java index ba760659..b3beda47 100644 --- a/src/main/java/com/dispose/setup/SystemInitial.java +++ b/src/main/java/com/dispose/setup/SystemInitial.java @@ -1,12 +1,6 @@ package com.dispose.setup; -import com.dispose.common.AuthConfigValue; -import com.dispose.common.DisposeConfigValue; -import com.dispose.common.DpTechConfigValue; import com.dispose.common.ErrorCode; -import com.dispose.config.AuthConfigure; -import com.dispose.config.DisposeConfigure; -import com.dispose.config.DpTechConfigure; import com.dispose.pojo.po.MulReturnType; import com.dispose.pojo.vo.DeviceFirewareInfo; import com.dispose.service.DisposeAbilityRouterService; @@ -25,24 +19,6 @@ import javax.annotation.Resource; @Component @Slf4j public class SystemInitial implements CommandLineRunner { - /** - * The Dispose configure. - */ - @Resource - DisposeConfigure disposeConfigure; - - /** - * The Auth configure. - */ - @Resource - AuthConfigure authConfigure; - - /** - * The Dp tech configure. - */ - @Resource - DpTechConfigure dpTechConfigure; - /** * The Dispose ability router service. */ @@ -50,62 +26,8 @@ public class SystemInitial implements CommandLineRunner { private DisposeAbilityRouterService disposeAbilityRouterService; /** - * Load configure. + * Sets ability device. */ - private void loadConfigure() { - - try { - AuthConfigValue.TOKEN_EXPIRED_TIME_MS = Long.parseLong(authConfigure.getTokenTimeoutMinute()) * 60 * 1000; - } catch (Exception ex) { - log.error("load TOKEN_EXPIRED_TIME_MS configure error: {}", ex.getMessage()); - } - - try { - AuthConfigValue.VERIFY_REQUEST_TOKEN = Boolean.parseBoolean(authConfigure.getVerifyRequestToken()); - } catch (Exception ex) { - log.error("load VERIFY_REQUEST_TOKEN configure error: {}", ex.getMessage()); - } - - try { - DpTechConfigValue.SOAP_CONNECT_TIMEOUT_SECOND = - Integer.parseInt(dpTechConfigure.getSoapConnTimeoutSecond()); - } catch (Exception ex) { - log.error("load SOAP_CONNECT_TIMEOUT_SECOND configure error: {}", ex.getMessage()); - } - - try { - DpTechConfigValue.SOAP_RECEIVE_TIMEOUT_SECOND = - Integer.parseInt(dpTechConfigure.getSoapRecvTimeoutSecond()); - } catch (Exception ex) { - log.error("load SOAP_RECEIVE_TIMEOUT_SECOND configure error: {}", ex.getMessage()); - } - - try { - DisposeConfigValue.REQUEST_TIMEOUT_MS = Integer.parseInt(disposeConfigure.getRequestTimeoutSecond()) * 1000; - } catch (Exception ex) { - log.error("load REQUEST_TIMEOUT_MS configure error: {}", ex.getMessage()); - } - - try { - DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT = - Boolean.parseBoolean(disposeConfigure.getCheckProtocolTimeout()); - } catch (Exception ex) { - log.error("load CHECK_PROTO_REQUEST_TIMEOUT configure error: {}", ex.getMessage()); - } - - try { - DisposeConfigValue.USED_PRIVACY_PROTECT = Boolean.parseBoolean(disposeConfigure.getUsedPrivacyProtect()); - } catch (Exception ex) { - log.error("load USED_PRIVACY_PROTECT configure error: {}", ex.getMessage()); - } - - try { - DisposeConfigValue.CALL_ERROR_RETRY_TIMES = Integer.parseInt(disposeConfigure.getCallErrorRetryTimes()); - } catch (Exception ex) { - log.error("load CALL_ERROR_RETRY_TIMES configure error: {}", ex.getMessage()); - } - } - @Async("bizExecutor") public void setupAbilityDevice() { disposeAbilityRouterService.getAllAbilityDevices().forEach(v -> { @@ -118,7 +40,6 @@ public class SystemInitial implements CommandLineRunner { }); } - /** * Run. * @@ -126,9 +47,6 @@ public class SystemInitial implements CommandLineRunner { */ @Override public void run(String... args) { - // 系统初始化入口 - loadConfigure(); - // 初始化处置能力设备 setupAbilityDevice(); } diff --git a/src/main/resources/mappers/DeviceTask.xml b/src/main/resources/mappers/DeviceTask.xml index a0aec51c..9ec95d9d 100644 --- a/src/main/resources/mappers/DeviceTask.xml +++ b/src/main/resources/mappers/DeviceTask.xml @@ -39,6 +39,12 @@ ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}) + + SELECT * FROM device_task - WHERE status = ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()} + WHERE status = ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()} OR + status = ${@com.dispose.common.DisposeTaskStatus@TASK_STARTING.getValue()}