Merge remote-tracking branch 'origin/v2.0.5_dev' into v2.0.5_dev
This commit is contained in:
commit
d64b4ad013
|
@ -577,7 +577,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
||||||
|
|
||||||
// UMC上面存在对象已经失效
|
// UMC上面存在对象已经失效
|
||||||
if (disposeServiceGroup.values().stream().noneMatch(k -> serviceId.equals(k.getServiceId()))) {
|
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);
|
ErrorCode err = removeProtectObject(protectName);
|
||||||
|
|
||||||
if (err != ErrorCode.ERR_OK) {
|
if (err != ErrorCode.ERR_OK) {
|
||||||
|
|
|
@ -18,9 +18,10 @@ public interface DisposeAbilityRouterService {
|
||||||
*
|
*
|
||||||
* @param ipAddr the ip addr
|
* @param ipAddr the ip addr
|
||||||
* @param ipPort the ip port
|
* @param ipPort the ip port
|
||||||
|
* @param deviceType the device type
|
||||||
* @return the ability device
|
* @return the ability device
|
||||||
*/
|
*/
|
||||||
AbilityInfo getAbilityDevice(String ipAddr, String ipPort);
|
AbilityInfo getAbilityDevice(String ipAddr, String ipPort, String deviceType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets ability device.
|
* Gets ability device.
|
||||||
|
|
|
@ -65,11 +65,12 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
*
|
*
|
||||||
* @param ipAddr the ip addr
|
* @param ipAddr the ip addr
|
||||||
* @param ipPort the ip port
|
* @param ipPort the ip port
|
||||||
|
* @param deviceType the device type
|
||||||
* @return the ability device
|
* @return the ability device
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AbilityInfo getAbilityDevice(String ipAddr, String ipPort) {
|
public AbilityInfo getAbilityDevice(String ipAddr, String ipPort, String deviceType) {
|
||||||
return disposeAbilityMap.get(getAbilityDeviceHashKey(ipAddr, ipPort));
|
return disposeAbilityMap.get(getAbilityDeviceHashKey(ipAddr, ipPort, deviceType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +87,8 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
if (dev != 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;
|
return null;
|
||||||
|
@ -113,7 +115,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
DisposeAbility db;
|
DisposeAbility db;
|
||||||
|
|
||||||
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
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();
|
String url = httpType + addr + "/" + dev.getUrlPath();
|
||||||
|
|
||||||
switch (dev.getDeviceType()) {
|
switch (dev.getDeviceType()) {
|
||||||
|
@ -145,8 +147,11 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||||
db.getDisposeDeviceProtectObject();
|
db.getDisposeDeviceProtectObject();
|
||||||
|
|
||||||
|
String hashKey = getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(),
|
||||||
|
String.valueOf(dev.getDeviceType()));
|
||||||
|
|
||||||
// 缓存处置设备到Hash表中
|
// 缓存处置设备到Hash表中
|
||||||
disposeAbilityMap.put(addr, AbilityInfo.builder()
|
disposeAbilityMap.put(hashKey, AbilityInfo.builder()
|
||||||
.db(db)
|
.db(db)
|
||||||
.dev(dev)
|
.dev(dev)
|
||||||
.linkStatus(false)
|
.linkStatus(false)
|
||||||
|
@ -206,7 +211,8 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
* @param ipPort the ip port
|
* @param ipPort the ip port
|
||||||
* @return the ability device hash key
|
* @return the ability device hash key
|
||||||
*/
|
*/
|
||||||
private String getAbilityDeviceHashKey(String ipAddr, String ipPort) {
|
private String getAbilityDeviceHashKey(String ipAddr, String ipPort, String deviceType) {
|
||||||
return (ipPort == null || ipPort.length() == 0) ? ipAddr : (ipAddr + ":" + ipPort);
|
String addrPort = ipPort == null || ipPort.length() == 0 ? ipAddr : (ipAddr + ":" + ipPort);
|
||||||
|
return addrPort + "-" + deviceType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,8 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
|
||||||
e.printStackTrace();
|
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);
|
Assert.assertNotNull(abilityInfo);
|
||||||
|
|
||||||
|
@ -251,7 +252,8 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
|
||||||
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(deviceList));
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(deviceList));
|
||||||
|
|
||||||
deviceList.forEach(v -> {
|
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);
|
||||||
Assert.assertNotNull(abilityInfo.getDev());
|
Assert.assertNotNull(abilityInfo.getDev());
|
||||||
|
|
Loading…
Reference in New Issue