aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan')
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java31
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java12
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java8
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java38
4 files changed, 65 insertions, 24 deletions
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
index c8b1cedce..e11f3da8b 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
@@ -22,7 +22,6 @@ package org.onap.policy.apex.plugins.context.distribution.infinispan;
import java.util.Map;
-import org.infinispan.Cache;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.impl.distribution.AbstractDistributor;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -32,8 +31,8 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * This context distributor distributes context across threads in multiple JVMs on multiple hosts.
- * It uses Infinispan to distribute maps.
+ * This context distributor distributes context across threads in multiple JVMs on multiple hosts. It uses Infinispan to
+ * distribute maps.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -58,8 +57,7 @@ public class InfinispanContextDistributor extends AbstractDistributor {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.context.impl.distribution.AbstractContextDistributor#init(org.onap.policy.apex
+ * @see org.onap.policy.apex.context.impl.distribution.AbstractContextDistributor#init(org.onap.policy.apex
* .model.basicmodel.concepts.AxArtifactKey)
*/
@Override
@@ -71,18 +69,26 @@ public class InfinispanContextDistributor extends AbstractDistributor {
// Create the infinispan manager if it does not already exist
if (infinispanManager == null) {
// Get the parameters from the parameter service
- final InfinispanDistributorParameters parameters =
- ParameterService.get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ final InfinispanDistributorParameters parameters = ParameterService
+ .get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- LOGGER.debug("initiating Infinispan with the parameters: " + parameters);
+ LOGGER.debug("initiating Infinispan with the parameters: {}", parameters);
// Create the manager
- infinispanManager = new InfinispanManager(parameters);
+ setInfinispanManager(new InfinispanManager(parameters));
}
LOGGER.exit("init(" + key + ")");
}
+ /**
+ * Set the infinispan manager statically.
+ * @param newInfinispanManager the new infinspan manager instance
+ */
+ private static void setInfinispanManager(InfinispanManager newInfinispanManager) {
+ infinispanManager = newInfinispanManager;
+ }
+
/*
* (non-Javadoc)
*
@@ -94,10 +100,7 @@ public class InfinispanContextDistributor extends AbstractDistributor {
LOGGER.info("InfinispanContextDistributor: create album: " + contextAlbumKey.getId());
// Get the Cache from Infinispan
- final Cache<String, Object> infinispanCache =
- infinispanManager.getCacheManager().getCache(contextAlbumKey.getId().replace(':', '_'));
-
- return infinispanCache;
+ return infinispanManager.getCacheManager().getCache(contextAlbumKey.getId().replace(':', '_'));
}
/*
@@ -111,6 +114,6 @@ public class InfinispanContextDistributor extends AbstractDistributor {
if (infinispanManager != null) {
infinispanManager.shutdown();
}
- infinispanManager = null;
+ setInfinispanManager(null);
}
}
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
index 16fdd85ac..1993d21de 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
@@ -46,7 +46,7 @@ public class InfinispanDistributorParameters extends DistributorParameters {
private String configFile = DEFAULT_INFINISPAN_DISTRIBUTION_CONFIG_FILE;
private String jgroupsFile = DEFAULT_INFINISPAN_DISTRIBUTION_JGROUPS_FILE;
private boolean preferIPv4Stack = DEFAULT_INFINISPAN_JAVA_NET_PREFER_IPV4_STACK;
- private String jGroupsBindAddress = DEFAULT_INFINSPAN_JGROUPS_BIND_ADDRESS;
+ private String jgroupsBindAddress = DEFAULT_INFINSPAN_JGROUPS_BIND_ADDRESS;
// @formatter:on
/**
@@ -116,16 +116,16 @@ public class InfinispanDistributorParameters extends DistributorParameters {
* @return the j groups bind address
*/
public String getjGroupsBindAddress() {
- return jGroupsBindAddress;
+ return jgroupsBindAddress;
}
/**
* Setj groups bind address.
*
- * @param jGroupsBindAddress the j groups bind address
+ * @param jgroupsBindAddress the j groups bind address
*/
- public void setjGroupsBindAddress(final String jGroupsBindAddress) {
- this.jGroupsBindAddress = jGroupsBindAddress;
+ public void setjGroupsBindAddress(final String jgroupsBindAddress) {
+ this.jgroupsBindAddress = jgroupsBindAddress;
}
/*
@@ -136,6 +136,6 @@ public class InfinispanDistributorParameters extends DistributorParameters {
@Override
public String toString() {
return "InfinispanDistributorParameters [configFile=" + configFile + ", jgroupsFile=" + jgroupsFile
- + ", preferIPv4Stack=" + preferIPv4Stack + ", jGroupsBindAddress=" + jGroupsBindAddress + "]";
+ + ", preferIPv4Stack=" + preferIPv4Stack + ", jGroupsBindAddress=" + jgroupsBindAddress + "]";
}
}
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java
index 1a2076f10..843a6b971 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java
@@ -45,7 +45,7 @@ public class InfinispanManager {
* @throws ContextException On errors connecting to Infinispan
*/
public InfinispanManager(final InfinispanDistributorParameters infinispanDistributorParameters)
- throws ContextException {
+ throws ContextException {
LOGGER.entry("Creating Infinispan Manager: " + infinispanDistributorParameters);
setSystemProperties(infinispanDistributorParameters);
@@ -55,8 +55,8 @@ public class InfinispanManager {
cacheManager = new DefaultCacheManager(infinispanDistributorParameters.getConfigFile());
LOGGER.debug("started infinispan cache manager using specified configuration");
} catch (final IOException ioException) {
- final String errorMessage =
- "failed to start infinispan cache manager, no infinispan configuration found on local file system or in classpath, "
+ final String errorMessage = "failed to start infinispan cache manager, "
+ + "no infinispan configuration found on local file system or in classpath, "
+ "try setting Infinspan \"configFile\" parameter";
LOGGER.error(errorMessage);
throw new ContextException(errorMessage, ioException);
@@ -101,7 +101,7 @@ public class InfinispanManager {
*/
private void setSystemProperties(final InfinispanDistributorParameters infinispanDistributorParameters) {
System.setProperty("java.net.preferIPv4Stack",
- Boolean.toString(infinispanDistributorParameters.preferIPv4Stack()));
+ Boolean.toString(infinispanDistributorParameters.preferIPv4Stack()));
System.setProperty("jgroups.bind_addr", infinispanDistributorParameters.getjGroupsBindAddress());
}
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
index 862dcef83..3da1cf509 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
@@ -17,6 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.apex.plugins.context.distribution.infinispan;
import java.io.IOException;
@@ -38,6 +39,9 @@ import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
+/**
+ * The Class InfinispanContextDistributorTest.
+ */
public class InfinispanContextDistributorTest {
private static final XLogger logger = XLoggerFactory.getXLogger(InfinispanContextDistributorTest.class);
@@ -46,6 +50,9 @@ public class InfinispanContextDistributorTest {
private SchemaParameters schemaParameters;
private ContextParameters contextParameters;
+ /**
+ * Before test.
+ */
@Before
public void beforeTest() {
contextParameters = new ContextParameters();
@@ -70,6 +77,9 @@ public class InfinispanContextDistributorTest {
ParameterService.register(schemaParameters);
}
+ /**
+ * After test.
+ */
@After
public void afterTest() {
ParameterService.deregister(schemaParameters);
@@ -80,6 +90,13 @@ public class InfinispanContextDistributorTest {
ParameterService.deregister(contextParameters);
}
+ /**
+ * Test context album update infinispan.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
@Test
public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateInfinispan test . . .");
@@ -89,6 +106,13 @@ public class InfinispanContextDistributorTest {
logger.debug("Ran testContextAlbumUpdateInfinispan test");
}
+ /**
+ * Test context instantiation infinispan.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
@Test
public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationInfinispan test . . .");
@@ -98,6 +122,13 @@ public class InfinispanContextDistributorTest {
logger.debug("Ran testContextInstantiationInfinispan test");
}
+ /**
+ * Test context update infinispan.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
@Test
public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateInfinispan test . . .");
@@ -107,6 +138,13 @@ public class InfinispanContextDistributorTest {
logger.debug("Ran testContextUpdateInfinispan test");
}
+ /**
+ * Test sequential context instantiation infinispan.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
@Test
public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testSequentialContextInstantiationInfinispan test . . .");