diff options
Diffstat (limited to 'plugins/plugins-context')
21 files changed, 76 insertions, 2959 deletions
diff --git a/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml index ce80a7a89..71806c54f 100644 --- a/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml +++ b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml @@ -36,5 +36,11 @@ <artifactId>hazelcast</artifactId> <version>${version.hazelcast}</version> </dependency> + <dependency> + <groupId>org.onap.policy.apex-pdp.context</groupId> + <artifactId>context-test-utils</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextUpdate.java b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java index 3abfd1873..c999c95f0 100644 --- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextUpdate.java +++ b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java @@ -18,77 +18,57 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.apex.plugins.context.test.distribution; +package org.onap.policy.apex.plugins.context.distribution.hazelcast; import java.io.IOException; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.apex.context.parameters.DistributorParameters; +import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate; +import org.onap.policy.apex.context.test.distribution.ContextInstantiation; import org.onap.policy.apex.context.test.distribution.ContextUpdate; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -public class TestContextUpdate { +public class HazelcastContextDistributorTest { + private static final String HAZEL_CAST_PLUGIN_CLASS = HazelcastContextDistributor.class.getCanonicalName(); // Logger for this class - private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdate.class); + private static final XLogger logger = XLoggerFactory.getXLogger(HazelcastContextDistributorTest.class); - @Before - public void beforeTest() {} - - @After - public void afterTest() {} @Test - public void testContextUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextUpdateJVMLocalVarSet test . . ."); + public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextAlbumUpdateHazelcast test . . ."); final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - new ContextUpdate().testContextUpdate(); + contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS); + new ContextAlbumUpdate().testContextAlbumUpdate(); - logger.debug("Ran testContextUpdateJVMLocalVarSet test"); + logger.debug("Ran testContextAlbumUpdateHazelcast test"); } @Test - public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextUpdateHazelcast test . . ."); + public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextInstantiationHazelcast test . . ."); final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); - new ContextUpdate().testContextUpdate(); + contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS); + new ContextInstantiation().testContextInstantiation(); - logger.debug("Ran testContextUpdateHazelcast test"); + logger.debug("Ran testContextInstantiationHazelcast test"); } @Test - public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextUpdateInfinispan test . . ."); + public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextUpdateHazelcast test . . ."); final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor"); - new InfinispanDistributorParameters(); - + contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS); new ContextUpdate().testContextUpdate(); - logger.debug("Ran testContextUpdateInfinispan test"); + logger.debug("Ran testContextUpdateHazelcast test"); } - @Test - public void testContextUpdateJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextUpdateJVMLocalVarNotSet test . . ."); - - new ContextParameters(); - new ContextUpdate().testContextUpdate(); - - logger.debug("Ran testContextUpdateJVMLocalVarNotSet test"); - } } diff --git a/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml b/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml index 7592edd91..c6985a952 100644 --- a/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml +++ b/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml @@ -42,6 +42,12 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.onap.policy.apex-pdp.context</groupId> + <artifactId>context-test-utils</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextInstantiation.java b/plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java index a13b798ef..34fa7d439 100644 --- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextInstantiation.java +++ b/plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Copyright (C) 2018 Ericsson. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,70 +17,77 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - -package org.onap.policy.apex.plugins.context.test.distribution; +package org.onap.policy.apex.plugins.context.distribution.infinispan; import java.io.IOException; import org.junit.Test; import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.apex.context.parameters.DistributorParameters; +import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate; import org.onap.policy.apex.context.test.distribution.ContextInstantiation; +import org.onap.policy.apex.context.test.distribution.ContextUpdate; +import org.onap.policy.apex.context.test.distribution.SequentialContextInstantiation; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -public class TestContextInstantiation { - // Logger for this class - private static final XLogger logger = XLoggerFactory.getXLogger(TestContextInstantiation.class); +public class InfinispanContextDistributorTest { + private static final XLogger logger = XLoggerFactory.getXLogger(InfinispanContextDistributorTest.class); + + private static final String PLUGIN_CLASS = InfinispanContextDistributor.class.getCanonicalName(); @Test - public void testContextInstantiationJVMLocalVarSet() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextInstantiationJVMLocalVarSet test . . ."); + public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextAlbumUpdateInfinispan test . . ."); final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - new ContextInstantiation().testContextInstantiation(); + contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS); + new InfinispanDistributorParameters(); + + new ContextAlbumUpdate().testContextAlbumUpdate(); - logger.debug("Ran testContextInstantiationJVMLocalVarSet test"); + logger.debug("Ran testContextAlbumUpdateInfinispan test"); } @Test - public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextInstantiationHazelcast test . . ."); + public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextInstantiationInfinispan test . . ."); final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); + contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS); + new InfinispanDistributorParameters(); + new ContextInstantiation().testContextInstantiation(); - logger.debug("Ran testContextInstantiationHazelcast test"); + logger.debug("Ran testContextInstantiationInfinispan test"); } @Test - public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextInstantiationInfinispan test . . ."); + public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextUpdateInfinispan test . . ."); final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor"); + contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS); new InfinispanDistributorParameters(); - new ContextInstantiation().testContextInstantiation(); + new ContextUpdate().testContextUpdate(); - logger.debug("Ran testContextInstantiationInfinispan test"); + logger.debug("Ran testContextUpdateInfinispan test"); } @Test - public void testContextInstantiationJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextInstantiationJVMLocalVarNotSet test . . ."); + public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException { + logger.debug("Running testSequentialContextInstantiationInfinispan test . . ."); - new ContextParameters(); - new ContextInstantiation().testContextInstantiation(); + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS); + new InfinispanDistributorParameters(); + + new SequentialContextInstantiation().testSequentialContextInstantiation(); - logger.debug("Ran testContextInstantiationJVMLocalVarNotSet test"); + logger.debug("Ran testSequentialContextInstantiationInfinispan test"); } + + } diff --git a/plugins/plugins-context/context-metrics/pom.xml b/plugins/plugins-context/context-metrics/pom.xml deleted file mode 100644 index 1e5800c5e..000000000 --- a/plugins/plugins-context/context-metrics/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2018 Ericsson. All rights reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - SPDX-License-Identifier: Apache-2.0 - ============LICENSE_END========================================================= ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId> - <artifactId>plugins-context</artifactId> - <version>2.0.0-SNAPSHOT</version> - </parent> - <artifactId>context-metrics</artifactId> - <name>${project.artifactId}</name> - <description>[${project.parent.artifactId}] module to calculate metrics using various plugins</description> - - - <dependencies> - <dependency> - <groupId>org.onap.policy.apex-pdp.core</groupId> - <artifactId>core-infrastructure</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.context</groupId> - <artifactId>context-test</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-distribution</groupId> - <artifactId>context-distribution-hazelcast</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-distribution</groupId> - <artifactId>context-distribution-infinispan</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-locking</groupId> - <artifactId>context-locking-curator</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-locking</groupId> - <artifactId>context-locking-hazelcast</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.curator</groupId> - <artifactId>curator-test</artifactId> - <version>3.2.0</version> - <scope>test</scope> - </dependency> - </dependencies> -</project>
\ No newline at end of file diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java b/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java deleted file mode 100644 index de719c937..000000000 --- a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java +++ /dev/null @@ -1,525 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.metrics; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.onap.policy.apex.context.ContextAlbum; -import org.onap.policy.apex.context.ContextException; -import org.onap.policy.apex.context.Distributor; -import org.onap.policy.apex.context.impl.distribution.DistributorFactory; -import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.apex.context.parameters.DistributorParameters; -import org.onap.policy.apex.context.parameters.LockManagerParameters; -import org.onap.policy.apex.context.test.concepts.TestContextItem003; -import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel; -import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters; -import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManagerParameters; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The Class concurrentContextMetrics tests concurrent use of context. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class ConcurrentContextMetrics { - private static final int NUM_ARGS = 8; - private static final int ARG_LABEL = 0; - private static final int ARG_JVM_COUNT = 1; - private static final int ARG_THREAD_COUNT = 2; - private static final int ARG_ITERATIONS = 3; - private static final int ARG_ARRAY_SIZE = 4; - private static final int ARG_LOCK_TYPE = 5; - private static final int ARG_ZOOKEEPER_ADDRESS = 6; - private static final int ARG_INTERACTIVE = 7; - - private static final int TIME_10_MS = 10; - - // Logger for this class - private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextMetrics.class); - - // Test parameters - private String testLabel = null; - private int jvmCount = -1; - private int threadCount = -1; - private int threadLoops = -1; - private int longArraySize = -1; - private int lockType = -1; - private String zookeeperAddress = null; - private long total = -1; - private boolean interactive = false; - - // The context distributor and map used by each test - private Distributor contextDistributor = null; - private ContextAlbum lTypeAlbum = null; - - private final DateFormat dateFormat = new SimpleDateFormat("yyyy,MM,dd,HH,mm,ss,S"); - - /** - * The main method. - * - * @param args the args - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - public static void main(final String[] args) throws ApexModelException, IOException, ApexException { - if (args.length != NUM_ARGS) { - System.err.println( - "usage: ConcurrentContextMetrics testLabel jvmCount threadCount threadLoops longArraySize lockType zookeeperAddress interactive"); - return; - } - // @formatter:off - final ConcurrentContextMetrics concurrentContextMetrics = new ConcurrentContextMetrics( - args[ARG_LABEL], - Integer.valueOf(args[ARG_JVM_COUNT]), - Integer.valueOf(args[ARG_THREAD_COUNT]), - Integer.valueOf(args[ARG_ITERATIONS]), - Integer.valueOf(args[ARG_ARRAY_SIZE]), - Integer.valueOf(args[ARG_LOCK_TYPE]), - args[ARG_ZOOKEEPER_ADDRESS], - Boolean.valueOf(args[ARG_INTERACTIVE])); - // @formatter:on - - concurrentContextMetrics.concurrentContextMetricsJVMLocal(); - concurrentContextMetrics.concurrentContextMetricsCurator(); - concurrentContextMetrics.concurrentContextMetricsHazelcast(); - concurrentContextMetrics.concurrentContextMetricsHazelcastMultiJVMHazelcastLock(); - concurrentContextMetrics.concurrentContextMetricsInfinispanMultiJVMHazelcastlock(); - concurrentContextMetrics.concurrentContextMetricsInfinispanMultiJVMCuratorLock(); - concurrentContextMetrics.concurrentContextMetricsHazelcastMultiJVMCuratorLock(); - } - - /** - * The Constructor. - * - * @param testLabel the test label - * @param jvmCount the jvm count - * @param threadCount the thread count - * @param threadLoops the thread loops - * @param longArraySize the long array size - * @param lockType the lock type - * @param zookeeperAddress the zookeeper address - * @param interactive the interactive - */ - // CHECKSTYLE:OFF: checkstyle:parameterNumber - public ConcurrentContextMetrics(final String testLabel, final int jvmCount, final int threadCount, - final int threadLoops, final int longArraySize, final int lockType, final String zookeeperAddress, - final boolean interactive) { - // CHECKSTYLE:ON: checkstyle:parameterNumber - super(); - this.testLabel = testLabel; - this.jvmCount = jvmCount; - this.threadCount = threadCount; - this.threadLoops = threadLoops; - this.longArraySize = longArraySize; - this.lockType = lockType; - this.zookeeperAddress = zookeeperAddress; - this.interactive = interactive; - } - - /** - * Concurrent context metrics JVM local. - * - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - private void concurrentContextMetricsJVMLocal() throws ApexModelException, IOException, ApexException { - if (jvmCount != 1) { - return; - } - - LOGGER.debug("Running concurrentContextMetricsJVMLocalVarSet metrics . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - contextParameters.getLockManagerParameters() - .setPluginClass(LockManagerParameters.DEFAULT_LOCK_MANAGER_PLUGIN_CLASS); - runConcurrentContextMetrics("JVMLocal"); - - LOGGER.debug("Ran concurrentContextMetricsJVMLocalVarSet metrics"); - } - - /** - * Concurrent context metrics hazelcast. - * - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - private void concurrentContextMetricsHazelcast() throws ApexModelException, IOException, ApexException { - if (jvmCount != 1) { - return; - } - - LOGGER.debug("Running concurrentContextMetricsHazelcast metrics . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager"); - runConcurrentContextMetrics("Hazelcast"); - - LOGGER.debug("Ran concurrentContextMetricsHazelcast metrics"); - } - - /** - * Concurrent context metrics curator. - * - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - private void concurrentContextMetricsCurator() throws ApexModelException, IOException, ApexException { - if (jvmCount != 1) { - return; - } - - LOGGER.debug("Running concurrentContextMetricsCurator metrics . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - - final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters(); - curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager"); - contextParameters.setLockManagerParameters(curatorParameters); - curatorParameters.setZookeeperAddress(zookeeperAddress); - - runConcurrentContextMetrics("Curator"); - - LOGGER.debug("Ran concurrentContextMetricsCurator metrics"); - } - - /** - * Concurrent context metrics hazelcast multi JVM hazelcast lock. - * - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - private void concurrentContextMetricsHazelcastMultiJVMHazelcastLock() - throws ApexModelException, IOException, ApexException { - LOGGER.debug("Running concurrentContextMetricsHazelcastMultiJVMHazelcastLock metrics . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); - contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager"); - runConcurrentContextMetrics("HazelcastMultiJVMHazelcastLock"); - - LOGGER.debug("Ran concurrentContextMetricsHazelcastMultiJVMHazelcastLock metrics"); - } - - /** - * Concurrent context metrics infinispan multi JVM hazelcastlock. - * - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - private void concurrentContextMetricsInfinispanMultiJVMHazelcastlock() - throws ApexModelException, IOException, ApexException { - LOGGER.debug("Running concurrentContextMetricsInfinispanMultiJVMHazelcastlock metrics . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor"); - contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager"); - - final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters(); - contextParameters.setDistributorParameters(infinispanParameters); - - runConcurrentContextMetrics("InfinispanMultiJVMHazelcastlock"); - - LOGGER.debug("Ran concurrentContextMetricsInfinispanMultiJVMHazelcastlock metrics"); - } - - /** - * Concurrent context metrics infinispan multi JVM curator lock. - * - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - private void concurrentContextMetricsInfinispanMultiJVMCuratorLock() - throws ApexModelException, IOException, ApexException { - LOGGER.debug("Running concurrentContextMetricsInfinispanMultiJVMCuratorLock metrics . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor"); - - final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters(); - curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager"); - contextParameters.setLockManagerParameters(curatorParameters); - curatorParameters.setZookeeperAddress(zookeeperAddress); - - final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters(); - contextParameters.setDistributorParameters(infinispanParameters); - - runConcurrentContextMetrics("InfinispanMultiJVMCuratorLock"); - - LOGGER.debug("Ran concurrentContextMetricsInfinispanMultiJVMCuratorLock metrics"); - } - - /** - * Concurrent context metrics hazelcast multi JVM curator lock. - * - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - private void concurrentContextMetricsHazelcastMultiJVMCuratorLock() - throws ApexModelException, IOException, ApexException { - LOGGER.debug("Running concurrentContextMetricsHazelcastMultiJVMCuratorLock metrics . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); - - final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters(); - curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager"); - contextParameters.setLockManagerParameters(curatorParameters); - curatorParameters.setZookeeperAddress(zookeeperAddress); - - runConcurrentContextMetrics("HazelcastMultiJVMCuratorLock"); - - LOGGER.debug("Ran concurrentContextMetricsHazelcastMultiJVMCuratorLock metrics"); - } - - /** - * Run concurrent context metrics. - * - * @param testName the test name - * @throws ApexModelException the apex model exception - * @throws IOException the IO exception - * @throws ApexException the apex exception - */ - private void runConcurrentContextMetrics(final String testName) - throws ApexModelException, IOException, ApexException { - total = -1; - outMetricLine(testName, "Init"); - - try { - setupContext(); - } catch (final Exception e) { - e.printStackTrace(); - throw e; - } - - outMetricLine(testName, "Start"); - - Thread[] threadArray; - - // Check if we have a single JVM or multiple JVMs - int runningThreadCount = -1; - if (jvmCount == 1) { - threadArray = new Thread[threadCount]; - - // Run everything in this JVM - for (int t = 0; t < threadCount; t++) { - threadArray[t] = - new Thread(new ConcurrentContextMetricsThread(0, t, threadLoops, longArraySize, lockType)); - threadArray[t].setName(testLabel + "_" + testName + ":concurrentContextMetricsThread_0_" + t); - threadArray[t].start(); - } - - outMetricLine(testName, "Running"); - runningThreadCount = threadCount; - } else { - threadArray = new Thread[jvmCount]; - - final ConcurrentContextMetricsJVMThread[] jvmArray = new ConcurrentContextMetricsJVMThread[jvmCount]; - // Spawn JVMs to run the tests - for (int j = 0; j < jvmCount; j++) { - jvmArray[j] = new ConcurrentContextMetricsJVMThread(testLabel + "_" + testName, j, threadCount, - threadLoops, longArraySize, lockType); - threadArray[j] = new Thread(jvmArray[j]); - threadArray[j].setName(testLabel + "_" + testName + ":concurrentContextMetricsJVMThread_" + j); - threadArray[j].start(); - } - - boolean allReadyToGo; - do { - ThreadUtilities.sleep(TIME_10_MS); - allReadyToGo = true; - for (int j = 0; j < jvmCount; j++) { - if (!jvmArray[j].isReadyToGo()) { - allReadyToGo = false; - break; - } - } - } while (!allReadyToGo); - - outMetricLine(testName, "Ready"); - if (interactive) { - System.in.read(); - } - outMetricLine(testName, "Running"); - - for (int j = 0; j < jvmCount; j++) { - jvmArray[j].offYouGo(); - } - - boolean allFinished; - do { - ThreadUtilities.sleep(TIME_10_MS); - allFinished = true; - for (int j = 0; j < jvmCount; j++) { - if (!jvmArray[j].isAllFinished()) { - allFinished = false; - break; - } - } - } while (!allFinished); - - outMetricLine(testName, "Completed"); - - verifyContext(testName); - - for (int j = 0; j < jvmCount; j++) { - jvmArray[j].finishItOut(); - } - - runningThreadCount = jvmCount; - } - - boolean allFinished; - do { - ThreadUtilities.sleep(TIME_10_MS); - allFinished = true; - for (int i = 0; i < runningThreadCount; i++) { - if (threadArray[i].isAlive()) { - allFinished = false; - break; - } - } - } while (!allFinished); - - if (jvmCount == 1) { - outMetricLine(testName, "Completed"); - verifyContext(testName); - } - - clearContext(testName); - } - - /** - * Setup context. - * - * @throws ContextException the context exception - */ - private void setupContext() throws ContextException { - final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1"); - contextDistributor = new DistributorFactory().getDistributor(distributorKey); - - final AxArtifactKey[] usedArtifactStackArray = {new AxArtifactKey("testC-top", "0.0.1"), - new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")}; - - final AxContextModel albumsModel = TestContextAlbumFactory.createMultiAlbumsContextModel(); - contextDistributor.registerModel(albumsModel); - - lTypeAlbum = contextDistributor.createContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1")); - assert (lTypeAlbum != null); - lTypeAlbum.setUserArtifactStack(usedArtifactStackArray); - - for (int i = 0; i < longArraySize; i++) { - final String longKey = Integer.toString(i); - final TestContextItem003 longItem = new TestContextItem003(); - longItem.setLongValue(0); - lTypeAlbum.put(longKey, longItem); - } - } - - /** - * Verify context. - * - * @param testName the test name - * @throws ContextException the context exception - */ - private void verifyContext(final String testName) throws ContextException { - total = 0; - - try { - for (int i = 0; i < longArraySize; i++) { - total += ((TestContextItem003) lTypeAlbum.get(Integer.toString(i))).getLongValue(); - } - - outMetricLine(testName, "Totaled"); - } catch (final Exception e) { - e.printStackTrace(); - } - - if (lockType == 2) { - if (total == jvmCount * threadCount * threadLoops) { - outMetricLine(testName, "VerifiedOK"); - } else { - outMetricLine(testName, "VerifiedFail"); - } - } else { - if (total == 0) { - outMetricLine(testName, "VerifiedOK"); - } else { - outMetricLine(testName, "VerifiedFail"); - } - } - } - - /** - * Clear context. - * - * @param testName the test name - * @throws ContextException the context exception - */ - private void clearContext(final String testName) throws ContextException { - contextDistributor.clear(); - contextDistributor = null; - - outMetricLine(testName, "Cleared"); - } - - /** - * Out metric line. - * - * @param testName the test name - * @param testPhase the test phase - */ - public void outMetricLine(final String testName, final String testPhase) { - System.out.println("ContextMetrics," + dateFormat.format(new Date()) + "," + System.currentTimeMillis() + "," - + testLabel + "," + testName + "," + testPhase + "," + jvmCount + "," + threadCount + "," + threadLoops - + "," + longArraySize + "," + lockType + "," + total); - } -} diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java b/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java deleted file mode 100644 index ed81e39a1..000000000 --- a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java +++ /dev/null @@ -1,212 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.metrics; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Arrays; - -import org.onap.policy.apex.context.ContextAlbum; -import org.onap.policy.apex.context.Distributor; -import org.onap.policy.apex.context.impl.distribution.DistributorFactory; -import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.service.AbstractParameters; -import org.onap.policy.apex.model.basicmodel.service.ParameterService; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel; -import org.onap.policy.apex.model.utilities.Assertions; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; - -/** - * The Class ConcurrentContextMetricsJVM rins in its own JVM to test concurrent context updates and - * lockings across JVMs. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public final class ConcurrentContextMetricsJVM { - // Logger for this class - private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextMetricsJVM.class); - - private static final int NUM_ARGS = 6; - private static final int ARG_JVM_NO = 1; - private static final int ARG_THREAD_COUNT = 2; - private static final int ARG_ITERATIONS = 3; - private static final int ARG_ARRAY_SIZE = 4; - private static final int ARG_LOCK_TYPE = 5; - - private static final int WAIT_10_MS = 10; - - /** - * The Constructor for this class. - * - * @param testType the test type - * @param jvmNo the jvm no - * @param threadCount the thread count - * @param threadLoops the thread loops - * @param longArraySize the long array size - * @param lockType the lock type - * @throws ApexException the apex exception - * @throws IOException the IO exception - */ - private ConcurrentContextMetricsJVM(final String testType, final int jvmNo, final int threadCount, - final int threadLoops, final int longArraySize, final int lockType) throws ApexException, IOException { - LOGGER.debug("starting JVMs and threads . . ."); - - final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); - - // Set up the distributor for this JVM - final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1"); - final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey); - - final AxArtifactKey[] usedArtifactStackArray = {new AxArtifactKey("testC-top_" + jvmNo, "0.0.1"), - new AxArtifactKey("testC-next_" + jvmNo, "0.0.1"), new AxArtifactKey("testC-bot_" + jvmNo, "0.0.1")}; - - final AxContextModel testAxContextModel = TestContextAlbumFactory.createLongContextModel(); - contextDistributor.registerModel(testAxContextModel); - final ContextAlbum testContextAlbum = - contextDistributor.createContextAlbum(new AxArtifactKey("LongSameTypeContextAlbum", "0.0.1")); - Assertions.argumentNotNull(testContextAlbum, "testContextAlbum may not be null"); - testContextAlbum.setUserArtifactStack(usedArtifactStackArray); - - final Thread[] threadArray = new Thread[threadCount]; - - for (int t = 0; t < threadCount; t++) { - threadArray[t] = - new Thread(new ConcurrentContextMetricsThread(jvmNo, t, threadLoops, longArraySize, lockType)); - threadArray[t].setName(testType + ":ConcurrentContextMetricsThread_" + jvmNo + "_" + t); - threadArray[t].start(); - LOGGER.debug("started thread " + threadArray[t].getName()); - } - - System.out.println("ReadyToGo"); - while (true) { - final String goLine = bufferedReader.readLine(); - if (!goLine.trim().equals("OffYouGo")) { - throw new IOException("Expected OffYouGo"); - } - break; - } - - boolean allFinished; - do { - allFinished = true; - for (int t = 0; t < threadCount; t++) { - if (threadArray[t].isAlive()) { - allFinished = false; - ThreadUtilities.sleep(WAIT_10_MS); - break; - } - } - } while (!allFinished); - - System.out.println("AllFinished"); - while (true) { - final String goLine = bufferedReader.readLine(); - if (!goLine.trim().equals("FinishItOut")) { - throw new IOException("Expected FinishItOut"); - } - break; - } - - LOGGER.debug("threads finished"); - contextDistributor.clear(); - } - - /** - * The main method. - * - * @param args the args - * @throws JsonSyntaxException the json syntax exception - * @throws ClassNotFoundException the class not found exception - */ - @SuppressWarnings("unchecked") - public static void main(final String[] args) throws JsonSyntaxException, ClassNotFoundException { - if (args.length < NUM_ARGS || (args.length % 2 != 0)) { - LOGGER.error("invalid arguments: " + Arrays.toString(args)); - LOGGER.error( - "usage: ConcurrentContextMetricsJVM testLabel jvmNo threadCount threadLoops longArraySize lockType [parameterKey parameterJson].... "); - return; - } - - int jvmNo = -1; - int threadCount = -1; - int threadLoops = -1; - int longArraySize = -1; - int lockType = -1; - - try { - jvmNo = Integer.parseInt(args[ARG_JVM_NO]); - } catch (final Exception e) { - LOGGER.error("invalid argument jvmNo", e); - return; - } - - try { - threadCount = Integer.parseInt(args[ARG_THREAD_COUNT]); - } catch (final Exception e) { - LOGGER.error("invalid argument threadCount", e); - return; - } - - try { - threadLoops = Integer.parseInt(args[ARG_ITERATIONS]); - } catch (final Exception e) { - LOGGER.error("invalid argument threadLoops", e); - return; - } - - try { - longArraySize = Integer.parseInt(args[ARG_ARRAY_SIZE]); - } catch (final Exception e) { - LOGGER.error("invalid argument longArraySize", e); - return; - } - - try { - lockType = Integer.parseInt(args[ARG_LOCK_TYPE]); - } catch (final Exception e) { - LOGGER.error("invalid argument lockType", e); - return; - } - - for (int p = NUM_ARGS; p < args.length - 1; p += 2) { - @SuppressWarnings("rawtypes") - final Class parametersClass = Class.forName(args[p]); - final AbstractParameters parameters = - (AbstractParameters) new Gson().fromJson(args[p + 1], parametersClass); - ParameterService.registerParameters(parametersClass, parameters); - } - - try { - new ConcurrentContextMetricsJVM(args[0], jvmNo, threadCount, threadLoops, longArraySize, lockType); - } catch (final Exception e) { - LOGGER.error("error running test in JVM", e); - return; - } - } -} diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java b/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java deleted file mode 100644 index 64bc0cab6..000000000 --- a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java +++ /dev/null @@ -1,187 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.metrics; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; - -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.service.AbstractParameters; -import org.onap.policy.apex.model.basicmodel.service.ParameterService; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -import com.google.gson.Gson; - -/** - * The Class ConcurrentContextMetricsJVMThread gets metrics for concurrent use of context. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class ConcurrentContextMetricsJVMThread implements Runnable { - // Logger for this class - private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextMetricsJVMThread.class); - - private final String testType; - private final int jvm; - private final int threadCount; - private final int threadLoops; - private final int longArraySize; - private final int lockType; - - private boolean readyToGo = false; - private boolean allFinished = false; - - private PrintWriter processWriter; - - /** - * The Constructor. - * - * @param testType the test type - * @param jvm the jvm - * @param threadCount the thread count - * @param threadLoops the thread loops - * @param longArraySize the long array size - * @param lockType the lock type - * @throws ApexException the apex exception - */ - public ConcurrentContextMetricsJVMThread(final String testType, final int jvm, final int threadCount, - final int threadLoops, final int longArraySize, final int lockType) throws ApexException { - this.testType = testType; - this.jvm = jvm; - this.threadCount = threadCount; - this.threadLoops = threadLoops; - this.longArraySize = longArraySize; - this.lockType = lockType; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - final List<String> commandList = new ArrayList<>(); - commandList.add(System.getProperty("java.home") + System.getProperty("file.separator") + "bin" - + System.getProperty("file.separator") + "java"); - commandList.add("-cp"); - commandList.add(System.getProperty("java.class.path")); - for (final Entry<Object, Object> property : System.getProperties().entrySet()) { - if (property.getKey().toString().startsWith("APEX") - || property.getKey().toString().equals("java.net.preferIPv4Stack") - || property.getKey().toString().equals("jgroups.bind_addr")) { - commandList.add("-D" + property.getKey().toString() + "=" + property.getValue().toString()); - } - } - commandList.add("org.onap.policy.apex.plugins.context.metrics.ConcurrentContextMetricsJVM"); - commandList.add(testType); - commandList.add(new Integer(jvm).toString()); - commandList.add(new Integer(threadCount).toString()); - commandList.add(new Integer(threadLoops).toString()); - commandList.add(new Integer(longArraySize).toString()); - commandList.add(new Integer(lockType).toString()); - - for (final Entry<Class<?>, AbstractParameters> parameterServiceEntry : ParameterService.getAll()) { - commandList.add(parameterServiceEntry.getKey().getCanonicalName()); - commandList.add(new Gson().toJson(parameterServiceEntry.getValue())); - } - - LOGGER.info("starting JVM " + jvm); - - // Run the JVM - final ProcessBuilder processBuilder = new ProcessBuilder(commandList); - processBuilder.redirectErrorStream(true); - Process process; - - try { - process = processBuilder.start(); - - final InputStream is = process.getInputStream(); - processWriter = new PrintWriter(process.getOutputStream()); - final InputStreamReader isr = new InputStreamReader(is); - final BufferedReader br = new BufferedReader(isr); - - String line; - - LOGGER.info("JVM Output for command " + commandList + "\n"); - while ((line = br.readLine()) != null) { - LOGGER.info(line); - - if (line.trim().equals("ReadyToGo")) { - readyToGo = true; - } else if (line.trim().equals("AllFinished")) { - allFinished = true; - } - } - - // Wait to get exit value - try { - final int exitValue = process.waitFor(); - LOGGER.info("\n\nJVM " + jvm + " finished, exit value is " + exitValue); - } catch (final InterruptedException e) { - e.printStackTrace(); - } - } catch (final IOException e1) { - e1.printStackTrace(); - } - } - - /** - * Checks if is ready to go. - * - * @return true, if checks if is ready to go - */ - public boolean isReadyToGo() { - return readyToGo; - } - - /** - * Checks if is all finished. - * - * @return true, if checks if is all finished - */ - public boolean isAllFinished() { - return allFinished; - } - - /** - * Off you go. - */ - public void offYouGo() { - processWriter.println("OffYouGo"); - processWriter.flush(); - } - - /** - * Finish it out. - */ - public void finishItOut() { - processWriter.println("FinishItOut"); - processWriter.flush(); - } -} diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java b/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java deleted file mode 100644 index 2752536e9..000000000 --- a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.metrics; - -import java.util.Random; - -import org.onap.policy.apex.context.ContextAlbum; -import org.onap.policy.apex.context.ContextException; -import org.onap.policy.apex.context.Distributor; -import org.onap.policy.apex.context.impl.distribution.DistributorFactory; -import org.onap.policy.apex.context.test.concepts.TestContextItem003; -import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The Class ConcurrentContextMetricsThread gets metrics for concurrent use of context. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class ConcurrentContextMetricsThread implements Runnable { - // Logger for this class - private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextMetricsThread.class); - private final Distributor contextDistributor; - private final int jvm; - private final int instance; - private final int threadLoops; - private final int longArraySize; - private final int lockType; - - /** - * The Constructor. - * - * @param jvm the jvm - * @param instance the instance - * @param threadLoops the thread loops - * @param longArraySize the long array size - * @param lockType the lock type - * @throws ApexException the apex exception - */ - public ConcurrentContextMetricsThread(final int jvm, final int instance, final int threadLoops, - final int longArraySize, final int lockType) throws ApexException { - this.jvm = jvm; - this.instance = instance; - this.threadLoops = threadLoops; - this.longArraySize = longArraySize; - this.lockType = lockType; - - final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor_" + jvm + "_" + instance, "0.0.1"); - contextDistributor = new DistributorFactory().getDistributor(distributorKey); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - LOGGER.info("running ConcurrentContextMetricsThread_" + jvm + "_" + instance + " . . ."); - - ContextAlbum lTypeAlbum = null; - try { - final AxContextModel axTestContextModel = TestContextAlbumFactory.createMultiAlbumsContextModel(); - contextDistributor.registerModel(axTestContextModel); - lTypeAlbum = contextDistributor.createContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1")); - } catch (final Exception e) { - LOGGER.error("could not get the test context album", e); - LOGGER.error("failed ConcurrentContextMetricsThread_" + jvm + "_" + instance); - return; - } - - if (lTypeAlbum == null) { - LOGGER.error("could not find the test context album"); - LOGGER.error("failed ConcurrentContextMetricsThread_" + jvm + "_" + instance); - return; - } - - final AxArtifactKey[] usedArtifactStackArray = - {new AxArtifactKey("testCC-top", "0.0.1"), new AxArtifactKey("testCC-" + instance, "0.0.1")}; - - lTypeAlbum.setUserArtifactStack(usedArtifactStackArray); - - final Random rand = new Random(); - - for (int i = 0; i < threadLoops; i++) { - // Get the next random entry to use - final String nextLongKey = Integer.toString(rand.nextInt(longArraySize)); - - if (lockType == 0) { - final TestContextItem003 item = (TestContextItem003) lTypeAlbum.get(nextLongKey); - final long value = item.getLongValue(); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("lock type=" + lockType + ", value=" + value); - } - continue; - } - - if (lockType == 1) { - try { - lTypeAlbum.lockForReading(nextLongKey); - } catch (final ContextException e) { - LOGGER.error("could not acquire read lock on context album, key=" + nextLongKey, e); - continue; - } - - final TestContextItem003 item = (TestContextItem003) lTypeAlbum.get(nextLongKey); - final long value = item.getLongValue(); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("lock type=" + lockType + ", value=" + value); - } - - try { - lTypeAlbum.unlockForReading(nextLongKey); - } catch (final ContextException e) { - LOGGER.error("could not release read lock on context album, key=" + nextLongKey, e); - } - - continue; - } - - if (lockType == 2) { - try { - lTypeAlbum.lockForWriting(nextLongKey); - } catch (final ContextException e) { - LOGGER.error("could not acquire write lock on context album, key=" + nextLongKey, e); - continue; - } - - final TestContextItem003 item = (TestContextItem003) lTypeAlbum.get(nextLongKey); - long value = item.getLongValue(); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("lock type=" + lockType + ", value=" + value); - } - item.setLongValue(++value); - lTypeAlbum.put(nextLongKey, item); - - try { - lTypeAlbum.unlockForWriting(nextLongKey); - } catch (final ContextException e) { - LOGGER.error("could not release write lock on context album, key=" + nextLongKey, e); - } - continue; - } - } - - LOGGER.info("completed ConcurrentContextMetricsThread_" + jvm + "_" + instance); - } -} diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/package-info.java b/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/package-info.java deleted file mode 100644 index 5e916b6db..000000000 --- a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -/** - * Used to get metrics on the performance of Context Album performance for various types of - * distribution and locking mechanisms in APEX. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -package org.onap.policy.apex.plugins.context.metrics; diff --git a/plugins/plugins-context/context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java b/plugins/plugins-context/context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java deleted file mode 100644 index 5607f8711..000000000 --- a/plugins/plugins-context/context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.metrics; - -import static org.junit.Assert.fail; - -import java.io.IOException; - -import org.apache.curator.test.TestingServer; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class TestMetrics { - // Zookeeper test server - TestingServer zkTestServer; - - @Before - public void beforeTest() throws Exception { - zkTestServer = new TestingServer(62181); - } - - @After - public void afterTest() throws IOException { - zkTestServer.stop(); - } - - @Test - public void getSingleJVMMetrics() { - final String[] args = {"singleJVMTestNL", "1", "32", "1000", "65536", "0", "localhost:62181", "false"}; - - try { - ConcurrentContextMetrics.main(args); - } catch (final Exception e) { - fail("Metrics test failed"); - e.printStackTrace(); - } - } -} diff --git a/plugins/plugins-context/context-metrics/src/test/resources/hazelcast/hazelcast.xml b/plugins/plugins-context/context-metrics/src/test/resources/hazelcast/hazelcast.xml deleted file mode 100644 index 84da4951e..000000000 --- a/plugins/plugins-context/context-metrics/src/test/resources/hazelcast/hazelcast.xml +++ /dev/null @@ -1,643 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2016-2018 Ericsson. All rights reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - SPDX-License-Identifier: Apache-2.0 - ============LICENSE_END========================================================= ---> - -<hazelcast xmlns="http://www.hazelcast.com/schema/config" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <group> - <name>HazelcastGroup3.0EVAL</name> - <password>password3.0EVAL</password> - </group> - <network> - <port auto-increment="true">5706</port> - <join> - <multicast enabled="false"> - <multicast-group>224.2.2.10</multicast-group> - <multicast-port>54327</multicast-port> - </multicast> - <tcp-ip enabled="true"> - <members>10.0.0.0</members> - <!-- members>192.168.219.141</members--> - </tcp-ip> - </join> - <interfaces enabled="false"> - <!-- This value will allow hazelcast to run locally from the IDE --> - <interface>127.0.0.*</interface> - </interfaces> - </network> - <properties> - <property name="hazelcast.icmp.enabled">true</property> - <property name="hazelcast.logging.type">slf4j</property> - <!-- disable the hazelcast shutdown hook - prefer to control the shutdown - in code --> - <property name="hazelcast.shutdownhook.enabled">false</property> - <property name="hazelcast.graceful.shutdown.max.wait">60</property> - </properties> - <executor-service> - <pool-size>16</pool-size> - </executor-service> - <queue name="default"> - <!-- Maximum size of the queue. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>100000</max-size> - <!-- Maximum number of seconds for each item to stay in the queue. Items - that are not consumed in <time-to-live-seconds> will automatically get evicted - from the queue. Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. - Default is 0. --> - </queue> - <map name="default"> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>1</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>0</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>25</eviction-percentage> - </map> - <map name="L_ATTACH-Map"> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>1</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>LRU</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>1000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>5</eviction-percentage> - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.loading.service.buffer.L_ATTACHLoader</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>60000</write-delay-seconds> </map-store> --> - - - </map> - <map name="CTUM-Map"> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>1</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>LRU</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>1000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>5</eviction-percentage> - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>7200</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.loading.service.buffer.CTUMLoader</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>3600</write-delay-seconds> </map-store> --> - - </map> - <map name="L_HANDOVER-Map"> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>1</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>LRU</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>1000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>5</eviction-percentage> - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>3600</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.base.publishing.hazelcast.L_ATTACHStore</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>5</write-delay-seconds> </map-store> --> - - - </map> - - <map name="L_SERVICE_REQUEST-Map"> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>1</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>LRU</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>1000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>5</eviction-percentage> - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>7200</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.base.publishing.hazelcast.L_HandoverStore</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>5</write-delay-seconds> </map-store> --> - - - </map> - <map name="CommonCache"> - - - <!-- Number of async-backups. If 1 is set as the backup-count for example, - then all entries of the map will be copied to another JVM for fail-safety. - Valid numbers are 0 (no backup), 1, 2, 3. --> - <async-backup-count>1</async-backup-count> - - <!-- Can we read the local backup entries? Default value is false for strong - consistency. Being able to read backup data will give you greater performance. --> - <read-backup-data>true</read-backup-data> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>LRU</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>3000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>5</eviction-percentage> - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>7200</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.base.publishing.hazelcast.L_HandoverStore</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>5</write-delay-seconds> </map-store> --> - - - </map> - - - <map name="Topology-Map"> - - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>2</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>10000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>0</eviction-percentage> - - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.loading.service.buffer.TopologyCacheLoader</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>5</write-delay-seconds> </map-store> --> - - - - </map> - <map name="Protocol-cause-code-Map"> - <near-cache> - <!-- Maximum number of seconds for each entry to stay in the near cache. - Entries that are older than <time-to-live-seconds> will get automatically - evicted from the near cache. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - - <!-- Maximum number of seconds each entry can stay in the near cache as - untouched (not-read). Entries that are not read (touched) more than <max-idle-seconds> - value will get removed from the near cache. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-idle-seconds>0</max-idle-seconds> - - <!-- Valid values are: NONE (no extra eviction, <time-to-live-seconds> - may still apply), LRU (Least Recently Used), LFU (Least Frequently Used). - NONE is the default. Regardless of the eviction policy used, <time-to-live-seconds> - will still apply. --> - <eviction-policy>NONE</eviction-policy> - - <!-- Maximum size of the near cache. When max size is reached, cache is - evicted based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>2000</max-size> - - <!-- Should the cached entries get evicted if the entries are changed - (updated or removed). true of false. Default is true. --> - <invalidate-on-change>true</invalidate-on-change> - - </near-cache> - - - - </map> - <map name="SessionId_Map"> - - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>1</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>10000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>0</eviction-percentage> - - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>60</time-to-live-seconds> - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.loading.service.buffer.TopologyCacheLoader</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>5</write-delay-seconds> </map-store> --> - - - </map> - <map name="gpeh-reasons-Map"> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>2</backup-count> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>0</eviction-percentage> - <near-cache> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), - LFU (Least Frequently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>1000</max-size> - - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - </near-cache> - </map> - <map name="tac-imei-Map"> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>2</backup-count> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>0</eviction-percentage> - - <near-cache> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), - LFU (Least Frequently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>10000</max-size> - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - </near-cache> - </map> - - <map name="CORE-DATA-Map"> - - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>2</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>10000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>0</eviction-percentage> - - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.loading.service.buffer.TopologyCacheLoader</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>5</write-delay-seconds> </map-store> --> - - - - </map> - <map name="IMSI-APN-Map"> - - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>2</backup-count> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>10000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>0</eviction-percentage> - - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.loading.service.buffer.TopologyCacheLoader</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>5</write-delay-seconds> </map-store> --> - - - - </map> - <map name="CommonDataCache"> - - - <!-- Number of async-backups. If 1 is set as the backup-count for example, - then all entries of the map will be copied to another JVM for fail-safety. - Valid numbers are 0 (no backup), 1, 2, 3. --> - <async-backup-count>1</async-backup-count> - - <!-- Can we read the local backup entries? Default value is false for strong - consistency. Being able to read backup data will give you greater performance. --> - <read-backup-data>true</read-backup-data> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>LRU</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>3000000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>5</eviction-percentage> - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>7200</time-to-live-seconds> - - <!-- <map-store enabled="true"> Name of the class implementing MapLoader - and/or MapStore. The class should implement at least of these interfaces - and contain no-argument constructor. Note that the inner classes are not - supported. <class-name>com.ericsson.xstream.base.publishing.hazelcast.L_HandoverStore</class-name> - Number of seconds to delay to call the MapStore.store(key, value). If the - value is zero then it is write-through so MapStore.store(key, value) will - be called as soon as the entry is updated. Otherwise it is write-behind so - updates will be stored after write-delay-seconds value by calling Hazelcast.storeAll(map). - Default value is 0. <write-delay-seconds>5</write-delay-seconds> </map-store> --> - - - </map> - - - <queue name="raw-distributer-queue"> - <!-- Maximum size of the queue. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>100000</max-size> - </queue> - <map name="queue-map"> - - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>0</backup-count> - - </map> - - <map name="radio-correlation-config-Map"> - <backup-count>2</backup-count> - <eviction-policy>NONE</eviction-policy> - <max-size>50</max-size> - <eviction-percentage>0</eviction-percentage> - <time-to-live-seconds>0</time-to-live-seconds> - </map> - - <map name="xstream-configuration-map"> - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>0</backup-count> - <time-to-live-seconds>100000</time-to-live-seconds> - </map> - - <map name="TOPIC-TASK-MAP"> - - <async-backup-count>3</async-backup-count> - - <read-backup-data>true</read-backup-data> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>1000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>0</eviction-percentage> - - - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - </map> - <map name="TOPIC-REGISTRY"> - - <async-backup-count>3</async-backup-count> - - <read-backup-data>true</read-backup-data> - <!-- Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU - (Least Frequiently Used). NONE is the default. --> - <eviction-policy>NONE</eviction-policy> - <!-- Maximum size of the map. When max size is reached, map is evicted - based on the policy defined. Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>1000</max-size> - <!-- When max. size is reached, specified percentage of the map will be - evicted. Any integer between 0 and 100. If 25 is set for example, 25% of - the entries will get evicted. --> - <eviction-percentage>0</eviction-percentage> - - - - <!-- Maximum number of seconds for each entry to stay in the map. Entries - that are older than <time-to-live-seconds> and not updated for <time-to-live-seconds> - will get automatically evicted from the map. Any integer between 0 and Integer.MAX_VALUE. - 0 means infinite. Default is 0. --> - <time-to-live-seconds>0</time-to-live-seconds> - </map> - <queue name="Pooled-Topic-Request-Queue"> - <!-- Maximum size of the queue.Any integer between 0 and Integer.MAX_VALUE. - 0 means Integer.MAX_VALUE. Default is 0. --> - <max-size>100000</max-size> - </queue> - <map name="Pooled-Topic-Request-Queue-Backup-map"> - - <!-- Number of backups. If 1 is set as the backup-count for example, then - all entries of the map will be copied to another JVM for fail-safety. Valid - numbers are 0 (no backup), 1, 2, 3. --> - <backup-count>1</backup-count> - <eviction-policy>NONE</eviction-policy> - <time-to-live-seconds>0</time-to-live-seconds> - </map> - -</hazelcast> diff --git a/plugins/plugins-context/context-metrics/src/test/resources/infinispan/infinispan.xml b/plugins/plugins-context/context-metrics/src/test/resources/infinispan/infinispan.xml deleted file mode 100644 index a8541333e..000000000 --- a/plugins/plugins-context/context-metrics/src/test/resources/infinispan/infinispan.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2016-2018 Ericsson. All rights reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - SPDX-License-Identifier: Apache-2.0 - ============LICENSE_END========================================================= ---> - -<?xml version="1.0" encoding="UTF-8"?> - -<infinispan xmlns="urn:infinispan:config:8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:8.0 http://infinispan.org/schemas/infinispan-config-8.0.xsd"> - <jgroups> - <stack-file name="external-file" path="default-configs/default-jgroups-tcp.xml" /> - </jgroups> - - <cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1"> - <transport cluster="apexCluster" stack="external-file" /> - <jmx /> - <replicated-cache name="LargeContextMap_0.0.1" mode="SYNC" statistics="true"> - <state-transfer enabled="true" /> - </replicated-cache> - <replicated-cache name="LongSameTypeContextMap_0.0.1" mode="SYNC" statistics="true"> - <state-transfer enabled="true" /> - </replicated-cache> - <replicated-cache name="TestContext_0.0.1" mode="SYNC"> - <state-transfer enabled="true" /> - </replicated-cache> - </cache-container> -</infinispan> diff --git a/plugins/plugins-context/plugins-context-test/pom.xml b/plugins/plugins-context/plugins-context-test/pom.xml deleted file mode 100644 index 7239abe66..000000000 --- a/plugins/plugins-context/plugins-context-test/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2018 Ericsson. All rights reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - SPDX-License-Identifier: Apache-2.0 - ============LICENSE_END========================================================= ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId> - <artifactId>plugins-context</artifactId> - <version>2.0.0-SNAPSHOT</version> - </parent> - - <artifactId>plugins-context-test</artifactId> - <name>${project.artifactId}</name> - <description>[${project.parent.artifactId}] module to run context tests using various plugins</description> - - <dependencies> - <dependency> - <groupId>org.onap.policy.apex-pdp.core</groupId> - <artifactId>core-infrastructure</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-distribution</groupId> - <artifactId>context-distribution-hazelcast</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-distribution</groupId> - <artifactId>context-distribution-infinispan</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-locking</groupId> - <artifactId>context-locking-curator</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-locking</groupId> - <artifactId>context-locking-hazelcast</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.apex-pdp.context</groupId> - <artifactId>context-test</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.curator</groupId> - <artifactId>curator-test</artifactId> - <version>4.0.0</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <configuration> - <skip>true</skip> - <skipDeploy>true</skipDeploy> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <forkMode>always</forkMode> - </configuration> - </plugin> - </plugins> - </build> -</project>
\ No newline at end of file diff --git a/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/HazelcastContextInjection.java b/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/HazelcastContextInjection.java deleted file mode 100644 index 4c21103c3..000000000 --- a/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/HazelcastContextInjection.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.test; - -import java.util.Map.Entry; -import java.util.Random; - -import org.onap.policy.apex.context.ContextAlbum; -import org.onap.policy.apex.context.ContextException; -import org.onap.policy.apex.context.Distributor; -import org.onap.policy.apex.context.impl.distribution.DistributorFactory; -import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; -import org.onap.policy.apex.model.basicmodel.service.ModelService; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; - -/** - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public final class HazelcastContextInjection { - private static final int ONE_SECOND = 1000; - private static final int SIXTY_SECONDS = 60; - private static final int MAX_INT_10000 = 10000; - - /** - * Default constructor is private to avoid subclassing. - */ - private HazelcastContextInjection() {} - - /** - * The main method. - * - * @param args the arguments to the method - * @throws ContextException exceptions thrown on context injection - */ - public static void main(final String[] args) throws ContextException { - // For convenience, I created model programmatically, it can of course be read in from a - // policy model - final AxContextModel contextModel = createContextModel(); - - // The model must be registered in the model service. - ModelService.registerModel(AxContextSchemas.class, contextModel.getSchemas()); - ModelService.registerModel(AxContextAlbums.class, contextModel.getAlbums()); - - // Configure APex to use Hazelcast distribution and locking - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass("com.ericsson.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); - contextParameters.getLockManagerParameters() - .setPluginClass("com.ericsson.apex.plugins.context.locking.hazelcast.HazelcastLockManager"); - - // Fire up our distribution - final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1"); - final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey); - contextDistributor.init(distributorKey); - - // Now, get a handle on the album - final ContextAlbum myContextAlbum = - contextDistributor.createContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1")); - - final int jvmID = new Random().nextInt(MAX_INT_10000); - final String myLongKey = "MyLong_" + jvmID; - final String commonLongKey = "CommonLong"; - - // Put the long value for this JVM into the map - myContextAlbum.put(myLongKey, new Long(0L)); - - // Put the common long value to be used across JVMS in the map if its not htere already - myContextAlbum.lockForWriting(commonLongKey); - if (myContextAlbum.get(commonLongKey) == null) { - myContextAlbum.put(commonLongKey, new Long(0L)); - } - myContextAlbum.unlockForWriting(commonLongKey); - - // Run for 60 seconds to show multi JVM - for (int i = 0; i < SIXTY_SECONDS; i++) { - System.out.println("JVM " + jvmID + " iteration " + i); - - for (final Entry<String, Object> albumEntry : myContextAlbum.entrySet()) { - myContextAlbum.lockForReading(albumEntry.getKey()); - System.out.println(albumEntry.getKey() + "-->" + albumEntry.getValue()); - myContextAlbum.unlockForReading(albumEntry.getKey()); - } - System.out.println("old " + myLongKey + ": " + myContextAlbum.get(myLongKey)); - - myContextAlbum.lockForReading(commonLongKey); - System.out.println("old CommonLong: " + myContextAlbum.get(commonLongKey)); - myContextAlbum.unlockForReading(commonLongKey); - - Long myLong = (Long) myContextAlbum.get(myLongKey); - myLong++; - myContextAlbum.put(myLongKey, myLong); - - myContextAlbum.lockForWriting(commonLongKey); - Long commonLong = (Long) myContextAlbum.get(commonLongKey); - commonLong++; - myContextAlbum.put(commonLongKey, commonLong); - myContextAlbum.unlockForWriting(commonLongKey); - - System.out.println("new myLong: " + myContextAlbum.get(myLongKey)); - System.out.println("new commonLong: " + myContextAlbum.get(commonLongKey)); - - try { - Thread.sleep(ONE_SECOND); - } catch (final Exception e) { - e.printStackTrace(); - } - } - - contextDistributor.clear(); - } - - /** - * This method just creates a simple context model programatically. - * - * @return a context model - */ - public static AxContextModel createContextModel() { - final AxContextSchema longSchema = - new AxContextSchema(new AxArtifactKey("LongSchema", "0.0.1"), "Java", "java.lang.Long"); - - final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1")); - schemas.getSchemasMap().put(longSchema.getKey(), longSchema); - - final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1"), - "APPLICATION", true, longSchema.getKey()); - - final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1")); - albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition); - - final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1")); - final AxContextModel contextModel = - new AxContextModel(new AxArtifactKey("LongContextModel", "0.0.1"), schemas, albums, keyInformation); - contextModel.setKeyInformation(keyInformation); - keyInformation.generateKeyInfo(contextModel); - - return contextModel; - } -} diff --git a/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/package-info.java b/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/package-info.java deleted file mode 100644 index eab36189d..000000000 --- a/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -/** - * Is used to inject context into context maps for test purposes. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -package org.onap.policy.apex.plugins.context.test; diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextAlbumUpdate.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextAlbumUpdate.java deleted file mode 100644 index c24ef40e4..000000000 --- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextAlbumUpdate.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.test.distribution; - -import java.io.IOException; - -import org.junit.After; -import org.junit.Test; -import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.apex.context.parameters.DistributorParameters; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate; - -public class TestContextAlbumUpdate { - // Logger for this class - private static final XLogger logger = XLoggerFactory.getXLogger(TestContextAlbumUpdate.class); - - @Test - public void testContextAlbumUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextAlbumUpdateJVMLocalVarSet test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - new ContextAlbumUpdate().testContextAlbumUpdate(); - - logger.debug("Ran testContextAlbumUpdateJVMLocalVarSet test"); - } - - @Test - public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextAlbumUpdateHazelcast test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); - new ContextAlbumUpdate().testContextAlbumUpdate(); - - logger.debug("Ran testContextAlbumUpdateHazelcast test"); - } - - @Test - public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextAlbumUpdateInfinispan test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor"); - new InfinispanDistributorParameters(); - - new ContextAlbumUpdate().testContextAlbumUpdate(); - - logger.debug("Ran testContextAlbumUpdateInfinispan test"); - } - - @Test - public void testContextAlbumUpdateJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException { - logger.debug("Running testContextAlbumUpdateJVMLocalVarNotSet test . . ."); - - new ContextParameters(); - new ContextAlbumUpdate().testContextAlbumUpdate(); - - logger.debug("Ran testContextAlbumUpdateJVMLocalVarNotSet test"); - } - - /** - * Test context update cleardown. - */ - @After - public void testContextAlbumUpdateCleardown() {} -} diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestSequentialContextInstantiation.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestSequentialContextInstantiation.java deleted file mode 100644 index cc3f52015..000000000 --- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestSequentialContextInstantiation.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.test.distribution; - -import java.io.IOException; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.apex.context.parameters.DistributorParameters; -import org.onap.policy.apex.context.test.distribution.SequentialContextInstantiation; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The Class TestContextInstantiation. - * - * @author Sergey Sachkov (sergey.sachkov@ericsson.com) - */ -public class TestSequentialContextInstantiation { - // Logger for this class - private static final XLogger logger = XLoggerFactory.getXLogger(TestSequentialContextInstantiation.class); - - @Before - public void beforeTest() {} - - @After - public void afterTest() {} - - @Test - public void testSequentialContextInstantiationJVMLocalVarSet() - throws ApexModelException, IOException, ApexException { - logger.debug("Running testSequentialContextInstantiationJVMLocalVarSet test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - new SequentialContextInstantiation().testSequentialContextInstantiation(); - - logger.debug("Ran testSequentialContextInstantiationJVMLocalVarSet test"); - } - - @Test - public void testSequentialContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException { - logger.debug("Running testSequentialContextInstantiationHazelcast test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); - new SequentialContextInstantiation().testSequentialContextInstantiation(); - - logger.debug("Ran testSequentialContextInstantiationHazelcast test"); - } - - @Test - public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException { - logger.debug("Running testSequentialContextInstantiationInfinispan test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor"); - new InfinispanDistributorParameters(); - - new SequentialContextInstantiation().testSequentialContextInstantiation(); - - logger.debug("Ran testSequentialContextInstantiationInfinispan test"); - } - - @Test - public void testSequentialContextInstantiationJVMLocalVarNotSet() - throws ApexModelException, IOException, ApexException { - logger.debug("Running testSequentialContextInstantiationJVMLocalVarNotSet test . . ."); - - new ContextParameters(); - new SequentialContextInstantiation().testSequentialContextInstantiation(); - - logger.debug("Ran testSequentialContextInstantiationJVMLocalVarNotSet test"); - } -} diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/CuratorManagerTest.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/CuratorManagerTest.java deleted file mode 100644 index 0b9d60673..000000000 --- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/CuratorManagerTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.test.locking; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.io.IOException; - -import org.apache.curator.test.TestingServer; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.context.ContextException; -import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager; -import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManagerParameters; - -public class CuratorManagerTest { - // Zookeeper test server - TestingServer zkTestServer; - - @Before - public void beforeTest() throws Exception { - zkTestServer = new TestingServer(62181); - } - - @After - public void afterTest() throws IOException { - zkTestServer.stop(); - } - - @Test - public void testCuratorManagerConfigProperty() { - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.setLockManagerParameters(new CuratorLockManagerParameters()); - - ((CuratorLockManagerParameters) contextParameters.getLockManagerParameters()).setZookeeperAddress(null); - - try { - final CuratorLockManager curatorManager = new CuratorLockManager(); - curatorManager.init(new AxArtifactKey()); - assertNull(curatorManager); - } catch (final ContextException e) { - assertEquals(e.getMessage(), - "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly"); - } - - ((CuratorLockManagerParameters) contextParameters.getLockManagerParameters()).setZookeeperAddress("zooby"); - - try { - final CuratorLockManager curatorManager = new CuratorLockManager(); - curatorManager.init(new AxArtifactKey()); - fail("Curator manager test should fail"); - } catch (final ContextException e) { - assertEquals(e.getMessage(), - "could not connect to Zookeeper server at \"zooby\", see error log for details"); - } - - ((CuratorLockManagerParameters) contextParameters.getLockManagerParameters()) - .setZookeeperAddress("localhost:62181"); - - try { - final CuratorLockManager curatorManager0 = new CuratorLockManager(); - curatorManager0.init(new AxArtifactKey()); - assertNotNull(curatorManager0); - - final CuratorLockManager curatorManager1 = new CuratorLockManager(); - curatorManager1.init(new AxArtifactKey()); - assertNotNull(curatorManager1); - - curatorManager0.shutdown(); - curatorManager1.shutdown(); - } catch (final ContextException e) { - assertNull(e); - } - } -} diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java deleted file mode 100644 index e02009a55..000000000 --- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java +++ /dev/null @@ -1,313 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.context.test.locking; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.NetworkInterface; -import java.util.Collections; -import java.util.Enumeration; -import java.util.TreeSet; - -import org.apache.curator.shaded.com.google.common.io.Files; -import org.apache.zookeeper.server.NIOServerCnxnFactory; -import org.apache.zookeeper.server.ZooKeeperServer; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.apex.context.parameters.DistributorParameters; -import org.onap.policy.apex.context.parameters.LockManagerParameters; -import org.onap.policy.apex.context.test.locking.ConcurrentContext; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.model.basicmodel.service.ParameterService; -import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters; -import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManagerParameters; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -import com.hazelcast.config.Config; - -/** - * The Class TestConcurrentContext tests concurrent use of context. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class TestConcurrentContext { - // Logger for this class - private static final XLogger logger = XLoggerFactory.getXLogger(TestConcurrentContext.class); - - // Test parameters - private static final int ZOOKEEPER_START_PORT = 62181; - private static final int TEST_JVM_COUNT_SINGLE_JVM = 1; - private static final int TEST_JVM_COUNT_MULTI_JVM = 3; - private static final int TEST_THREAD_COUNT_SINGLE_JVM = 64; - private static final int TEST_THREAD_COUNT_MULTI_JVM = 20; - private static final int TEST_THREAD_LOOPS = 100; - - private NIOServerCnxnFactory zookeeperFactory; - - // We need to increment the Zookeeper port because sometimes the port is not released at the end - // of the test for a few seconds. - private static int nextZookeeperPort = ZOOKEEPER_START_PORT; - private int zookeeperPort; - - @BeforeClass - public static void configure() throws Exception { - System.setProperty("java.net.preferIPv4Stack", "true"); - System.setProperty("hazelcast.config", "src/test/resources/hazelcast/hazelcast.xml"); - - // The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to - // work. IN order to ensure that all - // the JVMs in a test pick up the same IP address, this function sets the address to be the - // first non-loopback IPv4 address - // on a host - final TreeSet<String> ipAddressSet = new TreeSet<String>(); - - final Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); - for (final NetworkInterface netint : Collections.list(nets)) { - final Enumeration<InetAddress> inetAddresses = netint.getInetAddresses(); - for (final InetAddress inetAddress : Collections.list(inetAddresses)) { - // Look for real IPv4 internet addresses - if (!inetAddress.isLoopbackAddress() && inetAddress.getAddress().length == 4) { - ipAddressSet.add(inetAddress.getHostAddress()); - } - } - } - - if (ipAddressSet.size() == 0) { - throw new Exception("cound not find real IP address for test"); - } - System.out.println("For Infinispan, setting jgroups.tcp.address to: " + ipAddressSet.first()); - System.setProperty("jgroups.tcp.address", ipAddressSet.first()); - - final Config config = new Config(); - config.getNetworkConfig().setPublicAddress(ipAddressSet.first()); - config.getNetworkConfig().getInterfaces().addInterface(ipAddressSet.first()); - } - - @AfterClass - public static void teardown() throws IOException {} - - private void startZookeeperServer() throws IOException, InterruptedException { - final File zookeeperDirectory = Files.createTempDir(); - - zookeeperPort = nextZookeeperPort++; - - final ZooKeeperServer server = new ZooKeeperServer(zookeeperDirectory, zookeeperDirectory, 5000); - zookeeperFactory = new NIOServerCnxnFactory(); - zookeeperFactory.configure(new InetSocketAddress(zookeeperPort), 100); - - zookeeperFactory.startup(server); - } - - private void stopZookeeperServer() { - zookeeperFactory.shutdown(); - } - - @Test - public void testConcurrentContextJVMLocalVarSet() throws ApexModelException, IOException, ApexException { - logger.debug("Running testConcurrentContextJVMLocalVarSet test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager"); - final long result = new ConcurrentContext().testConcurrentContext("JVMLocalVarSet", TEST_JVM_COUNT_SINGLE_JVM, - TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS); - - assertEquals(TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS, result); - - logger.debug("Ran testConcurrentContextJVMLocalVarSet test"); - } - - @Test - public void testConcurrentContextJVMLocalNoVarSet() throws ApexModelException, IOException, ApexException { - logger.debug("Running testConcurrentContextJVMLocalNoVarSet test . . ."); - - new ContextParameters(); - final long result = new ConcurrentContext().testConcurrentContext("JVMLocalNoVarSet", TEST_JVM_COUNT_SINGLE_JVM, - TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS); - - assertEquals(TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS, result); - - logger.debug("Ran testConcurrentContextJVMLocalNoVarSet test"); - } - - @Test - public void testConcurrentContextMultiJVMNoLock() throws ApexModelException, IOException, ApexException { - logger.debug("Running testConcurrentContextMultiJVMNoLock test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor"); - contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager"); - - final long result = new ConcurrentContext().testConcurrentContext("testConcurrentContextMultiJVMNoLock", - TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS); - - // No concurrent map so result will be zero - assertEquals(0, result); - - logger.debug("Ran testConcurrentContextMultiJVMNoLock test"); - } - - @Test - public void testConcurrentContextHazelcastLock() throws ApexModelException, IOException, ApexException { - logger.debug("Running testConcurrentContextHazelcastLock test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager"); - final long result = new ConcurrentContext().testConcurrentContext("HazelcastLock", TEST_JVM_COUNT_SINGLE_JVM, - TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS); - - assertEquals(TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS, result); - logger.debug("Ran testConcurrentContextHazelcastLock test"); - } - - @Test - public void testConcurrentContextCuratorLock() - throws ApexModelException, IOException, ApexException, InterruptedException { - logger.debug("Running testConcurrentContextCuratorLock test . . ."); - - startZookeeperServer(); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters() - .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS); - - final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters(); - curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager"); - curatorParameters.setZookeeperAddress("127.0.0.1:" + zookeeperPort); - contextParameters.setLockManagerParameters(curatorParameters); - ParameterService.registerParameters(LockManagerParameters.class, curatorParameters); - - final long result = new ConcurrentContext().testConcurrentContext("CuratorLock", TEST_JVM_COUNT_SINGLE_JVM, - TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS); - - assertEquals(TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS, result); - - stopZookeeperServer(); - logger.debug("Ran testConcurrentContextCuratorLock test"); - } - - @Test - public void testConcurrentContextHazelcastMultiJVMHazelcastLock() - throws ApexModelException, IOException, ApexException { - logger.debug("Running testConcurrentContextHazelcastMultiJVMHazelcastLock test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); - contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager"); - final long result = new ConcurrentContext().testConcurrentContext("HazelcastMultiHazelcastlock", - TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS); - - assertEquals(TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS, result); - logger.debug("Ran testConcurrentContextHazelcastMultiJVMHazelcastLock test"); - } - - @Test - public void testConcurrentContextInfinispanMultiJVMHazelcastlock() - throws ApexModelException, IOException, ApexException { - logger.debug("Running testConcurrentContextInfinispanMultiJVMHazelcastlock test . . ."); - - final ContextParameters contextParameters = new ContextParameters(); - final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters(); - infinispanParameters.setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor"); - infinispanParameters.setConfigFile("infinispan/infinispan-context-test.xml"); - contextParameters.setDistributorParameters(infinispanParameters); - contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager"); - - final long result = new ConcurrentContext().testConcurrentContext("InfinispanMultiHazelcastlock", - TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS); - - assertEquals(TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS, result); - logger.debug("Ran testConcurrentContextInfinispanMultiJVMHazelcastlock test"); - } - - @Test - public void testConcurrentContextInfinispanMultiJVMCuratorLock() - throws ApexModelException, IOException, ApexException, InterruptedException { - logger.debug("Running testConcurrentContextInfinispanMultiJVMCuratorLock test . . ."); - - startZookeeperServer(); - - final ContextParameters contextParameters = new ContextParameters(); - final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters(); - infinispanParameters.setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor"); - infinispanParameters.setConfigFile("infinispan/infinispan-context-test.xml"); - contextParameters.setDistributorParameters(infinispanParameters); - - final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters(); - curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager"); - curatorParameters.setZookeeperAddress("127.0.0.1:" + zookeeperPort); - contextParameters.setLockManagerParameters(curatorParameters); - ParameterService.registerParameters(LockManagerParameters.class, curatorParameters); - - final long result = new ConcurrentContext().testConcurrentContext("InfinispanMultiCuratorLock", - TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS); - - assertEquals(TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS, result); - - stopZookeeperServer(); - - logger.debug("Ran testConcurrentContextInfinispanMultiJVMCuratorLock test"); - } - - @Test - public void testConcurrentContextHazelcastMultiJVMCuratorLock() - throws ApexModelException, IOException, ApexException, InterruptedException { - logger.debug("Running testConcurrentContextHazelcastMultiJVMCuratorLock test . . ."); - - startZookeeperServer(); - - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.getDistributorParameters().setPluginClass( - "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor"); - - final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters(); - curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager"); - curatorParameters.setZookeeperAddress("127.0.0.1:" + zookeeperPort); - contextParameters.setLockManagerParameters(curatorParameters); - ParameterService.registerParameters(LockManagerParameters.class, curatorParameters); - - final long result = new ConcurrentContext().testConcurrentContext("HazelcastMultiCuratorLock", - TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS); - - assertEquals(TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS, result); - - stopZookeeperServer(); - logger.debug("Ran testConcurrentContextHazelcastMultiJVMCuratorLock test"); - } -} diff --git a/plugins/plugins-context/pom.xml b/plugins/plugins-context/pom.xml index 7be78433f..8e3c72870 100644 --- a/plugins/plugins-context/pom.xml +++ b/plugins/plugins-context/pom.xml @@ -41,64 +41,11 @@ </dependency> </dependencies> - <profiles> - <profile> - <id>apexDefault</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - <modules> - <module>context-schema</module> - <module>context-distribution</module> - <module>context-locking</module> - <module>context-persistence</module> - </modules> - </profile> - <profile> - <id>apexTests</id> - <activation> - <property> - <name>apexTests</name> - </property> - </activation> - <modules> - <module>context-schema</module> - <module>context-distribution</module> - <module>context-locking</module> - <module>context-persistence</module> - <module>plugins-context-test</module> - </modules> - </profile> - <profile> - <id>apexMetrics</id> - <activation> - <property> - <name>apexMetrics</name> - </property> - </activation> - <modules> - <module>context-schema</module> - <module>context-distribution</module> - <module>context-locking</module> - <module>context-persistence</module> - <module>context-metrics</module> - </modules> - </profile> - <profile> - <id>apexAll</id> - <activation> - <property> - <name>apexAll</name> - </property> - </activation> - <modules> - <module>context-schema</module> - <module>context-distribution</module> - <module>context-locking</module> - <module>context-persistence</module> - <module>plugins-context-test</module> - <module>context-metrics</module> - </modules> - </profile> - </profiles> + <modules> + <module>context-schema</module> + <module>context-distribution</module> + <module>context-locking</module> + <module>context-persistence</module> + </modules> + </project>
\ No newline at end of file |