diff --git a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java index 878ded18..2421c677 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java @@ -137,7 +137,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { dpBypassManager.getTractionStrategyName().remove(v.getPolicyName()); } else { log.info("!!!!Remove Traction Strategy {} Error: {}", v.getPolicyName(), - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } } @@ -161,7 +161,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { dpBypassManager.getProtectStrategy().remove(objName); } else { log.error("!!!!Disable Protection Strategy Template {} Error: {}", objName, - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } break; @@ -177,7 +177,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { dpBypassManager.getProtectObject().remove(objName); } else { log.error("!!!!Delete Protection Object {} Error: {}", objName, - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } @@ -209,18 +209,18 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 创建对象 NtcRequestResultInfo ret = getCleanTypePort() .addProtectionObjectForUMC("", - allCleanupDevices, - objName, - ipSegment, - ipType, - 0); + allCleanupDevices, + objName, + ipSegment, + ipType, + 0); if (ret.getResultRetVal() == 0) { log.debug("Add Protection Object {} Succeed", objName); } else { log.error("!!!!Add Protection Object {}, {}, {} Error: {}", objName, ipSegment, ipType, - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } @@ -231,7 +231,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { log.debug("{} Link Protection Strategy Template {} Succeed", objName, template); } else { log.error("!!!!{} Link Protection Strategy Template {} Error: {}", objName, template, - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } @@ -280,14 +280,14 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 创建旁路手动牵引策略 ret = getCleanTypePort().addBypassManualTractionStrategyForUMC(tractionName, - objName, - getIpSegmentFormat(disposeObject)); + objName, + getIpSegmentFormat(disposeObject)); if (ret.getResultRetVal() == 0) { log.debug("----Finish Create Traction Strategy {} Succeed", tractionName); return ErrorCode.ERR_OK; } else { log.error("----Create Traction Strategy Error: {}, {}, {}, {}", tractionName, - objName, disposeObject, ret.getResultInfo().getValue()); + objName, disposeObject, ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } } @@ -316,7 +316,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (ret.getResultRetVal() != 0) { err = ErrorCode.ERR_CALLDEVICE; log.error("----Error Start Traction Strategy: {}, {}, {}", objName, disposeObject, - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); } else { log.debug("----Finish Start Traction Strategy: {}, {}", objName, disposeObject); } @@ -392,7 +392,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { return ErrorCode.ERR_OK; } else { log.error("!!!!Remove Traction Strategy {} Error: {}", tractionName, - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } } @@ -421,7 +421,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { log.debug("Disable Protection Strategy Template {} Succeed", objName); } else { log.error("!!!!Disable Protection Strategy Template {} Error: {}", objName, - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } @@ -437,7 +437,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { log.debug("{} Link Protection Strategy Template {} Succeed", objName, newTemplate); } else { log.error("!!!!{} Link Protection Strategy Template {} Error: {}", objName, newTemplate, - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } @@ -461,7 +461,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 未找到合适的模板 if (TemplateConfigure.UMC_TEMPLATE.stream().noneMatch(m -> m.getName().equals(template))) { log.error("!!!!{} Can't Math Template: {}, {} From {}", v.getServiceId(), v.getServiceType(), - v.getServiceBandwidth(), TemplateConfigure.UMC_TEMPLATE); + v.getServiceBandwidth(), TemplateConfigure.UMC_TEMPLATE); return; } @@ -538,9 +538,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 更新防护对象 if (upgradeIpSegment) { err = upgradeProtectObject(protectName, - ipSegment.get(t), - IpAddrType.IPV4.equals(t) ? 0 : 1, - template); + ipSegment.get(t), + IpAddrType.IPV4.equals(t) ? 0 : 1, + template); if (err == ErrorCode.ERR_OK) { log.debug("Add Protection Object {} Succeed", protectName); } else { @@ -549,9 +549,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { } } else { err = createProtectObject(protectName, - ipSegment.get(t), - IpAddrType.IPV4.equals(t) ? 0 : 1, - template); + ipSegment.get(t), + IpAddrType.IPV4.equals(t) ? 0 : 1, + template); if (err == ErrorCode.ERR_OK) { log.debug("Add Protection Object {} Succeed", protectName); } else { @@ -586,23 +586,6 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { } } - -// dpBypassManager.getProtectObject().values().forEach(v -> { -// String serviceId = v.getProtectName() -// .replace(objectPrefix + "_", "") -// .replace("_" + IpAddrType.IPV4.getDescription(), "") -// .replace("_" + IpAddrType.IPV6.getDescription(), ""); -// -// // UMC上面存在对象已经失效 -// if (disposeServiceGroup.values().stream().noneMatch(k -> serviceId.equals(k.getServiceId()))) { -// log.info("++++Remove UMC Unused Protect Object: {}", v.getProtectName()); -// ErrorCode err = removeProtectObject(v.getProtectName()); -// -// if (err != ErrorCode.ERR_OK) { -// log.error("!!!!Remove Protect Object Error: {}", v.getProtectName()); -// } -// } -// }); } /** @@ -742,7 +725,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { log.debug("----Finish DPTech Get All Protection Strategy Association Relation"); } catch (Exception ex) { log.error("----Exception DPTech Get All Protection Strategy Association Relation: {}", - ex.getMessage()); + ex.getMessage()); } } @@ -788,8 +771,8 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 删除非法的防护对象 if (!objName.startsWith(objectPrefix)) { log.error("!!!!Found Unexpect Protection Object [{}, {}], Deleted it.", - objName, - k.getIpSegment().getValue()); + objName, + k.getIpSegment().getValue()); NtcRequestResultInfo rsp = getCleanTypePort().deleteProtectionObjectForUMC(objName); @@ -837,7 +820,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { log.warn("!!!!Remove Exception Protection IpSegment {}, {} Succeed", objName, v); } else { log.warn("!!!!Remove Exception Protection IpSegment {}, {} Error: {}", objName, v, - rsp.getResultInfo().getValue()); + rsp.getResultInfo().getValue()); } } @@ -912,7 +895,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (err != ErrorCode.ERR_OK) { log.error("----Error DPTech Start Cleanup Task, Create Traction Strategy Error: {}, {}, {}", - protectObjName, disposeObject, err); + protectObjName, disposeObject, err); return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null); } @@ -921,7 +904,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (err != ErrorCode.ERR_OK) { log.error("----Error DPTech Start Cleanup Task, Start Traction Strategy Error: {}, {}, {}", - protectObjName, disposeObject, err); + protectObjName, disposeObject, err); return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null); } @@ -970,7 +953,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (err != ErrorCode.ERR_OK) { log.error("----Error DPTech Stop Cleanup Task, Stop Traction Strategy Error: {}, {}", disposeObject, - err); + err); return new MulReturnType<>(err, null); } @@ -980,7 +963,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (err != ErrorCode.ERR_OK) { log.error("----Error DPTech Stop Cleanup Task, Clean Traction Strategy Error: {}, {}", - disposeObject, err); + disposeObject, err); } } @@ -1026,9 +1009,20 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { disposeServiceGroup.put(v.getServiceId(), v); } } else { + //缓存和数据库中都不存在,则添加进缓存 disposeServiceGroup.put(v.getServiceId(), v); } } + + List expireKey = new ArrayList<>(); + + for (String v : disposeServiceGroup.keySet()) { + if (svrList.stream().noneMatch(k -> k.getServiceId().equals(v))) { + expireKey.add(v); + } + } + + expireKey.forEach(disposeServiceGroup::remove); } /**