summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator')
-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.java54
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java4
2 files changed, 27 insertions, 31 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/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 477a010fa..d2976d799 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
@@ -33,13 +33,13 @@ import org.apache.zookeeper.CreateMode;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.impl.locking.AbstractLockManager;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class CuratorLockManager manages the Curator interface towards Zookeeper for administering
- * the Apex Context Album instance locks..
+ * The Class CuratorLockManager manages the Curator interface towards Zookeeper for administering the Apex Context Album
+ * instance locks..
*/
public class CuratorLockManager extends AbstractLockManager {
// Logger for this class
@@ -65,8 +65,8 @@ public class CuratorLockManager extends AbstractLockManager {
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.context.impl.locking.AbstractLockManager#init(org.onap.policy.apex.
- * model. basicmodel.concepts.AxArtifactKey)
+ * @see org.onap.policy.apex.context.impl.locking.AbstractLockManager#init(org.onap.policy.apex. model.
+ * basicmodel.concepts.AxArtifactKey)
*/
@Override
public void init(final AxArtifactKey key) throws ContextException {
@@ -75,23 +75,22 @@ public class CuratorLockManager extends AbstractLockManager {
super.init(key);
// Get the lock manager parameters
- final CuratorLockManagerParameters lockParameters =
- ParameterService.getParameters(CuratorLockManagerParameters.class);
+ final CuratorLockManagerParameters lockParameters = ParameterService
+ .get(CuratorLockManagerParameters.class.getSimpleName());
// 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");
+ 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");
+ "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
}
// Set up the curator framework we'll use
curatorFramework = CuratorFrameworkFactory.builder().connectString(curatorZookeeperAddress)
- .retryPolicy(new ExponentialBackoffRetry(lockParameters.getZookeeperConnectSleepTime(),
- lockParameters.getZookeeperContextRetries()))
- .build();
+ .retryPolicy(new ExponentialBackoffRetry(lockParameters.getZookeeperConnectSleepTime(),
+ lockParameters.getZookeeperContextRetries()))
+ .build();
// Listen for changes on the Curator connection
curatorFramework.getConnectionStateListenable().addListener(new CuratorManagerConnectionStateListener());
@@ -102,22 +101,22 @@ public class CuratorLockManager extends AbstractLockManager {
// Wait for the connection to be made
try {
curatorFramework.blockUntilConnected(
- lockParameters.getZookeeperConnectSleepTime() * lockParameters.getZookeeperContextRetries(),
- TimeUnit.MILLISECONDS);
+ lockParameters.getZookeeperConnectSleepTime() * lockParameters.getZookeeperContextRetries(),
+ TimeUnit.MILLISECONDS);
} catch (final InterruptedException e) {
// restore the interrupt status
Thread.currentThread().interrupt();
- LOGGER.warn("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", wait for connection timed out");
- throw new ContextException("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", wait for connection timed out");
+ String message = "error connecting to Zookeeper server at \"" + curatorZookeeperAddress
+ + "\", wait for connection timed out";
+ LOGGER.warn(message);
+ throw new ContextException(message);
}
if (!curatorFramework.getZookeeperClient().isConnected()) {
- LOGGER.warn("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", see error log for details");
- throw new ContextException("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", see error log for details");
+ String message = "could not connect to Zookeeper server at \"" + curatorZookeeperAddress
+ + "\", see error log for details";
+ LOGGER.warn(message);
+ throw new ContextException(message);
}
// We'll use Ephemeral nodes for locks on the Zookeeper server
@@ -129,8 +128,7 @@ public class CuratorLockManager extends AbstractLockManager {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.core.context.impl.locking.AbstractLockManager#getReentrantReadWriteLock(
+ * @see org.onap.policy.apex.core.context.impl.locking.AbstractLockManager#getReentrantReadWriteLock(
* java.lang.String)
*/
@Override
@@ -140,7 +138,7 @@ public class CuratorLockManager extends AbstractLockManager {
return new CuratorReentrantReadWriteLock(curatorFramework, "/" + lockId);
} else {
throw new ContextException("creation of lock using Zookeeper server at \"" + curatorZookeeperAddress
- + "\", failed, see error log for details");
+ + "\", failed, see error log for details");
}
}
@@ -176,8 +174,8 @@ public class CuratorLockManager extends AbstractLockManager {
return;
}
- LOGGER.info("curator state of client \"" + curatorFramework + "\" connected to \"" + curatorZookeeperAddress
- + "\" changed to " + newState);
+ LOGGER.info("curator state of client \"{}\" connected to \"{}\" changed to {}", curatorFramework,
+ curatorZookeeperAddress, newState);
if (newState != ConnectionState.CONNECTED) {
shutdown();
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
index 9e8d5d2af..ac936d436 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
@@ -21,7 +21,6 @@
package org.onap.policy.apex.plugins.context.locking.curator;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
* Bean class for Curator locking parameters.
@@ -49,8 +48,7 @@ public class CuratorLockManagerParameters extends LockManagerParameters {
* The Constructor.
*/
public CuratorLockManagerParameters() {
- super(CuratorLockManagerParameters.class.getCanonicalName());
- ParameterService.registerParameters(CuratorLockManagerParameters.class, this);
+ super();
}
/**