REM:
1.删除多余代码
2.同步缓存和数据库信息
This commit is contained in:
chenlinghy 2021-01-21 18:47:58 +08:00
parent e782872b5b
commit db5f8d36e2
1 changed files with 43 additions and 49 deletions

View File

@ -137,7 +137,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
dpBypassManager.getTractionStrategyName().remove(v.getPolicyName()); dpBypassManager.getTractionStrategyName().remove(v.getPolicyName());
} else { } else {
log.info("!!!!Remove Traction Strategy {} Error: {}", v.getPolicyName(), log.info("!!!!Remove Traction Strategy {} Error: {}", v.getPolicyName(),
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
} }
@ -161,7 +161,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
dpBypassManager.getProtectStrategy().remove(objName); dpBypassManager.getProtectStrategy().remove(objName);
} else { } else {
log.error("!!!!Disable Protection Strategy Template {} Error: {}", objName, log.error("!!!!Disable Protection Strategy Template {} Error: {}", objName,
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
break; break;
@ -177,7 +177,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
dpBypassManager.getProtectObject().remove(objName); dpBypassManager.getProtectObject().remove(objName);
} else { } else {
log.error("!!!!Delete Protection Object {} Error: {}", objName, log.error("!!!!Delete Protection Object {} Error: {}", objName,
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
@ -209,18 +209,18 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
// 创建对象 // 创建对象
NtcRequestResultInfo ret = getCleanTypePort() NtcRequestResultInfo ret = getCleanTypePort()
.addProtectionObjectForUMC("", .addProtectionObjectForUMC("",
allCleanupDevices, allCleanupDevices,
objName, objName,
ipSegment, ipSegment,
ipType, ipType,
0); 0);
if (ret.getResultRetVal() == 0) { if (ret.getResultRetVal() == 0) {
log.debug("Add Protection Object {} Succeed", objName); log.debug("Add Protection Object {} Succeed", objName);
} else { } else {
log.error("!!!!Add Protection Object {}, {}, {} Error: {}", objName, ipSegment, ipType, log.error("!!!!Add Protection Object {}, {}, {} Error: {}", objName, ipSegment, ipType,
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
@ -231,7 +231,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
log.debug("{} Link Protection Strategy Template {} Succeed", objName, template); log.debug("{} Link Protection Strategy Template {} Succeed", objName, template);
} else { } else {
log.error("!!!!{} Link Protection Strategy Template {} Error: {}", objName, template, log.error("!!!!{} Link Protection Strategy Template {} Error: {}", objName, template,
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
@ -280,14 +280,14 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
// 创建旁路手动牵引策略 // 创建旁路手动牵引策略
ret = getCleanTypePort().addBypassManualTractionStrategyForUMC(tractionName, ret = getCleanTypePort().addBypassManualTractionStrategyForUMC(tractionName,
objName, objName,
getIpSegmentFormat(disposeObject)); getIpSegmentFormat(disposeObject));
if (ret.getResultRetVal() == 0) { if (ret.getResultRetVal() == 0) {
log.debug("----Finish Create Traction Strategy {} Succeed", tractionName); log.debug("----Finish Create Traction Strategy {} Succeed", tractionName);
return ErrorCode.ERR_OK; return ErrorCode.ERR_OK;
} else { } else {
log.error("----Create Traction Strategy Error: {}, {}, {}, {}", tractionName, log.error("----Create Traction Strategy Error: {}, {}, {}, {}", tractionName,
objName, disposeObject, ret.getResultInfo().getValue()); objName, disposeObject, ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
} }
@ -316,7 +316,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
if (ret.getResultRetVal() != 0) { if (ret.getResultRetVal() != 0) {
err = ErrorCode.ERR_CALLDEVICE; err = ErrorCode.ERR_CALLDEVICE;
log.error("----Error Start Traction Strategy: {}, {}, {}", objName, disposeObject, log.error("----Error Start Traction Strategy: {}, {}, {}", objName, disposeObject,
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
} else { } else {
log.debug("----Finish Start Traction Strategy: {}, {}", objName, disposeObject); log.debug("----Finish Start Traction Strategy: {}, {}", objName, disposeObject);
} }
@ -392,7 +392,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
return ErrorCode.ERR_OK; return ErrorCode.ERR_OK;
} else { } else {
log.error("!!!!Remove Traction Strategy {} Error: {}", tractionName, log.error("!!!!Remove Traction Strategy {} Error: {}", tractionName,
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
} }
@ -421,7 +421,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
log.debug("Disable Protection Strategy Template {} Succeed", objName); log.debug("Disable Protection Strategy Template {} Succeed", objName);
} else { } else {
log.error("!!!!Disable Protection Strategy Template {} Error: {}", objName, log.error("!!!!Disable Protection Strategy Template {} Error: {}", objName,
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
@ -437,7 +437,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
log.debug("{} Link Protection Strategy Template {} Succeed", objName, newTemplate); log.debug("{} Link Protection Strategy Template {} Succeed", objName, newTemplate);
} else { } else {
log.error("!!!!{} Link Protection Strategy Template {} Error: {}", objName, newTemplate, log.error("!!!!{} Link Protection Strategy Template {} Error: {}", objName, newTemplate,
ret.getResultInfo().getValue()); ret.getResultInfo().getValue());
return ErrorCode.ERR_CALLDEVICE; return ErrorCode.ERR_CALLDEVICE;
} }
@ -461,7 +461,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
// 未找到合适的模板 // 未找到合适的模板
if (TemplateConfigure.UMC_TEMPLATE.stream().noneMatch(m -> m.getName().equals(template))) { if (TemplateConfigure.UMC_TEMPLATE.stream().noneMatch(m -> m.getName().equals(template))) {
log.error("!!!!{} Can't Math Template: {}, {} From {}", v.getServiceId(), v.getServiceType(), log.error("!!!!{} Can't Math Template: {}, {} From {}", v.getServiceId(), v.getServiceType(),
v.getServiceBandwidth(), TemplateConfigure.UMC_TEMPLATE); v.getServiceBandwidth(), TemplateConfigure.UMC_TEMPLATE);
return; return;
} }
@ -538,9 +538,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
// 更新防护对象 // 更新防护对象
if (upgradeIpSegment) { if (upgradeIpSegment) {
err = upgradeProtectObject(protectName, err = upgradeProtectObject(protectName,
ipSegment.get(t), ipSegment.get(t),
IpAddrType.IPV4.equals(t) ? 0 : 1, IpAddrType.IPV4.equals(t) ? 0 : 1,
template); template);
if (err == ErrorCode.ERR_OK) { if (err == ErrorCode.ERR_OK) {
log.debug("Add Protection Object {} Succeed", protectName); log.debug("Add Protection Object {} Succeed", protectName);
} else { } else {
@ -549,9 +549,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
} }
} else { } else {
err = createProtectObject(protectName, err = createProtectObject(protectName,
ipSegment.get(t), ipSegment.get(t),
IpAddrType.IPV4.equals(t) ? 0 : 1, IpAddrType.IPV4.equals(t) ? 0 : 1,
template); template);
if (err == ErrorCode.ERR_OK) { if (err == ErrorCode.ERR_OK) {
log.debug("Add Protection Object {} Succeed", protectName); log.debug("Add Protection Object {} Succeed", protectName);
} else { } 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"); log.debug("----Finish DPTech Get All Protection Strategy Association Relation");
} catch (Exception ex) { } catch (Exception ex) {
log.error("----Exception DPTech Get All Protection Strategy Association Relation: {}", 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)) { if (!objName.startsWith(objectPrefix)) {
log.error("!!!!Found Unexpect Protection Object [{}, {}], Deleted it.", log.error("!!!!Found Unexpect Protection Object [{}, {}], Deleted it.",
objName, objName,
k.getIpSegment().getValue()); k.getIpSegment().getValue());
NtcRequestResultInfo rsp = getCleanTypePort().deleteProtectionObjectForUMC(objName); NtcRequestResultInfo rsp = getCleanTypePort().deleteProtectionObjectForUMC(objName);
@ -837,7 +820,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
log.warn("!!!!Remove Exception Protection IpSegment {}, {} Succeed", objName, v); log.warn("!!!!Remove Exception Protection IpSegment {}, {} Succeed", objName, v);
} else { } else {
log.warn("!!!!Remove Exception Protection IpSegment {}, {} Error: {}", objName, v, 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) { if (err != ErrorCode.ERR_OK) {
log.error("----Error DPTech Start Cleanup Task, Create Traction Strategy Error: {}, {}, {}", log.error("----Error DPTech Start Cleanup Task, Create Traction Strategy Error: {}, {}, {}",
protectObjName, disposeObject, err); protectObjName, disposeObject, err);
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null); return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null);
} }
@ -921,7 +904,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
log.error("----Error DPTech Start Cleanup Task, Start Traction Strategy Error: {}, {}, {}", log.error("----Error DPTech Start Cleanup Task, Start Traction Strategy Error: {}, {}, {}",
protectObjName, disposeObject, err); protectObjName, disposeObject, err);
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null); return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null);
} }
@ -970,7 +953,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
log.error("----Error DPTech Stop Cleanup Task, Stop Traction Strategy Error: {}, {}", disposeObject, log.error("----Error DPTech Stop Cleanup Task, Stop Traction Strategy Error: {}, {}", disposeObject,
err); err);
return new MulReturnType<>(err, null); return new MulReturnType<>(err, null);
} }
@ -980,7 +963,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
log.error("----Error DPTech Stop Cleanup Task, Clean Traction Strategy Error: {}, {}", 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); disposeServiceGroup.put(v.getServiceId(), v);
} }
} else { } else {
//缓存和数据库中都不存在则添加进缓存
disposeServiceGroup.put(v.getServiceId(), v); disposeServiceGroup.put(v.getServiceId(), v);
} }
} }
List<String> expireKey = new ArrayList<>();
for (String v : disposeServiceGroup.keySet()) {
if (svrList.stream().noneMatch(k -> k.getServiceId().equals(v))) {
expireKey.add(v);
}
}
expireKey.forEach(disposeServiceGroup::remove);
} }
/** /**