summaryrefslogtreecommitdiffstats
path: root/controlloop/common/guard/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-07-11 09:07:23 -0400
committerJim Hahn <jrh3@att.com>2018-07-11 09:07:23 -0400
commit0b01c65ad0f11d48020097edf3583a917adda4bf (patch)
treeb661e1c833f00a515f5e14e859eca55038861298 /controlloop/common/guard/src/main/java
parent865dd094c03a145dc0588534263d1a62fef809eb (diff)
Include hostname as part of lock owner
Because the lock owner string is constructed, using just the target type and request ID, lock requests made by different ONSETs running on different PDP-Ds may both succeed. Added the hostname to the owner string so that locks for ONSETs for the same request ID will be rejected if the request is made on different PDP-Ds. Change-Id: I1d45194cbb1c5b1a1f6000477fe51879a2fecc19 Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/guard/src/main/java')
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
index 64d8a2f74..73baf205d 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
@@ -23,6 +23,7 @@ package org.onap.policy.guard;
import java.util.UUID;
import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.drools.core.lock.PolicyResourceLockManager;
+import org.onap.policy.drools.utils.NetworkUtil;
import org.onap.policy.guard.impl.PNFTargetLock;
import org.onap.policy.guard.impl.VMTargetLock;
import org.onap.policy.guard.impl.VNFTargetLock;
@@ -209,7 +210,7 @@ public class PolicyGuard {
throw new IllegalArgumentException("null requestID for lock type " + targetType);
}
- return targetType.toString() + ":" + requestID.toString();
+ return factory.getHostname() + ":" + targetType + ":" + requestID;
}
/**
@@ -223,5 +224,12 @@ public class PolicyGuard {
public PolicyResourceLockManager getManager() {
return PolicyResourceLockManager.getInstance();
}
+
+ /**
+ * @return the current host name
+ */
+ public String getHostname() {
+ return NetworkUtil.getHostname();
+ }
}
}