Merge remote-tracking branch 'origin/v2.0.5_dev' into v2.0.5_dev

This commit is contained in:
HuangXin 2021-01-25 10:51:08 +08:00
commit d64b4ad013
4 changed files with 22 additions and 13 deletions

View File

@ -577,7 +577,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
// UMC上面存在对象已经失效
if (disposeServiceGroup.values().stream().noneMatch(k -> serviceId.equals(k.getServiceId()))) {
log.info("++++Remove UMC Unused Protect Object: {}", protectName);
log.debug("Remove UMC Unused Protect Object: {}", protectName);
ErrorCode err = removeProtectObject(protectName);
if (err != ErrorCode.ERR_OK) {

View File

@ -18,9 +18,10 @@ public interface DisposeAbilityRouterService {
*
* @param ipAddr the ip addr
* @param ipPort the ip port
* @param deviceType the device type
* @return the ability device
*/
AbilityInfo getAbilityDevice(String ipAddr, String ipPort);
AbilityInfo getAbilityDevice(String ipAddr, String ipPort, String deviceType);
/**
* Gets ability device.

View File

@ -63,13 +63,14 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
/**
* Gets ability device.
*
* @param ipAddr the ip addr
* @param ipPort the ip port
* @param ipAddr the ip addr
* @param ipPort the ip port
* @param deviceType the device type
* @return the ability device
*/
@Override
public AbilityInfo getAbilityDevice(String ipAddr, String ipPort) {
return disposeAbilityMap.get(getAbilityDeviceHashKey(ipAddr, ipPort));
public AbilityInfo getAbilityDevice(String ipAddr, String ipPort, String deviceType) {
return disposeAbilityMap.get(getAbilityDeviceHashKey(ipAddr, ipPort, deviceType));
}
/**
@ -86,7 +87,8 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
.orElse(null);
if (dev != null) {
return disposeAbilityMap.get(getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort()));
return disposeAbilityMap.get(getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(),
String.valueOf(dev.getDeviceType())));
}
return null;
@ -113,7 +115,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
DisposeAbility db;
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
String addr = getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort());
String addr = (dev.getIpPort() == null || dev.getIpPort().length() == 0) ? dev.getIpAddr() : (dev.getIpAddr() + ":" + dev.getIpPort());
String url = httpType + addr + "/" + dev.getUrlPath();
switch (dev.getDeviceType()) {
@ -145,8 +147,11 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
db.getDisposeDeviceProtectObject();
String hashKey = getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(),
String.valueOf(dev.getDeviceType()));
// 缓存处置设备到Hash表中
disposeAbilityMap.put(addr, AbilityInfo.builder()
disposeAbilityMap.put(hashKey, AbilityInfo.builder()
.db(db)
.dev(dev)
.linkStatus(false)
@ -206,7 +211,8 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
* @param ipPort the ip port
* @return the ability device hash key
*/
private String getAbilityDeviceHashKey(String ipAddr, String ipPort) {
return (ipPort == null || ipPort.length() == 0) ? ipAddr : (ipAddr + ":" + ipPort);
private String getAbilityDeviceHashKey(String ipAddr, String ipPort, String deviceType) {
String addrPort = ipPort == null || ipPort.length() == 0 ? ipAddr : (ipAddr + ":" + ipPort);
return addrPort + "-" + deviceType;
}
}

View File

@ -149,7 +149,8 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
e.printStackTrace();
}
AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort());
AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort(),
String.valueOf(v.getDeviceType()));
Assert.assertNotNull(abilityInfo);
@ -251,7 +252,8 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(deviceList));
deviceList.forEach(v -> {
AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort());
AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort(),
String.valueOf(v.getDeviceType()));
Assert.assertNotNull(abilityInfo);
Assert.assertNotNull(abilityInfo.getDev());