diff options
author | Jim Hahn <jrh3@att.com> | 2021-06-28 15:04:36 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-06-29 10:21:49 -0400 |
commit | 4d4547ee4b3a6be75cf2c01f3065b129fddcfd3b (patch) | |
tree | c98e2237ab5565ba4af267814fb484fbae14dd64 /feature-distributed-locking/src/main/java | |
parent | d2b5424c17ef26d5e71b3014234cfd02f7854eca (diff) |
Use unique name in drools PdpMessages
Also modified distributed locking to use the unique name, in case the DB
is shared.
Issue-ID: POLICY-3410
Change-Id: I046a9ffdcb62f3d84d7d388a1e64bcf025fbbf75
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-distributed-locking/src/main/java')
-rw-r--r-- | feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockManager.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockManager.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockManager.java index c114d26a..93a63754 100644 --- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockManager.java +++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockManager.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,6 @@ import lombok.Getter; import lombok.Setter; import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSourceFactory; -import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.drools.core.lock.LockCallback; import org.onap.policy.drools.core.lock.LockState; import org.onap.policy.drools.core.lock.PolicyResourceLockManager; @@ -94,7 +93,7 @@ public class DistributedLockManager extends LockManager<DistributedLockManager.D * Name of the host on which this JVM is running. */ @Getter - private final String hostName; + private final String pdpName; /** * UUID of this object. @@ -135,7 +134,7 @@ public class DistributedLockManager extends LockManager<DistributedLockManager.D * Constructs the object. */ public DistributedLockManager() { - this.hostName = NetworkUtil.getHostname(); + this.pdpName = PolicyEngineConstants.PDP_NAME; this.resource2lock = getResource2lock(); } @@ -305,7 +304,7 @@ public class DistributedLockManager extends LockManager<DistributedLockManager.D "SELECT resourceId FROM pooling.locks WHERE host=? AND owner=? AND expirationTime > now()")) { // @formatter:on - stmt.setString(1, hostName); + stmt.setString(1, pdpName); stmt.setString(2, uuidString); try (ResultSet resultSet = stmt.executeQuery()) { @@ -415,7 +414,7 @@ public class DistributedLockManager extends LockManager<DistributedLockManager.D super(state, resourceId, ownerKey, holdSec, callback); this.feature = feature; - this.hostName = feature.hostName; + this.hostName = feature.pdpName; this.uuidString = feature.uuidString; } @@ -713,13 +712,13 @@ public class DistributedLockManager extends LockManager<DistributedLockManager.D + "values (?, ?, ?, timestampadd(second, ?, now()))")) { stmt.setString(1, getResourceId()); - stmt.setString(2, feature.hostName); + stmt.setString(2, feature.pdpName); stmt.setString(3, feature.uuidString); stmt.setInt(4, getHoldSec()); stmt.executeUpdate(); - this.hostName = feature.hostName; + this.hostName = feature.pdpName; this.uuidString = feature.uuidString; return true; @@ -742,7 +741,7 @@ public class DistributedLockManager extends LockManager<DistributedLockManager.D + " AND ((host=? AND owner=?) OR expirationTime < now())")) { stmt.setString(1, getResourceId()); - stmt.setString(2, feature.hostName); + stmt.setString(2, feature.pdpName); stmt.setString(3, feature.uuidString); stmt.setInt(4, getHoldSec()); @@ -754,7 +753,7 @@ public class DistributedLockManager extends LockManager<DistributedLockManager.D return false; } - this.hostName = feature.hostName; + this.hostName = feature.pdpName; this.uuidString = feature.uuidString; return true; |