diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-09-13 15:25:32 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-09-13 15:26:47 +0100 |
commit | 4cfa2e2d98f6877d54da304ef17f096284430908 (patch) | |
tree | c9452d2bf6bb96fae9c1e8e2d8ce8f8d01e69d22 /plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java | |
parent | 0e23f7634e1e1fb31454c516974613335fcea1a4 (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-distribution/plugins-context-distribution-infinispan/src/main/java')
3 files changed, 27 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()); } |