summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-locking
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-13 15:25:32 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-13 15:26:47 +0100
commit4cfa2e2d98f6877d54da304ef17f096284430908 (patch)
treec9452d2bf6bb96fae9c1e8e2d8ce8f8d01e69d22 /plugins/plugins-context/plugins-context-locking
parent0e23f7634e1e1fb31454c516974613335fcea1a4 (diff)
Sonar/Checkstyle in service/plugins
Sonar and Checkstyle changes in plugins and services, and knock on changes Issue-ID: POLICY-1034 Change-Id: Iff7df74e54fce2c661dcc2fae75ae93d4cacfe5b Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-context/plugins-context-locking')
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java9
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java7
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java8
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java14
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java6
5 files changed, 24 insertions, 20 deletions
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java
index 928255031..4e6ab71a4 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java
@@ -37,6 +37,9 @@ public class CuratorLockFacade implements Lock {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(CuratorLockFacade.class);
+ // Recurring string constants
+ private static final String FAILED_TO_ACQUIRE_LOCK_TAG = "failed to acquire lock for \"{}\"";
+
// The Lock ID
private final String lockId;
@@ -64,7 +67,7 @@ public class CuratorLockFacade implements Lock {
try {
lockMutex.acquire();
} catch (final Exception e) {
- LOGGER.warn("failed to acquire lock for \"" + lockId, e);
+ LOGGER.warn(FAILED_TO_ACQUIRE_LOCK_TAG, lockId, e);
}
}
@@ -75,7 +78,7 @@ public class CuratorLockFacade implements Lock {
*/
@Override
public void lockInterruptibly() throws InterruptedException {
- LOGGER.warn("lockInterruptibly() not supported for \"" + lockId);
+ LOGGER.warn("lockInterruptibly() not supported for \"{}\"", lockId);
}
/*
@@ -131,7 +134,7 @@ public class CuratorLockFacade implements Lock {
*/
@Override
public Condition newCondition() {
- LOGGER.warn("newCondition() not supported for \"" + lockId);
+ LOGGER.warn("newCondition() not supported for \"{} \"", lockId);
return null;
}
}
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
index d2976d799..bc8ce9055 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
@@ -81,9 +81,10 @@ public class CuratorLockManager extends AbstractLockManager {
// Check if the curator address has been set
curatorZookeeperAddress = lockParameters.getZookeeperAddress();
if (curatorZookeeperAddress == null || curatorZookeeperAddress.trim().length() == 0) {
- LOGGER.warn("could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
- throw new ContextException(
- "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
+ String message = "could not set up Curator locking, "
+ + "check if the curator Zookeeper address parameter is set correctly";
+ LOGGER.warn(message);
+ throw new ContextException(message);
}
// Set up the curator framework we'll use
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java
index 22bf5e596..5a24fb701 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java
@@ -33,7 +33,7 @@ import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock;
*/
public class CuratorReentrantReadWriteLock implements ReadWriteLock {
// The Lock ID
- private final String lockID;
+ private final String lockId;
// The Curator lock
private final InterProcessReadWriteLock curatorReadWriteLock;
@@ -49,7 +49,7 @@ public class CuratorReentrantReadWriteLock implements ReadWriteLock {
* @param lockId The unique ID of the lock.
*/
public CuratorReentrantReadWriteLock(final CuratorFramework curatorFramework, final String lockId) {
- lockID = lockId;
+ this.lockId = lockId;
// Create the Curator lock
curatorReadWriteLock = new InterProcessReadWriteLock(curatorFramework, lockId);
@@ -64,8 +64,8 @@ public class CuratorReentrantReadWriteLock implements ReadWriteLock {
*
* @return the lock ID
*/
- public String getLockID() {
- return lockID;
+ public String getLockId() {
+ return lockId;
}
/*
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java
index 73678ad2a..9d4a5ca8f 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java
@@ -20,12 +20,12 @@
package org.onap.policy.apex.plugins.context.locking.hazelcast;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ILock;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+
/**
* This class maps a Hazelcast {@link ILock} to a Java {@link ReadWriteLock}.
*
@@ -33,7 +33,7 @@ import com.hazelcast.core.ILock;
*/
public class HazelcastLock implements ReadWriteLock {
// The Lock ID
- private final String lockID;
+ private final String lockId;
// The hazelcast lock
private final ILock readLock;
@@ -46,7 +46,7 @@ public class HazelcastLock implements ReadWriteLock {
* @param lockId The unique ID of the lock.
*/
public HazelcastLock(final HazelcastInstance hazelcastInstance, final String lockId) {
- lockID = lockId;
+ this.lockId = lockId;
// Create the Hazelcast read and write locks
readLock = hazelcastInstance.getLock(lockId + "_READ");
@@ -58,8 +58,8 @@ public class HazelcastLock implements ReadWriteLock {
*
* @return the lock ID
*/
- public String getLockID() {
- return lockID;
+ public String getLockId() {
+ return lockId;
}
/*
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java
index 34258bf24..4994cf7f5 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java
@@ -20,6 +20,9 @@
package org.onap.policy.apex.plugins.context.locking.hazelcast;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+
import java.util.concurrent.locks.ReadWriteLock;
import org.onap.policy.apex.context.ContextException;
@@ -28,9 +31,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-
/**
* The Class HazelcastLockManager manages Hazelcast locks for locks on items in Apex context albums.
*