summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast')
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java18
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java31
2 files changed, 44 insertions, 5 deletions
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java
index 9d35c30a8..123d834ff 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java
@@ -20,6 +20,9 @@
package org.onap.policy.apex.plugins.context.distribution.hazelcast;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+
import java.util.Map;
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;
-
/**
* This context distributor distributes context across threads in multiple JVMs on multiple hosts.
* It uses hazelcast to distribute maps.
@@ -70,12 +70,20 @@ public class HazelcastContextDistributor extends AbstractDistributor {
// Create the hazelcast instance if it does not already exist
if (hazelcastInstance == null) {
- hazelcastInstance = Hazelcast.newHazelcastInstance();
+ setHazelcastInstance(Hazelcast.newHazelcastInstance());
}
LOGGER.exit("init(" + key + ")");
}
+ /**
+ * Set the hazelcast instance statically.
+ * @param newHazelcastInstance the hazelcast instance
+ */
+ private static void setHazelcastInstance(HazelcastInstance newHazelcastInstance) {
+ hazelcastInstance = newHazelcastInstance;
+ }
+
/*
* (non-Javadoc)
*
@@ -101,6 +109,6 @@ public class HazelcastContextDistributor extends AbstractDistributor {
if (hazelcastInstance != null) {
hazelcastInstance.shutdown();
}
- hazelcastInstance = null;
+ setHazelcastInstance(null);
}
}
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
index c3c137349..9d7f003ee 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
@@ -38,6 +38,9 @@ import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
+/**
+ * The Class HazelcastContextDistributorTest.
+ */
public class HazelcastContextDistributorTest {
private static final String HAZEL_CAST_PLUGIN_CLASS = HazelcastContextDistributor.class.getCanonicalName();
// Logger for this class
@@ -46,6 +49,9 @@ public class HazelcastContextDistributorTest {
private SchemaParameters schemaParameters;
private ContextParameters contextParameters;
+ /**
+ * Before test.
+ */
@Before
public void beforeTest() {
contextParameters = new ContextParameters();
@@ -69,6 +75,9 @@ public class HazelcastContextDistributorTest {
ParameterService.register(schemaParameters);
}
+ /**
+ * After test.
+ */
@After
public void afterTest() {
ParameterService.deregister(schemaParameters);
@@ -78,6 +87,14 @@ public class HazelcastContextDistributorTest {
ParameterService.deregister(contextParameters.getPersistorParameters());
ParameterService.deregister(contextParameters);
}
+
+ /**
+ * Test context album update hazelcast.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
@Test
public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateHazelcast test . . .");
@@ -87,6 +104,13 @@ public class HazelcastContextDistributorTest {
logger.debug("Ran testContextAlbumUpdateHazelcast test");
}
+ /**
+ * Test context instantiation hazelcast.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
@Test
public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationHazelcast test . . .");
@@ -96,6 +120,13 @@ public class HazelcastContextDistributorTest {
logger.debug("Ran testContextInstantiationHazelcast test");
}
+ /**
+ * Test context update hazelcast.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
@Test
public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateHazelcast test . . .");