aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestParameters.java3
-rw-r--r--client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java329
-rw-r--r--client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestParameters.java3
-rw-r--r--context/context-test-utils/pom.xml11
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java4
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java4
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java29
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java77
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/NoLockAlbumModifier.java45
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/ReadLockAlbumModifier.java60
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/SingleValueWriteLockAlbumModifier.java65
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/WriteLockAlbumModifier.java63
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java131
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java133
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java36
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java89
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProvider.java63
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java166
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java9
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java58
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java63
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java71
-rw-r--r--core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java25
-rw-r--r--testsuites/integration/integration-context-test/pom.xml14
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java312
-rw-r--r--testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml7
-rw-r--r--testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java433
-rw-r--r--testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java212
-rw-r--r--testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java187
-rw-r--r--testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java170
-rw-r--r--testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java55
-rw-r--r--testsuites/performance/performance-context-metrics/src/test/resources/hazelcast/hazelcast.xml656
-rw-r--r--testsuites/performance/performance-context-metrics/src/test/resources/infinispan/default-jgroups-tcp.xml76
-rw-r--r--testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml2
35 files changed, 1534 insertions, 2135 deletions
diff --git a/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestParameters.java b/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestParameters.java
index 6151506b8..952492f53 100644
--- a/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestParameters.java
+++ b/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestParameters.java
@@ -37,8 +37,7 @@ public class ApexDeploymentRestParameters {
private static final String DEFAULT_STATIC_PATH = "/";
// Package that will field REST requests
- public static final String[] DEFAULT_PACKAGES =
- new String[] { "com.ericsson.apex.services.client.deployment.rest" };
+ private static final String[] DEFAULT_PACKAGES = new String[] {"org.onap.policy.apex.client.deployment.rest"};
// The services parameters
private boolean helpSet = false;
diff --git a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java
index 08b869256..09b34ebe4 100644
--- a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java
+++ b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java
@@ -72,30 +72,33 @@ import org.slf4j.ext.XLoggerFactory;
/**
* The class represents the root resource exposed at the base URL<br>
* The url to access this resource would be in the form {@code <baseURL>/rest/<session>/....} <br>
- * For example: a PUT request to the following URL {@code http://localhost:8080/apex/rest/109/ContextSchema/Update},
- * with a JSON string payload containing the new {@code Schema} in the body, can be explained as:
+ * For example: a PUT request to the following URL
+ * {@code http://localhost:8080/apex/rest/109/ContextSchema/Update}, with a JSON string payload
+ * containing the new {@code Schema} in the body, can be explained as:
* <ul>
* <li>The server or servlet is running at the base URL {@code http://localhost:8080/apex}
- * <li>This resource {@code ApexRestEditorResource} is used because the path {@code rest/109} matches the {@code Path}
- * filter specification for this Resource ({@code @Path("rest/{session}")}), where the {@code int} path parameter
- * {@code session} is assigned the {@code int} value {@code 109}
- * <li>The path {@code ContextSchema/Update} redirects this call to the method {@link #updateContextSchema(String)},
- * which should be a {@link javax.ws.rs.PUT}, with a single String in the body/payload which gets mapped to the single
- * String parameter for the method.
- * <li>So, in summary, the REST request updates a {@code ContextSchema} as specified in the payload for {@code session}
- * number {@code 109}
+ * <li>This resource {@code ApexRestEditorResource} is used because the path {@code rest/109}
+ * matches the {@code Path} filter specification for this Resource
+ * ({@code @Path("rest/{session}")}), where the {@code int} path parameter {@code session} is
+ * assigned the {@code int} value {@code 109}
+ * <li>The path {@code ContextSchema/Update} redirects this call to the method
+ * {@link #updateContextSchema(String)}, which should be a {@link javax.ws.rs.PUT}, with a single
+ * String in the body/payload which gets mapped to the single String parameter for the method.
+ * <li>So, in summary, the REST request updates a {@code ContextSchema} as specified in the payload
+ * for {@code session} number {@code 109}
* </ul>
*
- * <b>Note:</b> An allocated {@code Session} identifier must be included in (almost) all requests. Models for different
- * {@code Session} identifiers are completely isolated from one another.
+ * <b>Note:</b> An allocated {@code Session} identifier must be included in (almost) all requests.
+ * Models for different {@code Session} identifiers are completely isolated from one another.
*
- * <b>Note:</b> To create a new {@code Session}, and have a new session ID allocated use {@link javax.ws.rs.GET} request
- * to {@code <baseURL>/rest/-1/Session/Create} (for example: {@code http://localhost:8080/apex/rest/-1/Session/Create} )
+ * <b>Note:</b> To create a new {@code Session}, and have a new session ID allocated use
+ * {@link javax.ws.rs.GET} request to {@code <baseURL>/rest/-1/Session/Create} (for example:
+ * {@code http://localhost:8080/apex/rest/-1/Session/Create} )
*
*/
@Path("editor/{session}")
-@Produces({ MediaType.APPLICATION_JSON })
-@Consumes({ MediaType.APPLICATION_JSON })
+@Produces({MediaType.APPLICATION_JSON})
+@Consumes({MediaType.APPLICATION_JSON})
public class ApexEditorRestResource {
// Get a reference to the logger
@@ -115,8 +118,8 @@ public class ApexEditorRestResource {
private ApexModel sessionApexModel = null;
/**
- * This method sets the Apex model for the current editor session. Don't forget to call {@link #commitChanges()}
- * when finished! This makes requests atomic.
+ * This method sets the Apex model for the current editor session. Don't forget to call
+ * {@link #commitChanges()} when finished! This makes requests atomic.
*
* @return the result of finding the session Apex model and setting it
*/
@@ -136,7 +139,8 @@ public class ApexEditorRestResource {
}
/**
- * This method sets the Apex model for the current editor session. Don't make any changes to the model.
+ * This method sets the Apex model for the current editor session. Don't make any changes to the
+ * model.
*
* @return the result of finding the session Apex model and setting it
*/
@@ -156,8 +160,8 @@ public class ApexEditorRestResource {
}
/**
- * This method commits changes to the Apex model for the current editor session. This should only be called once, at
- * the end of a successful change to the model for this session
+ * This method commits changes to the Apex model for the current editor session. This should
+ * only be called once, at the end of a successful change to the model for this session
*
* @return the result of committing the session Apex model
*/
@@ -174,12 +178,13 @@ public class ApexEditorRestResource {
}
/**
- * Creates a new session. Always call this method with sessionID -1, whereby a new sessionID will be allocated. If
- * successful the new sessionID will be available in the first message in the result.
+ * Creates a new session. Always call this method with sessionID -1, whereby a new sessionID
+ * will be allocated. If successful the new sessionID will be available in the first message in
+ * the result.
*
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}. This includes the session id
- * for this session.
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}.
+ * This includes the session id for this session.
*/
@GET
@Path("Session/Create")
@@ -216,10 +221,10 @@ public class ApexEditorRestResource {
/**
* Load the model from a JSON string for this session.
*
- * @param jsonString the JSON string to be parsed. The returned value(s) will be similar to {@link AxPolicyModel},
- * with merged {@linkplain AxKeyInfo} for the root object.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @param jsonString the JSON string to be parsed. The returned value(s) will be similar to
+ * {@link AxPolicyModel}, with merged {@linkplain AxKeyInfo} for the root object.
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@PUT
@Path("/Model/Load")
@@ -247,11 +252,11 @@ public class ApexEditorRestResource {
}
/**
- * Analyse the model and return analysis results. If successful the analysis results will be available in the
- * messages in the result.
+ * Analyse the model and return analysis results. If successful the analysis results will be
+ * available in the messages in the result.
*
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Model/Analyse")
@@ -276,11 +281,11 @@ public class ApexEditorRestResource {
}
/**
- * Validate the model and return validation results. If successful the validation results will be available in the
- * messages in the result.
+ * Validate the model and return validation results. If successful the validation results will
+ * be available in the messages in the result.
*
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Model/Validate")
@@ -309,9 +314,10 @@ public class ApexEditorRestResource {
/**
* Creates the new model model for this session.
*
- * @param jsonString the JSON string to be parsed containing the new model. See {@linkplain BeanModel}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @param jsonString the JSON string to be parsed containing the new model. See
+ * {@linkplain BeanModel}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@POST
@Path("Model/Create")
@@ -347,9 +353,10 @@ public class ApexEditorRestResource {
/**
* Update the model for this session.
*
- * @param jsonString the JSON string to be parsed containing the updated model. See {@linkplain BeanModel}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @param jsonString the JSON string to be parsed containing the updated model. See
+ * {@linkplain BeanModel}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@PUT
@Path("Model/Update")
@@ -379,11 +386,11 @@ public class ApexEditorRestResource {
}
/**
- * Gets the key for the model for this session. If successful the model key will be available in the first message
- * in the result. See {@linkplain AxKey}
+ * Gets the key for the model for this session. If successful the model key will be available in
+ * the first message in the result. See {@linkplain AxKey}
*
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Model/GetKey")
@@ -408,12 +415,12 @@ public class ApexEditorRestResource {
}
/**
- * Retrieve the model for this session. If successful the model will be available in the first message in the
- * result. The returned value will be similar to a {@link AxPolicyModel}, with merged {@linkplain AxKeyInfo} for the
- * root object.
+ * Retrieve the model for this session. If successful the model will be available in the first
+ * message in the result. The returned value will be similar to a {@link AxPolicyModel}, with
+ * merged {@linkplain AxKeyInfo} for the root object.
*
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Model/Get")
@@ -469,7 +476,9 @@ public class ApexEditorRestResource {
LOGGER.catching(e);
throw e;
} finally {
- LOGGER.exit(ret.isOK());
+ if (ret != null) {
+ LOGGER.exit(ret.isOK());
+ }
LOGGER.info("Model/Download" + (ret != null && ret.isOK() ? ": OK" : ": Not OK"));
}
}
@@ -477,8 +486,8 @@ public class ApexEditorRestResource {
/**
* Delete the model for this session.
*
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@DELETE
@Path("Model/Delete")
@@ -506,13 +515,13 @@ public class ApexEditorRestResource {
}
/**
- * List key information with the given key names/versions. If successful the result(s) will be available in the
- * result messages. See {@linkplain AxKeyInfo}
+ * List key information with the given key names/versions. If successful the result(s) will be
+ * available in the result messages. See {@linkplain AxKeyInfo}
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("KeyInformation/Get")
@@ -550,8 +559,8 @@ public class ApexEditorRestResource {
* Creates a context schema with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed. See {@linkplain BeanContextSchema}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@POST
@Path("ContextSchema/Create")
@@ -585,8 +594,8 @@ public class ApexEditorRestResource {
* Update a context schema with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed. See {@linkplain BeanContextSchema}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@PUT
@Path("ContextSchema/Update")
@@ -618,14 +627,14 @@ public class ApexEditorRestResource {
}
/**
- * List context schemas with the given key names/versions. If successful the result(s) will be available in the
- * result messages. The returned value(s) will be similar to {@link AxContextSchema}, with merged
- * {@linkplain AxKeyInfo} for the root object.
+ * List context schemas with the given key names/versions. If successful the result(s) will be
+ * available in the result messages. The returned value(s) will be similar to
+ * {@link AxContextSchema}, with merged {@linkplain AxKeyInfo} for the root object.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("ContextSchema/Get")
@@ -669,8 +678,8 @@ public class ApexEditorRestResource {
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@DELETE
@Path("ContextSchema/Delete")
@@ -708,13 +717,13 @@ public class ApexEditorRestResource {
}
/**
- * Validate context schemas with the given key names/versions. The result(s) will be available in the result
- * messages.
+ * Validate context schemas with the given key names/versions. The result(s) will be available
+ * in the result messages.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Validate/ContextSchema")
@@ -757,8 +766,8 @@ public class ApexEditorRestResource {
* Creates a context album with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed. See {@linkplain BeanContextAlbum}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@POST
@Path("ContextAlbum/Create")
@@ -793,8 +802,8 @@ public class ApexEditorRestResource {
* Update a context album with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed. See {@linkplain BeanContextAlbum}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@PUT
@Path("ContextAlbum/Update")
@@ -826,14 +835,14 @@ public class ApexEditorRestResource {
}
/**
- * List context albums with the given key names/versions. If successful the result(s) will be available in the
- * result messages. The returned value(s) will be similar to {@link AxContextAlbum}, with merged
- * {@linkplain AxKeyInfo} for the root object.
+ * List context albums with the given key names/versions. If successful the result(s) will be
+ * available in the result messages. The returned value(s) will be similar to
+ * {@link AxContextAlbum}, with merged {@linkplain AxKeyInfo} for the root object.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("ContextAlbum/Get")
@@ -877,8 +886,8 @@ public class ApexEditorRestResource {
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@DELETE
@Path("ContextAlbum/Delete")
@@ -916,13 +925,13 @@ public class ApexEditorRestResource {
}
/**
- * Validate context albums with the given key names/versions. The result(s) will be available in the result
- * messages.
+ * Validate context albums with the given key names/versions. The result(s) will be available in
+ * the result messages.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Validate/ContextAlbum")
@@ -965,8 +974,8 @@ public class ApexEditorRestResource {
* Creates an event with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed. See {@linkplain BeanEvent}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@POST
@Path("Event/Create")
@@ -1023,8 +1032,8 @@ public class ApexEditorRestResource {
* Update an event with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed. See {@linkplain BeanEvent}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@PUT
@Path("Event/Update")
@@ -1066,14 +1075,14 @@ public class ApexEditorRestResource {
}
/**
- * List events with the given key names/versions. If successful the result(s) will be available in the result
- * messages. The returned value(s) will be similar to {@link AxEvent}, with merged {@linkplain AxKeyInfo} for the
- * root object.
+ * List events with the given key names/versions. If successful the result(s) will be available
+ * in the result messages. The returned value(s) will be similar to {@link AxEvent}, with merged
+ * {@linkplain AxKeyInfo} for the root object.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Event/Get")
@@ -1116,8 +1125,8 @@ public class ApexEditorRestResource {
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@DELETE
@Path("Event/Delete")
@@ -1155,12 +1164,13 @@ public class ApexEditorRestResource {
}
/**
- * Validate events with the given key names/versions. The result(s) will be available in the result messages.
+ * Validate events with the given key names/versions. The result(s) will be available in the
+ * result messages.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Validate/Event")
@@ -1203,8 +1213,8 @@ public class ApexEditorRestResource {
* Creates a task with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed. See {@linkplain BeanTask}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@POST
@Path("Task/Create")
@@ -1353,8 +1363,8 @@ public class ApexEditorRestResource {
* Update a task with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed. See {@linkplain BeanTask}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@PUT
@Path("Task/Update")
@@ -1396,14 +1406,14 @@ public class ApexEditorRestResource {
}
/**
- * List tasks with the given key names/versions. If successful the result(s) will be available in the result
- * messages. The returned value(s) will be similar to {@link AxTask}, with merged {@linkplain AxKeyInfo} for the
- * root object.
+ * List tasks with the given key names/versions. If successful the result(s) will be available
+ * in the result messages. The returned value(s) will be similar to {@link AxTask}, with merged
+ * {@linkplain AxKeyInfo} for the root object.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Task/Get")
@@ -1446,8 +1456,8 @@ public class ApexEditorRestResource {
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@DELETE
@Path("Task/Delete")
@@ -1470,7 +1480,8 @@ public class ApexEditorRestResource {
version1 = null;
}
- // all input/output fields, parameters, logic, context references is "owned"/contained in the task, so
+ // all input/output fields, parameters, logic, context references is "owned"/contained
+ // in the task, so
// deleting the task removes all of these
ret = sessionApexModel.deleteTask(name1, version1);
if (ret.isOK()) {
@@ -1487,12 +1498,13 @@ public class ApexEditorRestResource {
}
/**
- * Validate tasks with the given key names/versions. The result(s) will be available in the result messages.
+ * Validate tasks with the given key names/versions. The result(s) will be available in the
+ * result messages.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Validate/Task")
@@ -1536,8 +1548,8 @@ public class ApexEditorRestResource {
* Creates a policy with the information in the JSON string passed.
*
* @param jsonString the JSON string to be parsed See {@linkplain BeanPolicy}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@POST
@Path("Policy/Create")
@@ -1623,10 +1635,11 @@ public class ApexEditorRestResource {
if (contexts != null) {
for (final BeanKeyRef c : contexts) {
if (c == null) {
- ret = new ApexAPIResult(RESULT.FAILED, "Null or invalid context reference \"" + c + "\" for"
- + " state \"" + statename + "\" for policy \"" + policyname + ":" + policyversion
- + "\". The policy was created, but there was an error adding the context reference for the state."
- + " The policy has only been partially defined.");
+ ret = new ApexAPIResult(RESULT.FAILED,
+ "Null or invalid context reference \"" + c + "\" for" + " state \"" + statename
+ + "\" for policy \"" + policyname + ":" + policyversion
+ + "\". The policy was created, but there was an error adding the context reference for the state."
+ + " The policy has only been partially defined.");
return ret;
}
tempres = sessionApexModel.createPolicyStateContextRef(policyname, policyversion, statename,
@@ -1671,21 +1684,22 @@ public class ApexEditorRestResource {
}
final Map<String, BeanStateOutput> outputs = state.getStateOutputs();
if (outputs == null || outputs.isEmpty()) {
- ret = new ApexAPIResult(RESULT.FAILED, "No state outputs have been defined in state \"" + statename
- + "\" for policy \"" + policyname + ":" + policyversion
- + "\". The policy and state were created, but there was an error adding state outputs."
- + " The policy has only been partially defined.");
+ ret = new ApexAPIResult(RESULT.FAILED,
+ "No state outputs have been defined in state \"" + statename + "\" for policy \""
+ + policyname + ":" + policyversion
+ + "\". The policy and state were created, but there was an error adding state outputs."
+ + " The policy has only been partially defined.");
return ret;
}
for (final Map.Entry<String, BeanStateOutput> o : outputs.entrySet()) {
final String outputname = o.getKey();
final BeanStateOutput output = o.getValue();
if (outputname == null || output == null || output.getEvent() == null) {
- ret = new ApexAPIResult(RESULT.FAILED, "Null or invalid output information for output named \""
- + outputname + "\" in state \"" + statename + "\" for policy \"" + policyname + ":"
- + policyversion
- + "\". The policy and state were created, but there was an error adding the output."
- + " The policy has only been partially defined.");
+ ret = new ApexAPIResult(RESULT.FAILED,
+ "Null or invalid output information for output named \"" + outputname + "\" in state \""
+ + statename + "\" for policy \"" + policyname + ":" + policyversion
+ + "\". The policy and state were created, but there was an error adding the output."
+ + " The policy has only been partially defined.");
return ret;
}
tempres = sessionApexModel.createPolicyStateOutput(policyname, policyversion, statename, outputname,
@@ -1713,11 +1727,11 @@ public class ApexEditorRestResource {
final String tasklocalname = t.getKey();
final BeanStateTaskRef taskref = t.getValue();
if (tasklocalname == null || taskref == null || taskref.getTask() == null) {
- ret = new ApexAPIResult(RESULT.FAILED, "Null or invalid task information for task named \""
- + tasklocalname + "\" in state \"" + statename + "\" for for policy \"" + policyname
- + ":" + policyversion
- + "\". The policy and state were created, but there was an error adding the task. "
- + "The policy has only been partially defined.");
+ ret = new ApexAPIResult(RESULT.FAILED,
+ "Null or invalid task information for task named \"" + tasklocalname + "\" in state \""
+ + statename + "\" for for policy \"" + policyname + ":" + policyversion
+ + "\". The policy and state were created, but there was an error adding the task. "
+ + "The policy has only been partially defined.");
return ret;
}
tempres = sessionApexModel.createPolicyStateTaskRef(policyname, policyversion, statename,
@@ -1753,8 +1767,8 @@ public class ApexEditorRestResource {
*
* @param firstStatePeriodic indicates if periodic event should be created and added to model
* @param jsonString the JSON string to be parsed. See {@linkplain BeanPolicy}
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@PUT
@Path("Policy/Update")
@@ -1807,14 +1821,14 @@ public class ApexEditorRestResource {
}
/**
- * List policies with the given key names/versions. If successful the result(s) will be available in the result
- * messages. The returned value(s) will be similar to {@link AxPolicy}, with merged {@linkplain AxKey Info} for the
- * root object.
+ * List policies with the given key names/versions. If successful the result(s) will be
+ * available in the result messages. The returned value(s) will be similar to {@link AxPolicy},
+ * with merged {@linkplain AxKey Info} for the root object.
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@GET
@Path("Policy/Get")
@@ -1859,8 +1873,8 @@ public class ApexEditorRestResource {
*
* @param name the name to search for. If null or empty, then all names will be queried
* @param version the version to search for. If null then all versions will be searched for.
- * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return true. Any
- * messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
+ * @return an ApexAPIResult object. If successful then {@link ApexAPIResult#isOK()} will return
+ * true. Any messages/errors can be retrieved using {@link ApexAPIResult#getMessages()}
*/
@DELETE
@Path("Policy/Delete")
@@ -1883,7 +1897,8 @@ public class ApexEditorRestResource {
version1 = null;
}
- // all input/output fields, parameters, logic, context references is "owned"/contained in the task, so
+ // all input/output fields, parameters, logic, context references is "owned"/contained
+ // in the task, so
// deleting the task removes all of these
ret = sessionApexModel.deletePolicy(name1, version1);
if (ret.isOK()) {
@@ -1900,12 +1915,14 @@ public class ApexEditorRestResource {
}
/**
- * The json strings representing the objects listed, stored in result.messages[], does not contain the
- * AxKeyInformation for that object. This utility method retrieves the AxKeyInfo for each object and adds it to the
- * json for the object.
+ * The json strings representing the objects listed, stored in result.messages[], does not
+ * contain the AxKeyInformation for that object. This utility method retrieves the AxKeyInfo for
+ * each object and adds it to the json for the object.
*
- * @param result The list result, containing json representations of objects stored in its "messages" array
- * @return The list result, containing json augmented representations of objects stored in its "messages" array
+ * @param result The list result, containing json representations of objects stored in its
+ * "messages" array
+ * @return The list result, containing json augmented representations of objects stored in its
+ * "messages" array
*/
private ApexAPIResult addKeyInfo2Messages(final ApexAPIResult result) {
if (result.isNOK()) {
@@ -2004,8 +2021,8 @@ public class ApexEditorRestResource {
}
/*
- * This method is used only for testing and is used to cause an exception on calls from unit test to test exception
- * handling.
+ * This method is used only for testing and is used to cause an exception on calls from unit
+ * test to test exception handling.
*/
protected static int createCorruptSession() {
final ApexEditorRestResource apexEditorRestResource = new ApexEditorRestResource();
diff --git a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestParameters.java b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestParameters.java
index a1a8efc57..cb6d76fab 100644
--- a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestParameters.java
+++ b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestParameters.java
@@ -37,8 +37,7 @@ public class ApexMonitoringRestParameters {
private static final String DEFAULT_STATIC_PATH = "/";
// Package that will field REST requests
- public static final String[] DEFAULT_PACKAGES =
- new String[] { "org.onap.policy.apex.services.client.monitoring.rest" };
+ private static final String[] DEFAULT_PACKAGES = new String[] {"org.onap.policy.apex.client.monitoring.rest"};
// The services parameters
private boolean helpSet = false;
diff --git a/context/context-test-utils/pom.xml b/context/context-test-utils/pom.xml
index dc8ec6e0d..77ef30d2a 100644
--- a/context/context-test-utils/pom.xml
+++ b/context/context-test-utils/pom.xml
@@ -56,5 +56,16 @@
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-test</artifactId>
+ <version>4.0.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</project> \ No newline at end of file
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
index 03ef650da..888394be2 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
@@ -44,7 +44,6 @@ import static org.onap.policy.apex.context.test.utils.Constants.STRING_GLOBAL_VA
import static org.onap.policy.apex.context.test.utils.Constants.STRING_VAL;
import static org.onap.policy.apex.context.test.utils.Constants.TEST_POLICY_CONTEXT_ITEM;
import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
-import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
import java.util.Collection;
@@ -79,6 +78,7 @@ import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
+import org.onap.policy.apex.context.test.utils.Constants;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
@@ -129,7 +129,7 @@ public class ContextInstantiation {
contextDistributor.createContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION));
assertNotNull(policyContextAlbum);
- policyContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ policyContextAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray());
final Date testDate = new Date();
@@ -204,7 +204,7 @@ public class ContextInstantiation {
final AxArtifactKey axContextAlbumKey = new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION);
final ContextAlbum externalContextAlbum = contextDistributor.createContextAlbum(axContextAlbumKey);
assertNotNull(externalContextAlbum);
- externalContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ externalContextAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray());
externalContextAlbum.putAll(valueMap2);
externalContextAlbum.getAlbumDefinition().setWritable(false);
@@ -363,7 +363,7 @@ public class ContextInstantiation {
final ContextAlbum globalContextAlbum =
contextDistributor.createContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION));
assertNotNull(globalContextAlbum);
- globalContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ globalContextAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray());
return globalContextAlbum;
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
index 75d559724..33100165b 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
@@ -31,8 +31,8 @@ import static org.onap.policy.apex.context.test.utils.Constants.EXCEPTION_MESSAG
import static org.onap.policy.apex.context.test.utils.Constants.LONG_CONTEXT_ALBUM;
import static org.onap.policy.apex.context.test.utils.Constants.MAP_CONTEXT_ALBUM;
import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
-import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+import static org.onap.policy.apex.context.test.utils.Constants.getAxArtifactKeyArray;
import java.io.IOException;
import java.util.Date;
@@ -160,7 +160,7 @@ public class ContextUpdate {
final ContextAlbum longContextAlbum =
contextDistributor.createContextAlbum(new AxArtifactKey(albumKey, VERSION));
assertNotNull(longContextAlbum);
- longContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ longContextAlbum.setUserArtifactStack(getAxArtifactKeyArray());
return longContextAlbum;
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
index dbf5ab2c6..4041c079d 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
@@ -36,7 +36,6 @@ import static org.onap.policy.apex.context.test.utils.Constants.LONG_VAL;
import static org.onap.policy.apex.context.test.utils.Constants.PI_VAL;
import static org.onap.policy.apex.context.test.utils.Constants.STRING_GLOBAL_VAL;
import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
-import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
import java.util.Collection;
@@ -63,6 +62,7 @@ import org.onap.policy.apex.context.test.concepts.TestContextIntItem;
import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.concepts.TestContextLongObjectItem;
import org.onap.policy.apex.context.test.concepts.TestContextStringItem;
+import org.onap.policy.apex.context.test.utils.Constants;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -351,7 +351,7 @@ public class SequentialContextInstantiation {
throws ContextException {
final ContextAlbum dateAlbum = contextDistributor.createContextAlbum(new AxArtifactKey(albumName, VERSION));
assertNotNull(dateAlbum);
- dateAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ dateAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray());
return dateAlbum;
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java
new file mode 100644
index 000000000..24e633109
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java
@@ -0,0 +1,29 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.lock.modifier;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+
+public interface AlbumModifier {
+
+ void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) throws ContextException;
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java
new file mode 100644
index 000000000..0dd0e7224
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java
@@ -0,0 +1,77 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.lock.modifier;
+
+import org.onap.policy.apex.context.ContextRuntimeException;
+
+public enum LockType {
+
+ NO_LOCK(0) {
+ @Override
+ public AlbumModifier getAlbumModifier() {
+ return NO_LOCK_MODIFER;
+ }
+ },
+ READ_LOCK(1) {
+ @Override
+ public AlbumModifier getAlbumModifier() {
+ return READ_LOCK_MODIFER;
+ }
+ },
+ WRITE_LOCK(2) {
+ @Override
+ public AlbumModifier getAlbumModifier() {
+ return WRITE_LOCK_MODIFER;
+ }
+ },
+ WRITE_LOCK_SINGLE_VALUE_UPDATE(3) {
+ @Override
+ public AlbumModifier getAlbumModifier() {
+ return WRITE_LOCK_SINGLE_VALUE_MODIFER;
+ }
+ };
+
+ private static final AlbumModifier NO_LOCK_MODIFER = new NoLockAlbumModifier();
+ private static final AlbumModifier READ_LOCK_MODIFER = new ReadLockAlbumModifier();
+ private static final AlbumModifier WRITE_LOCK_MODIFER = new WriteLockAlbumModifier();
+ private static final AlbumModifier WRITE_LOCK_SINGLE_VALUE_MODIFER = new SingleValueWriteLockAlbumModifier();
+
+ private final int value;
+
+ private LockType(final int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public static LockType getLockType(final int value) {
+ for (final LockType lockType : LockType.values()) {
+ if (lockType.getValue() == value) {
+ return lockType;
+ }
+ }
+ throw new ContextRuntimeException("Invalid Lock type value: " + value);
+ }
+
+ public abstract AlbumModifier getAlbumModifier();
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/NoLockAlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/NoLockAlbumModifier.java
new file mode 100644
index 000000000..b6ee1b8eb
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/NoLockAlbumModifier.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.lock.modifier;
+
+import java.util.Random;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+public class NoLockAlbumModifier implements AlbumModifier {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(NoLockAlbumModifier.class);
+
+ @Override
+ public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) {
+ final Random rand = new Random();
+ for (int i = 0; i < loopSize; i++) {
+ final String nextLongKey = Integer.toString(rand.nextInt(arraySize));
+ final TestContextLongItem item = (TestContextLongItem) contextAlbum.get(nextLongKey);
+ final long value = item.getLongValue();
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("lock type={}, value={}", LockType.NO_LOCK, value);
+ }
+ }
+ }
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/ReadLockAlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/ReadLockAlbumModifier.java
new file mode 100644
index 000000000..57c6b7524
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/ReadLockAlbumModifier.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.lock.modifier;
+
+import java.util.Random;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+public class ReadLockAlbumModifier implements AlbumModifier {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ReadLockAlbumModifier.class);
+
+ @Override
+ public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) {
+ final Random rand = new Random();
+ for (int i = 0; i < loopSize; i++) {
+ final String nextLongKey = Integer.toString(rand.nextInt(arraySize));
+ try {
+ contextAlbum.lockForReading(nextLongKey);
+ } catch (final ContextException e) {
+ LOGGER.error("could not acquire read lock on context album, key=" + nextLongKey, e);
+ continue;
+ }
+
+ final TestContextLongItem item = (TestContextLongItem) contextAlbum.get(nextLongKey);
+ final long value = item.getLongValue();
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("lock type={}, value={}", LockType.READ_LOCK, value);
+ }
+
+ try {
+ contextAlbum.unlockForReading(nextLongKey);
+ } catch (final ContextException e) {
+ LOGGER.error("could not release read lock on context album, key=" + nextLongKey, e);
+ }
+ }
+
+ }
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/SingleValueWriteLockAlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/SingleValueWriteLockAlbumModifier.java
new file mode 100644
index 000000000..a41de8dd7
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/SingleValueWriteLockAlbumModifier.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.lock.modifier;
+
+import static org.onap.policy.apex.context.test.utils.Constants.TEST_VALUE;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+public class SingleValueWriteLockAlbumModifier implements AlbumModifier {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(SingleValueWriteLockAlbumModifier.class);
+
+
+ @Override
+ public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize)
+ throws ContextException {
+ for (int i = 0; i < loopSize; i++) {
+ try {
+ contextAlbum.lockForWriting(TEST_VALUE);
+ TestContextLongItem item = (TestContextLongItem) contextAlbum.get(TEST_VALUE);
+ if (item != null) {
+ long value = item.getLongValue();
+ item.setLongValue(++value);
+ } else {
+ item = new TestContextLongItem(0L);
+ }
+ contextAlbum.put(TEST_VALUE, item);
+ } finally {
+ contextAlbum.unlockForWriting(TEST_VALUE);
+ }
+ }
+
+ try {
+ contextAlbum.lockForWriting(TEST_VALUE);
+ final TestContextLongItem item = (TestContextLongItem) contextAlbum.get(TEST_VALUE);
+ final long value = item.getLongValue();
+ LOGGER.info("Value after modification: ", value);
+ } catch (final Exception e) {
+ LOGGER.error("could not read the value in the test context album", e);
+ } finally {
+ contextAlbum.unlockForWriting(TEST_VALUE);
+ }
+ }
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/WriteLockAlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/WriteLockAlbumModifier.java
new file mode 100644
index 000000000..09e280026
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/WriteLockAlbumModifier.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.lock.modifier;
+
+import java.util.Random;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+public class WriteLockAlbumModifier implements AlbumModifier {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(WriteLockAlbumModifier.class);
+
+
+ @Override
+ public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) {
+ final Random rand = new Random();
+ for (int i = 0; i < loopSize; i++) {
+ final String nextLongKey = Integer.toString(rand.nextInt(arraySize));
+ try {
+ contextAlbum.lockForWriting(nextLongKey);
+ } catch (final ContextException e) {
+ LOGGER.error("could not acquire write lock on context album, key=" + nextLongKey, e);
+ continue;
+ }
+
+ final TestContextLongItem item = (TestContextLongItem) contextAlbum.get(nextLongKey);
+ long value = item.getLongValue();
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("lock type={}, value={}", LockType.WRITE_LOCK, value);
+ }
+ item.setLongValue(++value);
+ contextAlbum.put(nextLongKey, item);
+
+ try {
+ contextAlbum.unlockForWriting(nextLongKey);
+ } catch (final ContextException e) {
+ LOGGER.error("could not release write lock on context album, key=" + nextLongKey, e);
+ }
+ }
+
+ }
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
index b62364e9d..b373e9fa0 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
@@ -23,22 +23,20 @@ package org.onap.policy.apex.context.test.locking;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
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.TestContextLongItem;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.context.test.utils.IntegrationThreadFactory;
+import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
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.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -55,24 +53,17 @@ public class ConcurrentContext {
private Distributor contextDistributor = null;
private ContextAlbum lTypeAlbum = null;
- /**
- * Test concurrent context.
- *
- * @param testType the test type
- * @param jvmCount the jvm count
- * @param threadCount the thread count
- * @param threadLoops the thread loops
- * @return the long
- * @throws ApexModelException the apex model exception
- * @throws IOException the IO exception
- * @throws ApexException the apex exception
- */
- public long testConcurrentContext(final String testType, final int jvmCount, final int threadCount,
- final int threadLoops) throws ApexModelException, IOException, ApexException {
- final ConcurrentContext concurrentContext = new ConcurrentContext();
+ private final ConfigrationProvider configrationProvider;
+
+ public ConcurrentContext(final ConfigrationProvider configrationProvider) {
+ this.configrationProvider = configrationProvider;
+ }
+
+ public Map<String, TestContextLongItem> testConcurrentContext()
+ throws ApexModelException, IOException, ApexException {
try {
- concurrentContext.setupAndVerifyContext();
+ setupAndVerifyContext();
} catch (final Exception exception) {
LOGGER.error("Error occured while setting up and verifying concurrent context", exception);
throw exception;
@@ -80,28 +71,25 @@ public class ConcurrentContext {
LOGGER.debug("starting JVMs and threads . . .");
- final String name = getThreadFactoryName(jvmCount, testType);
- final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(name);
- final ExecutorService executorService = Executors.newFixedThreadPool(threadCount, threadFactory);
+ final ExecutorService executorService = configrationProvider.getExecutorService();
- final List<Closeable> tasks = new ArrayList<>(threadCount);
+ final List<Closeable> tasks = new ArrayList<>(configrationProvider.getThreadCount());
addShutDownHook(tasks);
// Check if we have a single JVM or multiple JVMs
- if (jvmCount == 1) {
+ if (configrationProvider.getJvmCount() == 1) {
// Run everything in this JVM
- for (int t = 0; t < threadCount; t++) {
- final ConcurrentContextThread task = new ConcurrentContextThread(0, t, threadLoops);
+ for (int t = 0; t < configrationProvider.getThreadCount(); t++) {
+ final ConcurrentContextThread task = new ConcurrentContextThread(0, t, configrationProvider);
tasks.add(task);
executorService.execute(task);
}
} else {
// Spawn JVMs to run the tests
- for (int j = 0; j < jvmCount; j++) {
- final ConcurrentContextJVMThread task =
- new ConcurrentContextJVMThread(testType, j, threadCount, threadLoops);
+ for (int j = 0; j < configrationProvider.getJvmCount(); j++) {
+ final ConcurrentContextJVMThread task = new ConcurrentContextJVMThread(j, configrationProvider);
tasks.add(task);
executorService.execute(task);
}
@@ -120,7 +108,7 @@ public class ConcurrentContext {
LOGGER.info("Shutting down now ...");
executorService.shutdownNow();
- return concurrentContext.verifyAndClearContext(jvmCount, threadCount, threadLoops);
+ return verifyAndClearContext();
}
@@ -140,85 +128,34 @@ public class ConcurrentContext {
});
}
-
- private String getThreadFactoryName(final int jvmCount, final String testType) {
- return jvmCount == 1 ? testType + ":TestConcurrentContextThread_0_"
- : testType + ":TestConcurrentContextJVMThread_";
- }
-
/**
* Setup and verify context.
*
* @throws ContextException the context exception
*/
private void setupAndVerifyContext() throws ContextException {
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
- contextDistributor = new DistributorFactory().getDistributor(distributorKey);
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {
- new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"),
- new AxArtifactKey("testC-bot", "0.0.1")
- };
- // @formatter:on
-
- final AxContextModel albumsModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
- contextDistributor.registerModel(albumsModel);
-
- lTypeAlbum = contextDistributor.createContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"));
- assert (lTypeAlbum != null);
- lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- // CHECKSTYLE:OFF: checkstyle:magicNumber
- lTypeAlbum.put("lTypeValue0", new TestContextLongItem(0xFFFFFFFFFFFFFFFFL));
- lTypeAlbum.put("lTypeValue1", new TestContextLongItem(0xFFFFFFFFFFFFFFFEL));
- lTypeAlbum.put("lTypeValue2", new TestContextLongItem(0xFFFFFFFFFFFFFFFDL));
- lTypeAlbum.put("lTypeValue3", new TestContextLongItem(0xFFFFFFFFFFFFFFFCL));
- lTypeAlbum.put("lTypeValue4", new TestContextLongItem(0xFFFFFFFFFFFFFFFBL));
- lTypeAlbum.put("lTypeValue5", new TestContextLongItem(0xFFFFFFFFFFFFFFFAL));
- lTypeAlbum.put("lTypeValue6", new TestContextLongItem(0xFFFFFFFFFFFFFFF9L));
- lTypeAlbum.put("lTypeValue7", new TestContextLongItem(0xFFFFFFFFFFFFFFF8L));
- lTypeAlbum.put("lTypeValue8", new TestContextLongItem(0xFFFFFFFFFFFFFFF7L));
- lTypeAlbum.put("lTypeValue9", new TestContextLongItem(0xFFFFFFFFFFFFFFF6L));
- lTypeAlbum.put("lTypeValueA", new TestContextLongItem(0xFFFFFFFFFFFFFFF5L));
- lTypeAlbum.put("lTypeValueB", new TestContextLongItem(0xFFFFFFFFFFFFFFF4L));
- lTypeAlbum.put("lTypeValueC", new TestContextLongItem(0xFFFFFFFFFFFFFFF3L));
- lTypeAlbum.put("lTypeValueD", new TestContextLongItem(0xFFFFFFFFFFFFFFF2L));
- lTypeAlbum.put("lTypeValueE", new TestContextLongItem(0xFFFFFFFFFFFFFFF1L));
- lTypeAlbum.put("lTypeValueF", new TestContextLongItem(0xFFFFFFFFFFFFFFF0L));
- LOGGER.debug(lTypeAlbum.toString());
- assert (lTypeAlbum.size() >= 16);
- // CHECKSTYLE:ON: checkstyle:magicNumber
-
- // The initial value for concurrent testing
- final TestContextLongItem item = new TestContextLongItem(0L);
- lTypeAlbum.put("testValue", item);
+ contextDistributor = configrationProvider.getDistributor();
+ lTypeAlbum = configrationProvider.getContextAlbum(contextDistributor);
+ final Map<String, Object> initValues = configrationProvider.getContextAlbumInitValues();
+ for (final Entry<String, Object> entry : initValues.entrySet()) {
+ lTypeAlbum.put(entry.getKey(), entry.getValue());
+ }
}
- /**
- * Verify and clear context.
- *
- * @param jvmCount the jvm count
- * @param threadCount the thread count
- * @param threadLoops the thread loops
- * @return the long
- * @throws ContextException the context exception
- */
- private long verifyAndClearContext(final int jvmCount, final int threadCount, final int threadLoops)
- throws ContextException {
+ private Map<String, TestContextLongItem> verifyAndClearContext() throws ContextException {
+ final Map<String, TestContextLongItem> values = new HashMap<>();
try {
- LOGGER.debug("threads finished, end value is {}",
- ((TestContextLongItem) lTypeAlbum.get("testValue")).getLongValue());
+
+ for (Entry<String, Object> entry : lTypeAlbum.entrySet()) {
+ values.put(entry.getKey(), (TestContextLongItem) entry.getValue());
+ }
} catch (final Exception exception) {
LOGGER.error("Error: ", exception);
}
- final long total = ((TestContextLongItem) lTypeAlbum.get("testValue")).getLongValue();
-
contextDistributor.clear();
contextDistributor = null;
- return total;
+ return values;
}
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
index e2a6b0da0..fc1c830e7 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
@@ -30,20 +30,19 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.TreeSet;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
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.context.test.utils.IntegrationThreadFactory;
+import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
+import org.onap.policy.apex.context.test.utils.ConfigrationProviderImpl;
+import org.onap.policy.apex.context.test.utils.Constants;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
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.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -62,55 +61,29 @@ public final class ConcurrentContextJVM {
private final int jvmNo;
- private final int threadCount;
-
- private final int threadLoops;
-
private final ExecutorService executorService;
- /**
- * The Constructor.
- *
- * @param testType the test type
- * @param jvmNo the jvm no
- * @param threadCount the thread count
- * @param threadLoops the thread loops
- * @throws ApexException the apex exception
- */
- private ConcurrentContextJVM(final String testType, final int jvmNo, final int threadCount, final int threadLoops) {
+ private final ConfigrationProvider configrationProvider;
+
+ private ConcurrentContextJVM(final int jvmNo, final ConfigrationProvider configrationProvider) {
this.jvmNo = jvmNo;
- this.threadCount = threadCount;
- this.threadLoops = threadLoops;
- final String name = testType + ":ConcurrentContextThread_" + jvmNo;
- this.executorService = Executors.newFixedThreadPool(threadCount, new IntegrationThreadFactory(name));
+ this.configrationProvider = configrationProvider;
+ final String name = configrationProvider.getTestName() + ":ConcurrentContextThread_" + jvmNo;
+ this.executorService = configrationProvider.getExecutorService(name, configrationProvider.getThreadCount());
}
public void execute() throws ApexException {
LOGGER.debug("starting JVMs and threads . . .");
final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor" + jvmNo, "0.0.1");
- final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {
- new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"),
- new AxArtifactKey("testC-bot", "0.0.1")
- };
- // @formatter:on
-
- final AxContextModel albumsModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
- contextDistributor.registerModel(albumsModel);
+ final Distributor distributor = configrationProvider.getDistributor(distributorKey);
+ final ContextAlbum contextAlbum = configrationProvider.getContextAlbum(distributor);
+ assert (contextAlbum != null);
- final ContextAlbum lTypeAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"));
- assert (lTypeAlbum != null);
- lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
+ final List<Future<?>> tasks = new ArrayList<>(configrationProvider.getThreadCount());
- final List<Future<?>> tasks = new ArrayList<>(threadCount);
-
- for (int t = 0; t < threadCount; t++) {
- tasks.add(executorService.submit(new ConcurrentContextThread(jvmNo, t, threadLoops)));
+ for (int t = 0; t < configrationProvider.getThreadCount(); t++) {
+ tasks.add(executorService.submit(new ConcurrentContextThread(jvmNo, t, configrationProvider)));
}
try {
@@ -123,8 +96,8 @@ public final class ConcurrentContextJVM {
Thread.currentThread().interrupt();
}
- LOGGER.debug("threads finished, end value is {}", lTypeAlbum.get("testValue"));
- contextDistributor.clear();
+ LOGGER.debug("threads finished, end value is {}", contextAlbum.get(Constants.TEST_VALUE));
+ distributor.clear();
LOGGER.info("Shutting down now ... ");
executorService.shutdownNow();
}
@@ -145,49 +118,25 @@ public final class ConcurrentContextJVM {
// CHECKSTYLE:OFF: checkstyle:magicNumber
// An even number of arguments greater than 3
- if (args.length < 7) {
+ if (args.length < 9) {
LOGGER.error("invalid arguments: " + Arrays.toString(args));
LOGGER.error(
- "usage: TestConcurrentContextJVM testType jvmNo threadCount threadLoops [parameterKey parameterJson].... ");
- return;
- }
-
- int jvmNo = -1;
- int threadCount = -1;
- int threadLoops = -1;
- String hazelCastfileLocation = null;
-
- try {
- jvmNo = Integer.parseInt(args[1]);
- } catch (final Exception e) {
- LOGGER.error("invalid argument jvmNo", e);
- return;
- }
-
- try {
- threadCount = Integer.parseInt(args[2]);
- } catch (final Exception e) {
- LOGGER.error("invalid argument threadCount", e);
+ "usage: TestConcurrentContextJVM testType jvmNo threadCount threadLoops albumSize lockType [parameterKey parameterJson].... ");
return;
}
- try {
- threadLoops = Integer.parseInt(args[3]);
- } catch (final Exception e) {
- LOGGER.error("invalid argument threadLoops", e);
- return;
- }
- try {
- hazelCastfileLocation = args[4].trim();
- } catch (final Exception e) {
- LOGGER.error("invalid argument hazelcast file location", e);
- return;
- }
+ final String testName = getStringValue("testType", args, 0);
+ final int jvmNo = getIntValue("jvmNo", args, 1);
+ final int threadCount = getIntValue("threadCount", args, 2);
+ final int threadLoops = getIntValue("threadLoops", args, 3);
+ final int albumSize = getIntValue("albumSize", args, 4);
+ final int lockType = getIntValue("lockType", args, 5);
+ final String hazelCastfileLocation = getStringValue("hazelcast file location", args, 6);;
System.setProperty("hazelcast.config", hazelCastfileLocation);
- for (int p = 5; p < args.length - 1; p += 2) {
+ for (int p = 7; p < args.length - 1; p += 2) {
@SuppressWarnings("rawtypes")
final Class parametersClass = Class.forName(args[p]);
final AbstractParameters parameters =
@@ -201,8 +150,9 @@ public final class ConcurrentContextJVM {
}
try {
- final ConcurrentContextJVM concurrentContextJVM =
- new ConcurrentContextJVM(args[0], jvmNo, threadCount, threadLoops);
+ final ConfigrationProvider configrationProvider =
+ new ConfigrationProviderImpl(testName, 1, threadCount, threadLoops, albumSize, lockType);
+ final ConcurrentContextJVM concurrentContextJVM = new ConcurrentContextJVM(jvmNo, configrationProvider);
concurrentContextJVM.execute();
} catch (final Exception e) {
@@ -211,9 +161,30 @@ public final class ConcurrentContextJVM {
}
// CHECKSTYLE:ON: checkstyle:magicNumber
+ }
+ private static String getStringValue(final String key, final String[] args, final int position) {
+ try {
+ return args[position];
+ } catch (final Exception e) {
+ final String msg = "invalid argument " + key;
+ LOGGER.error(msg, e);
+ throw new ApexRuntimeException(msg, e);
+ }
}
+ private static int getIntValue(final String key, final String[] args, final int position) {
+ final String value = getStringValue(key, args, position);
+ try {
+ return Integer.parseInt(value);
+ } catch (final Exception e) {
+ final String msg = "Expects number found " + value;
+ LOGGER.error(msg, e);
+ throw new ApexRuntimeException(msg, e);
+ }
+ }
+
+
/**
* This method setus up any static configuration required by the JVM.
*
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
index 995772f05..049754802 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
@@ -22,14 +22,13 @@ package org.onap.policy.apex.context.test.locking;
import java.io.BufferedReader;
import java.io.Closeable;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
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.context.test.utils.ConfigrationProvider;
import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.slf4j.ext.XLogger;
@@ -46,27 +45,13 @@ public class ConcurrentContextJVMThread implements Runnable, Closeable {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextJVMThread.class);
- private final String testType;
private final int jvm;
- private final int threadCount;
- private final int target;
+ private final ConfigrationProvider configrationProvider;
private Process process = null;
- /**
- * The Constructor.
- *
- * @param testType the test type
- * @param jvm the jvm
- * @param threadCount the thread count
- * @param target the target
- * @throws ApexException the apex exception
- */
- public ConcurrentContextJVMThread(final String testType, final int jvm, final int threadCount, final int target)
- throws ApexException {
- this.testType = testType;
+ public ConcurrentContextJVMThread(final int jvm, final ConfigrationProvider configrationProvider) {
this.jvm = jvm;
- this.threadCount = threadCount;
- this.target = target;
+ this.configrationProvider = configrationProvider;
}
/*
@@ -84,11 +69,13 @@ public class ConcurrentContextJVMThread implements Runnable, Closeable {
commandList.add("-cp");
commandList.add(System.getProperty("java.class.path"));
commandList.add(ConcurrentContextJVM.class.getCanonicalName());
- commandList.add(testType);
+ commandList.add(configrationProvider.getTestName());
commandList.add(new Integer(jvm).toString());
- commandList.add(new Integer(threadCount).toString());
- commandList.add(new Integer(target).toString());
- commandList.add(System.getProperty("hazelcast.config"));
+ commandList.add(new Integer(configrationProvider.getThreadCount()).toString());
+ commandList.add(new Integer(configrationProvider.getLoopSize()).toString());
+ commandList.add(new Integer(configrationProvider.getAlbumSize()).toString());
+ commandList.add(new Integer(configrationProvider.getLockType().getValue()).toString());
+ commandList.add(System.getProperty("hazelcast.config", ""));
for (final Entry<Class<?>, AbstractParameters> parameterServiceEntry : ParameterService.getAll()) {
commandList.add(parameterServiceEntry.getKey().getCanonicalName());
@@ -101,7 +88,6 @@ public class ConcurrentContextJVMThread implements Runnable, Closeable {
final ProcessBuilder processBuilder = new ProcessBuilder(commandList);
processBuilder.redirectErrorStream(true);
-
try {
process = processBuilder.start();
@@ -122,7 +108,7 @@ public class ConcurrentContextJVMThread implements Runnable, Closeable {
LOGGER.warn("Thread was interrupted");
Thread.currentThread().interrupt();
}
- } catch (final IOException ioException) {
+ } catch (final Exception ioException) {
LOGGER.error("Error occured while writing JVM Output for command ", ioException);
}
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
index 75a704557..726880f3b 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
@@ -25,13 +25,10 @@ import java.io.Closeable;
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.test.concepts.TestContextLongItem;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.context.test.lock.modifier.AlbumModifier;
+import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
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;
@@ -41,33 +38,25 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ConcurrentContextThread implements Runnable, Closeable {
- private static final String VALUE = "testValue";
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextThread.class);
- private final Distributor distributor;
private final int jvm;
private final int instance;
- private final int threadLoops;
+ private final ConfigrationProvider configrationProvider;
/**
* The Constructor.
*
* @param jvm the jvm
* @param instance the instance
- * @param threadLoops the thread loops
- * @throws ApexException the apex exception
+ * @param configrationProvider the configuration provider
*/
- public ConcurrentContextThread(final int jvm, final int instance, final int threadLoops) throws ApexException {
+ public ConcurrentContextThread(final int jvm, final int instance, final ConfigrationProvider configrationProvider) {
this.jvm = jvm;
this.instance = instance;
- this.threadLoops = threadLoops;
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor_" + jvm + "_" + instance, "0.0.1");
+ this.configrationProvider = configrationProvider;
new ContextParameters();
- distributor = new DistributorFactory().getDistributor(distributorKey);
- final AxContextModel albumsModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
- distributor.registerModel(albumsModel);
}
/*
@@ -79,72 +68,30 @@ public class ConcurrentContextThread implements Runnable, Closeable {
public void run() {
LOGGER.info("running TestConcurrentContextThread_" + jvm + "_" + instance + " . . .");
- ContextAlbum lTypeAlbum = null;
-
- try {
- lTypeAlbum = distributor.createContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"));
- } catch (final Exception e) {
- LOGGER.error("could not get the test context album", e);
- LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
- return;
- }
-
- if (lTypeAlbum == null) {
- LOGGER.error("could not find the test context album");
- LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
- return;
- }
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")};
- // @formatter:on
- lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
+ final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor_" + jvm + "_" + instance, "0.0.1");
+ final Distributor distributor = configrationProvider.getDistributor(distributorKey);
try {
- updateAlbum(lTypeAlbum);
- } catch (final Exception exception) {
- LOGGER.error("could not set the value in the test context album", exception);
- LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
- return;
- }
+ final long startTime = System.currentTimeMillis();
+ final ContextAlbum contextAlbum = configrationProvider.getContextAlbum(distributor);
+
+ final AlbumModifier albumModifier = configrationProvider.getAlbumModifier();
+ albumModifier.modifyAlbum(contextAlbum, configrationProvider.getLoopSize(),
+ configrationProvider.getAlbumSize());
+ LOGGER.info("Took {} ms to modify album", (System.currentTimeMillis() - startTime));
- try {
- lTypeAlbum.lockForWriting(VALUE);
- final TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get(VALUE);
- final long value = item.getLongValue();
- LOGGER.info("completed TestConcurrentContextThread_" + jvm + "_" + instance + ", value=" + value);
} catch (final Exception e) {
- LOGGER.error("could not read the value in the test context album", e);
- LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
+ LOGGER.error("Unexpected error occured while processing", e);
} finally {
try {
- lTypeAlbum.unlockForWriting(VALUE);
distributor.shutdown();
} catch (final ContextException e) {
- LOGGER.error("could not unlock test context album item", e);
- LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
+ LOGGER.error("Unable to shutdown distributor", e);
}
}
- }
+ LOGGER.info("finished TestConcurrentContextThread_" + jvm + "_" + instance + " . . .");
- private void updateAlbum(final ContextAlbum lTypeAlbum) throws Exception {
- for (int i = 0; i < threadLoops; i++) {
- try {
- lTypeAlbum.lockForWriting(VALUE);
- TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get(VALUE);
- if (item != null) {
- long value = item.getLongValue();
- item.setLongValue(++value);
- } else {
- item = new TestContextLongItem(0L);
- }
- lTypeAlbum.put(VALUE, item);
- } finally {
- lTypeAlbum.unlockForWriting(VALUE);
- }
- }
}
@Override
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProvider.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProvider.java
new file mode 100644
index 000000000..d17f32269
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProvider.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.utils;
+
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+
+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.test.lock.modifier.AlbumModifier;
+import org.onap.policy.apex.context.test.lock.modifier.LockType;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+public interface ConfigrationProvider {
+
+ String getTestName();
+
+ int getLoopSize();
+
+ int getThreadCount();
+
+ int getJvmCount();
+
+ int getAlbumSize();
+
+ ExecutorService getExecutorService();
+
+ ExecutorService getExecutorService(final String threadFactoryName, final int threadPoolSize);
+
+ Distributor getDistributor(final AxArtifactKey key);
+
+ Distributor getDistributor();
+
+ ContextAlbum getContextAlbum(final Distributor distributor);
+
+ ContextAlbum getContextAlbum(final Distributor distributor, AxArtifactKey axContextAlbumKey,
+ AxArtifactKey[] artifactKeys) throws ContextException;
+
+ Map<String, Object> getContextAlbumInitValues();
+
+ AlbumModifier getAlbumModifier();
+
+ LockType getLockType();
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java
new file mode 100644
index 000000000..50429099e
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java
@@ -0,0 +1,166 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.ContextRuntimeException;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
+import org.onap.policy.apex.context.test.lock.modifier.AlbumModifier;
+import org.onap.policy.apex.context.test.lock.modifier.LockType;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.onap.policy.apex.model.utilities.Assertions;
+
+public class ConfigrationProviderImpl implements ConfigrationProvider {
+
+ private final String testType;
+ private final int jvmCount;
+ private final int threadCount;
+ private final int loopSize;
+ private final int albumSize;
+ private final LockType lockType;
+
+ public ConfigrationProviderImpl(final String testType, final int jvmCount, final int threadCount,
+ final int loopSize, final int albumSize, final int lockType) {
+ this.testType = testType;
+ this.jvmCount = jvmCount;
+ this.threadCount = threadCount;
+ this.loopSize = loopSize;
+ this.albumSize = albumSize;
+ this.lockType = LockType.getLockType(lockType);
+ }
+
+ @Override
+ public String getTestName() {
+ return testType;
+ }
+
+ @Override
+ public int getLoopSize() {
+ return loopSize;
+ }
+
+ @Override
+ public int getThreadCount() {
+ return threadCount;
+ }
+
+ @Override
+ public int getJvmCount() {
+ return jvmCount;
+ }
+
+ @Override
+ public int getAlbumSize() {
+ return albumSize;
+ }
+
+ @Override
+ public ExecutorService getExecutorService() {
+ final String name = getThreadFactoryName(jvmCount, testType);
+ final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(name);
+ final ExecutorService executorService = Executors.newFixedThreadPool(threadCount, threadFactory);
+ return executorService;
+ }
+
+ @Override
+ public ExecutorService getExecutorService(final String threadFactoryName, final int threadPoolSize) {
+ final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(threadFactoryName);
+ final ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize, threadFactory);
+ return executorService;
+ }
+
+ @Override
+ public Distributor getDistributor(final AxArtifactKey key) {
+ try {
+ return new DistributorFactory().getDistributor(key);
+ } catch (ContextException e) {
+ throw new ContextRuntimeException("Unable to create Distributor", e);
+ }
+ }
+
+ @Override
+ public Distributor getDistributor() {
+ final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
+ return getDistributor(distributorKey);
+ }
+
+ @Override
+ public ContextAlbum getContextAlbum(final Distributor distributor) {
+ return getContextAlbum(distributor, Constants.L_TYPE_CONTEXT_ALBUM, Constants.getAxArtifactKeyArray());
+ }
+
+ @Override
+ public ContextAlbum getContextAlbum(final Distributor distributor, final AxArtifactKey axContextAlbumKey,
+ final AxArtifactKey[] artifactKeys) {
+ final AxContextModel axContextModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
+ try {
+ distributor.registerModel(axContextModel);
+ final ContextAlbum contextAlbum = distributor.createContextAlbum(axContextAlbumKey);
+ Assertions.argumentNotNull(contextAlbum, "ContextAlbum should not be null");
+ contextAlbum.setUserArtifactStack(artifactKeys);
+ return contextAlbum;
+ } catch (ContextException e) {
+ throw new ContextRuntimeException("Unable to create ContextAlbum", e);
+ }
+ }
+
+ @Override
+ public Map<String, Object> getContextAlbumInitValues() {
+ final Map<String, Object> values = new HashMap<>();
+ for (int i = 0; i < albumSize; i++) {
+ values.put(Integer.toString(i), new TestContextLongItem(0l));
+ }
+ return values;
+ }
+
+ @Override
+ public AlbumModifier getAlbumModifier() {
+ return lockType.getAlbumModifier();
+ }
+
+ @Override
+ public LockType getLockType() {
+ return lockType;
+ }
+
+
+ private String getThreadFactoryName(final int jvmCount, final String testType) {
+ return jvmCount == 1 ? testType + ":TestConcurrentContextThread_0_"
+ : testType + ":TestConcurrentContextJVMThread_";
+ }
+
+ @Override
+ public String toString() {
+ return "ConfigrationProviderImpl [testType=" + testType + ", jvmCount=" + jvmCount + ", threadCount="
+ + threadCount + ", loopSize=" + loopSize + ", albumSize=" + albumSize + ", lockType=" + lockType + "]";
+ }
+
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
index 79687139a..933c68b11 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
@@ -52,14 +52,17 @@ public class Constants {
public static final String TEST_POLICY_CONTEXT_ITEM = TestPolicyContextItem.class.getName();
public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("Europe/Dublin");
+ public static final AxArtifactKey L_TYPE_CONTEXT_ALBUM = new AxArtifactKey("LTypeContextAlbum", VERSION);
+ public static final String TEST_VALUE = "testValue";
+
private static final AxArtifactKey KEY = new AxArtifactKey("testC-top", VERSION);
private static final AxArtifactKey KEY3 = new AxArtifactKey("testC-bot", VERSION);
private static final AxArtifactKey KEY2 = new AxArtifactKey("testC-next", VERSION);
- public static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = getAxArtifactKeyArray();
+ private static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = new AxArtifactKey[] {KEY, KEY2, KEY3};;
- private static AxArtifactKey[] getAxArtifactKeyArray() {
- return new AxArtifactKey[] {KEY, KEY2, KEY3};
+ public static final AxArtifactKey[] getAxArtifactKeyArray() {
+ return USED_ARTIFACT_STACK_ARRAY;
}
private Constants() {}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java
new file mode 100644
index 000000000..01331f2a7
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.utils;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.TreeSet;
+
+public class NetworkUtils {
+
+ private NetworkUtils() {}
+
+ /**
+ * 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
+ *
+ * @return Set of IPv4 addresses
+ * @throws SocketException
+ */
+ public static TreeSet<String> getIPv4NonLoopAddresses() throws SocketException {
+ 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());
+ }
+ }
+ }
+ return ipAddressSet;
+ }
+
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java
new file mode 100644
index 000000000..67bb8878b
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.policy.apex.context.test.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+public class ZooKeeperServerServiceProvider {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ZooKeeperServerServiceProvider.class);
+
+ private NIOServerCnxnFactory zookeeperFactory;
+ private File zookeeperDirectory;
+ private InetSocketAddress addr;
+
+ public ZooKeeperServerServiceProvider(final File zookeeperDirectory, final InetSocketAddress addr) {
+ this.zookeeperDirectory = zookeeperDirectory;
+ this.addr = addr;
+ }
+
+ public ZooKeeperServerServiceProvider(final File zookeeperDirectory, final String addr, final int port) {
+ this.zookeeperDirectory = zookeeperDirectory;
+ this.addr = new InetSocketAddress(addr, port);
+ }
+
+ public void startZookeeperServer() throws IOException, InterruptedException {
+ LOGGER.info("Starting up ZooKeeperServer using address: {} and port: {}", addr.getAddress(), addr.getPort());
+ final ZooKeeperServer server = new ZooKeeperServer(zookeeperDirectory, zookeeperDirectory, 5000);
+ zookeeperFactory = new NIOServerCnxnFactory();
+ zookeeperFactory.configure(addr, 100);
+ zookeeperFactory.startup(server);
+ }
+
+ public void stopZookeeperServer() {
+ LOGGER.info("Stopping ZooKeeperServer for address: {} and port: {}", addr.getAddress(), addr.getPort());
+ if (zookeeperFactory != null) {
+ zookeeperFactory.shutdown();
+ }
+ }
+
+}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
index 7788fb411..c29353caf 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
@@ -22,15 +22,21 @@ package org.onap.policy.apex.context.test.locking;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.onap.policy.apex.context.test.lock.modifier.LockType.WRITE_LOCK_SINGLE_VALUE_UPDATE;
+import static org.onap.policy.apex.context.test.utils.Constants.TEST_VALUE;
-import java.io.IOException;
+import java.util.Map;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
+import org.onap.policy.apex.context.test.utils.ConfigrationProviderImpl;
+import org.onap.policy.apex.context.test.utils.Constants;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -40,10 +46,12 @@ import org.slf4j.ext.XLoggerFactory;
* @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 ALBUM_SIZE = 16;
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;
@@ -51,46 +59,81 @@ public class TestConcurrentContext {
private static final int TEST_THREAD_LOOPS = 100;
@Test
- public void testConcurrentContextJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
+ public void testConcurrentContextJVMLocalVarSet() throws Exception {
logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
- 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);
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalVarSet",
+ TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
+
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ assertFalse(result.isEmpty());
+ final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
+
logger.debug("Ran testConcurrentContextJVMLocalVarSet test");
}
@Test
- public void testConcurrentContextJVMLocalNoVarSet() throws ApexModelException, IOException, ApexException {
+ public void testConcurrentContextJVMLocalNoVarSet() throws Exception {
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);
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("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);
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ assertFalse(result.isEmpty());
+ final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
logger.debug("Ran testConcurrentContextJVMLocalNoVarSet test");
}
@Test
- public void testConcurrentContextMultiJVMNoLock() throws ApexModelException, IOException, ApexException {
+ public void testConcurrentContextMultiJVMNoLock() throws Exception {
logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
- final long result = new ConcurrentContext().testConcurrentContext("testConcurrentContextMultiJVMNoLock",
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("testConcurrentContextMultiJVMNoLock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
// No concurrent map so result will be zero
- assertEquals(0, result);
+ assertFalse(result.isEmpty());
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(0, actual.getLongValue());
logger.debug("Ran testConcurrentContextMultiJVMNoLock test");
}
+
+ private ConfigrationProvider getConfigrationProvider(final String testType, final int jvmCount,
+ final int threadCount, final int threadLoops) {
+ return new ConfigrationProviderImpl(testType, jvmCount, threadCount, threadLoops, ALBUM_SIZE,
+ WRITE_LOCK_SINGLE_VALUE_UPDATE.getValue()) {
+ @Override
+ public Map<String, Object> getContextAlbumInitValues() {
+ final Map<String, Object> initValues = super.getContextAlbumInitValues();
+ initValues.put(Constants.TEST_VALUE, new TestContextLongItem(0l));
+ return initValues;
+ }
+ };
+ }
}
diff --git a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java
index e18c327c0..21c5ee984 100644
--- a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java
+++ b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java
@@ -52,18 +52,25 @@ public class EndToEndStringMessagingTest {
assertNotNull(server);
server.start(new WSStringServerMessageListener());
- client = new WSStringMessageClient("localhost", 44441);
- assertNotNull(client);
- client.start(new WSStringClientMessageListener());
+ try {
+ client = new WSStringMessageClient("localhost", 44441);
+ assertNotNull(client);
+ client.start(new WSStringClientMessageListener());
- client.sendString("Hello, client here");
+ client.sendString("Hello, client here");
- while (!finished) {
- ThreadUtilities.sleep(50);
- }
- client.stop();
+ while (!finished) {
+ ThreadUtilities.sleep(50);
+ }
+ } finally {
+ if (client != null) {
+ client.stop();
+ }
+ if (server != null) {
+ server.stop();
+ }
- server.stop();
+ }
logger.debug("end to end messaging test finished");
}
diff --git a/testsuites/integration/integration-context-test/pom.xml b/testsuites/integration/integration-context-test/pom.xml
index 6454a8cd5..95e2c6b43 100644
--- a/testsuites/integration/integration-context-test/pom.xml
+++ b/testsuites/integration/integration-context-test/pom.xml
@@ -71,18 +71,6 @@
<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>
-</project>
+</project> \ No newline at end of file
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
index e2c2de97a..5c1329242 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
@@ -21,20 +21,17 @@
package org.onap.policy.apex.plugins.context.test.locking;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.onap.policy.apex.context.parameters.DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
+import static org.onap.policy.apex.context.test.utils.Constants.TEST_VALUE;
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.Map;
import java.util.TreeSet;
-import org.apache.zookeeper.server.NIOServerCnxnFactory;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
@@ -44,7 +41,15 @@ import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
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.TestContextLongItem;
+import org.onap.policy.apex.context.test.lock.modifier.LockType;
import org.onap.policy.apex.context.test.locking.ConcurrentContext;
+import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
+import org.onap.policy.apex.context.test.utils.ConfigrationProviderImpl;
+import org.onap.policy.apex.context.test.utils.Constants;
+import org.onap.policy.apex.context.test.utils.NetworkUtils;
+import org.onap.policy.apex.context.test.utils.ZooKeeperServerServiceProvider;
+import org.onap.policy.apex.core.infrastructure.messaging.util.MessagingUtils;
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;
@@ -58,8 +63,6 @@ import org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManag
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import com.hazelcast.config.Config;
-
/**
* The Class TestConcurrentContext tests concurrent use of context.
*
@@ -67,7 +70,7 @@ import com.hazelcast.config.Config;
*/
public class TestConcurrentContext {
private static final String HAZELCAST_CONFIG = "hazelcast.config";
-
+
private static final String JAVA_NET_PREFER_IPV4_STACK = "java.net.preferIPv4Stack";
private static final String HAZELCAST_XML_FILE = "src/test/resources/hazelcast/hazelcast.xml";
@@ -83,8 +86,6 @@ public class TestConcurrentContext {
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;
@@ -93,157 +94,175 @@ public class TestConcurrentContext {
@Rule
public final TemporaryFolder folder = new TemporaryFolder();
+ private ZooKeeperServerServiceProvider zooKeeperServerServiceProvider;
+
@BeforeClass
public static void configure() throws Exception {
System.setProperty(JAVA_NET_PREFER_IPV4_STACK, "true");
final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE);
System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation);
- // 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());
- }
- }
- }
+ final TreeSet<String> ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses();
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());
+ logger.info("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 {
+ private void startZookeeperServer() throws Exception {
final File zookeeperDirectory = folder.newFolder("zookeeperDirectory");
zookeeperPort = nextZookeeperPort++;
-
- final ZooKeeperServer server = new ZooKeeperServer(zookeeperDirectory, zookeeperDirectory, 5000);
- zookeeperFactory = new NIOServerCnxnFactory();
- zookeeperFactory.configure(new InetSocketAddress(zookeeperPort), 100);
-
- zookeeperFactory.startup(server);
+ final InetSocketAddress addr = new InetSocketAddress(MessagingUtils.findPort(zookeeperPort));
+ zooKeeperServerServiceProvider = new ZooKeeperServerServiceProvider(zookeeperDirectory, addr);
+ zooKeeperServerServiceProvider.startZookeeperServer();
}
private void stopZookeeperServer() {
- zookeeperFactory.shutdown();
+ if (zooKeeperServerServiceProvider != null) {
+ zooKeeperServerServiceProvider.stopZookeeperServer();
+ }
}
@Test
- public void testConcurrentContextJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
+ public void testConcurrentContextJVMLocalVarSet() throws Exception {
logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
- 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);
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalVarSet",
+ TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
+
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ assertFalse(result.isEmpty());
+
+ final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
logger.debug("Ran testConcurrentContextJVMLocalVarSet test");
}
@Test
- public void testConcurrentContextJVMLocalNoVarSet() throws ApexModelException, IOException, ApexException {
+ public void testConcurrentContextJVMLocalNoVarSet() throws Exception {
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);
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("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);
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(Constants.TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
logger.debug("Ran testConcurrentContextJVMLocalNoVarSet test");
}
@Test
- public void testConcurrentContextMultiJVMNoLock() throws ApexModelException, IOException, ApexException {
+ public void testConcurrentContextMultiJVMNoLock() throws Exception {
logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
- final long result = new ConcurrentContext().testConcurrentContext("testConcurrentContextMultiJVMNoLock",
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("testConcurrentContextMultiJVMNoLock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
// No concurrent map so result will be zero
- assertEquals(0, result);
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(0, actual.getLongValue());
logger.debug("Ran testConcurrentContextMultiJVMNoLock test");
}
@Test
- public void testConcurrentContextHazelcastLock() throws ApexModelException, IOException, ApexException {
+ public void testConcurrentContextHazelcastLock() throws Exception {
logger.debug("Running testConcurrentContextHazelcastLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
- 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);
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("HazelcastLock",
+ TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
+
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
+
logger.debug("Ran testConcurrentContextHazelcastLock test");
}
@Test
- public void testConcurrentContextCuratorLock()
- throws ApexModelException, IOException, ApexException, InterruptedException {
+ public void testConcurrentContextCuratorLock() throws Exception {
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(CuratorLockManager.class.getCanonicalName());
- curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + 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");
+ try {
+ startZookeeperServer();
+ final ContextParameters contextParameters = new ContextParameters();
+ final DistributorParameters distributorParameters = contextParameters.getDistributorParameters();
+ distributorParameters.setPluginClass(DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
+
+ final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
+ curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
+ contextParameters.setLockManagerParameters(curatorParameters);
+ ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
+
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("CuratorLock",
+ TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
+
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
+ logger.debug("Ran testConcurrentContextCuratorLock test");
+ } finally {
+ stopZookeeperServer();
+ }
}
@Test
- public void testConcurrentContextHazelcastMultiJVMHazelcastLock()
- throws ApexModelException, IOException, ApexException {
+ public void testConcurrentContextHazelcastMultiJVMHazelcastLock() throws Exception {
logger.debug("Running testConcurrentContextHazelcastMultiJVMHazelcastLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass(HazelcastContextDistributor.class.getCanonicalName());
+ final DistributorParameters distributorParameters = contextParameters.getDistributorParameters();
+ distributorParameters.setPluginClass(HazelcastContextDistributor.class.getCanonicalName());
contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
- final long result = new ConcurrentContext().testConcurrentContext("HazelcastMultiHazelcastlock",
+
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("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);
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ final int expected = TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
logger.debug("Ran testConcurrentContextHazelcastMultiJVMHazelcastLock test");
}
@@ -259,65 +278,98 @@ public class TestConcurrentContext {
contextParameters.setDistributorParameters(infinispanParameters);
contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
- final long result = new ConcurrentContext().testConcurrentContext("InfinispanMultiHazelcastlock",
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("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);
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ final int expected = TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
logger.debug("Ran testConcurrentContextInfinispanMultiJVMHazelcastlock test");
}
@Test
- public void testConcurrentContextInfinispanMultiJVMCuratorLock()
- throws ApexModelException, IOException, ApexException, InterruptedException {
+ public void testConcurrentContextInfinispanMultiJVMCuratorLock() throws Exception {
logger.debug("Running testConcurrentContextInfinispanMultiJVMCuratorLock test . . .");
- startZookeeperServer();
-
- final ContextParameters contextParameters = new ContextParameters();
- final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters();
- infinispanParameters.setPluginClass(InfinispanContextDistributor.class.getCanonicalName());
- infinispanParameters.setConfigFile("infinispan/infinispan-context-test.xml");
- contextParameters.setDistributorParameters(infinispanParameters);
-
- final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
- curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + 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();
+ try {
+ startZookeeperServer();
+
+ final ContextParameters contextParameters = new ContextParameters();
+ final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters();
+ infinispanParameters.setPluginClass(InfinispanContextDistributor.class.getCanonicalName());
+ infinispanParameters.setConfigFile("infinispan/infinispan-context-test.xml");
+ contextParameters.setDistributorParameters(infinispanParameters);
+
+ final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
+ curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
+ contextParameters.setLockManagerParameters(curatorParameters);
+ ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
+
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("InfinispanMultiCuratorLock",
+ TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
+
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
+
+ final int expected = TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
+ } finally {
+ stopZookeeperServer();
+ }
logger.debug("Ran testConcurrentContextInfinispanMultiJVMCuratorLock test");
}
@Test
- public void testConcurrentContextHazelcastMultiJVMCuratorLock()
- throws ApexModelException, IOException, ApexException, InterruptedException {
+ public void testConcurrentContextHazelcastMultiJVMCuratorLock() throws Exception {
logger.debug("Running testConcurrentContextHazelcastMultiJVMCuratorLock test . . .");
- startZookeeperServer();
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass(HazelcastContextDistributor.class.getCanonicalName());
-
- final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
- curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + 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);
+ try {
+ startZookeeperServer();
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters()
+ .setPluginClass(HazelcastContextDistributor.class.getCanonicalName());
+
+ final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
+ curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
+ contextParameters.setLockManagerParameters(curatorParameters);
+ ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
+
+ final ConfigrationProvider configrationProvider = getConfigrationProvider("HazelcastMultiCuratorLock",
+ TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
+ final Map<String, TestContextLongItem> result =
+ new ConcurrentContext(configrationProvider).testConcurrentContext();
+
+ final int expected = TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS;
+ final TestContextLongItem actual = result.get(TEST_VALUE);
+ assertNotNull(actual);
+ assertEquals(expected, actual.getLongValue());
+ } finally {
+ stopZookeeperServer();
+ }
+ logger.debug("Ran testConcurrentContextHazelcastMultiJVMCuratorLock test");
+ }
- assertEquals(TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS, result);
+ ConfigrationProvider getConfigrationProvider(final String testType, final int jvmCount, final int threadCount,
+ final int threadLoops) {
+ return new ConfigrationProviderImpl(testType, jvmCount, threadCount, threadLoops, 16,
+ LockType.WRITE_LOCK_SINGLE_VALUE_UPDATE.getValue()) {
+ @Override
+ public Map<String, Object> getContextAlbumInitValues() {
+ final Map<String, Object> initValues = super.getContextAlbumInitValues();
+ initValues.put(TEST_VALUE, new TestContextLongItem(0l));
+ return initValues;
+ }
- stopZookeeperServer();
- logger.debug("Ran testConcurrentContextHazelcastMultiJVMCuratorLock test");
+ };
}
}
diff --git a/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml b/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml
index 17ba5eaca..a84a737b5 100644
--- a/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml
+++ b/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml
@@ -24,6 +24,8 @@
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">
<UDP mcast_addr="${jgroups.udp.mcast_addr:228.6.7.8}"
mcast_port="${jgroups.udp.mcast_port:46655}"
+ bind_port="${jgroups.udp.mcast.bind_port:63005}"
+ bind_addr="${jgroups.udp.mcast.bind_addr:127.0.0.1}"
ucast_send_buf_size="1m"
mcast_send_buf_size="1m"
ucast_recv_buf_size="20m"
@@ -43,12 +45,13 @@
max_interval="30000"
/>
<FD_SOCK />
+ <FD_SOCK bind_addr="${jgroups.udp.mcast.bind_addr:127.0.0.1}" sock_conn_timeout="60000" start_port="${jgroups.udp.fd.sock.start_port:63010}" port_range="1000"/>
+
<FD_ALL timeout="60000"
interval="15000"
timeout_check_interval="5000"
/>
- <VERIFY_SUSPECT timeout="5000"
- />
+ <VERIFY_SUSPECT timeout="5000" />
<pbcast.NAKACK2 xmit_interval="100"
xmit_table_num_rows="50"
xmit_table_msgs_per_row="1024"
diff --git a/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java b/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java
index cbe06ed57..3d257f89a 100644
--- a/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java
+++ b/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java
@@ -20,27 +20,30 @@
package org.onap.policy.apex.plugins.context.metrics;
+import static org.onap.policy.apex.context.parameters.DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
+import static org.onap.policy.apex.context.parameters.LockManagerParameters.DEFAULT_LOCK_MANAGER_PLUGIN_CLASS;
+
+import java.io.File;
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 java.util.Arrays;
+import java.util.Map;
+import java.util.Map.Entry;
+
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.TestContextLongItem;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
+import org.onap.policy.apex.context.test.locking.ConcurrentContext;
+import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
+import org.onap.policy.apex.context.test.utils.ConfigrationProviderImpl;
+import org.onap.policy.apex.context.test.utils.ZooKeeperServerServiceProvider;
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.hazelcast.HazelcastContextDistributor;
+import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor;
import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
+import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager;
import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManagerParameters;
+import org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -50,7 +53,7 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ConcurrentContextMetrics {
- private static final int NUM_ARGS = 8;
+ private static final int NUM_ARGS = 9;
private static final int ARG_LABEL = 0;
private static final int ARG_JVM_COUNT = 1;
private static final int ARG_THREAD_COUNT = 2;
@@ -58,55 +61,38 @@ public class ConcurrentContextMetrics {
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;
+ private static final int ARG_ZOOKEEPER_PORT = 7;
+ private static final int ARG_ZOOKEEPER_DIRECTORY = 8;
// 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");
+ private final ConfigrationProvider configrationProvider;
+ private final File zookeeperDirectory;
+ private final int zookeeperPort;
/**
* The main method.
*
* @param args the args
- * @throws ApexModelException the apex model exception
- * @throws IOException the IO exception
- * @throws ApexException the apex exception
+ * @throws Exception the exception
*/
- public static void main(final String[] args) throws ApexModelException, IOException, ApexException {
+ public static void main(final String[] args) throws Exception {
if (args.length != NUM_ARGS) {
+ System.err.println("Args: " + Arrays.toString(args));
System.err.println(
- "usage: ConcurrentContextMetrics testLabel jvmCount threadCount threadLoops longArraySize lockType zookeeperAddress interactive");
+ "usage: testLabel jvmCount threadCount threadLoops longArraySize lockType zookeeperAddress zookeeperPort zookeeperDirectory");
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
+
+ final ConfigrationProvider configrationProvider =
+ new ConfigrationProviderImpl(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]));
+
+ final ConcurrentContextMetrics concurrentContextMetrics = new ConcurrentContextMetrics(configrationProvider,
+ args[ARG_ZOOKEEPER_ADDRESS], Integer.valueOf(args[ARG_ZOOKEEPER_PORT]), args[ARG_ZOOKEEPER_DIRECTORY]);
concurrentContextMetrics.concurrentContextMetricsJVMLocal();
concurrentContextMetrics.concurrentContextMetricsCurator();
@@ -119,30 +105,18 @@ public class ConcurrentContextMetrics {
/**
* 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
+ *
+ * @param configrationProvider
+ * @param zookeeperAddress
+ * @param zookeeperPort
+ * @param zookeeperDirectory
*/
- // 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;
+ public ConcurrentContextMetrics(final ConfigrationProvider configrationProvider, final String zookeeperAddress,
+ final int zookeeperPort, final String zookeeperDirectory) {
+ this.configrationProvider = configrationProvider;
this.zookeeperAddress = zookeeperAddress;
- this.interactive = interactive;
+ this.zookeeperPort = zookeeperPort;
+ this.zookeeperDirectory = new File(zookeeperDirectory);
}
/**
@@ -153,17 +127,15 @@ public class ConcurrentContextMetrics {
* @throws ApexException the apex exception
*/
private void concurrentContextMetricsJVMLocal() throws ApexModelException, IOException, ApexException {
- if (jvmCount != 1) {
+ if (configrationProvider.getJvmCount() != 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);
+ contextParameters.getDistributorParameters().setPluginClass(DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
+ contextParameters.getLockManagerParameters().setPluginClass(DEFAULT_LOCK_MANAGER_PLUGIN_CLASS);
runConcurrentContextMetrics("JVMLocal");
LOGGER.debug("Ran concurrentContextMetricsJVMLocalVarSet metrics");
@@ -172,22 +144,19 @@ public class ConcurrentContextMetrics {
/**
* 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) {
+ private void concurrentContextMetricsHazelcast() throws IOException, ApexException {
+ if (configrationProvider.getJvmCount() != 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");
+ contextParameters.getDistributorParameters().setPluginClass(DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
+ contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
runConcurrentContextMetrics("Hazelcast");
LOGGER.debug("Ran concurrentContextMetricsHazelcast metrics");
@@ -196,23 +165,21 @@ public class ConcurrentContextMetrics {
/**
* 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) {
+ private void concurrentContextMetricsCurator() throws IOException, ApexException {
+ if (configrationProvider.getJvmCount() != 1) {
return;
}
LOGGER.debug("Running concurrentContextMetricsCurator metrics . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
+ contextParameters.getDistributorParameters().setPluginClass(DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager");
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
contextParameters.setLockManagerParameters(curatorParameters);
curatorParameters.setZookeeperAddress(zookeeperAddress);
@@ -224,19 +191,16 @@ public class ConcurrentContextMetrics {
/**
* 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 {
+ private void concurrentContextMetricsHazelcastMultiJVMHazelcastLock() throws 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");
+ final DistributorParameters distributorParameters = contextParameters.getDistributorParameters();
+ distributorParameters.setPluginClass(HazelcastContextDistributor.class.getCanonicalName());
+ contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
runConcurrentContextMetrics("HazelcastMultiJVMHazelcastLock");
LOGGER.debug("Ran concurrentContextMetricsHazelcastMultiJVMHazelcastLock metrics");
@@ -245,19 +209,16 @@ public class ConcurrentContextMetrics {
/**
* 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 {
+ private void concurrentContextMetricsInfinispanMultiJVMHazelcastlock() throws 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 DistributorParameters distributorParameters = contextParameters.getDistributorParameters();
+ distributorParameters.setPluginClass(InfinispanContextDistributor.class.getCanonicalName());
+ contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters();
contextParameters.setDistributorParameters(infinispanParameters);
@@ -270,53 +231,67 @@ public class ConcurrentContextMetrics {
/**
* Concurrent context metrics infinispan multi JVM curator lock.
*
- * @throws ApexModelException the apex model exception
* @throws IOException the IO exception
* @throws ApexException the apex exception
+ * @throws InterruptedException
*/
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");
+ throws IOException, ApexException, InterruptedException {
- 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("Running concurrentContextMetricsInfinispanMultiJVMCuratorLock metrics . . .");
+ final ZooKeeperServerServiceProvider zooKeeperServerServiceProvider =
+ new ZooKeeperServerServiceProvider(zookeeperDirectory, zookeeperAddress, zookeeperPort);
+ try {
+ zooKeeperServerServiceProvider.startZookeeperServer();
+ final ContextParameters contextParameters = new ContextParameters();
+ final DistributorParameters distributorParameters = contextParameters.getDistributorParameters();
+ distributorParameters.setPluginClass(InfinispanContextDistributor.class.getCanonicalName());
+
+ final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
+ contextParameters.setLockManagerParameters(curatorParameters);
+ curatorParameters.setZookeeperAddress(zookeeperAddress);
+
+ final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters();
+ contextParameters.setDistributorParameters(infinispanParameters);
+
+ runConcurrentContextMetrics("InfinispanMultiJVMCuratorLock");
+ } finally {
+ zooKeeperServerServiceProvider.stopZookeeperServer();
+ }
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
+ * @throws InterruptedException
*/
private void concurrentContextMetricsHazelcastMultiJVMCuratorLock()
- throws ApexModelException, IOException, ApexException {
+ throws IOException, ApexException, InterruptedException {
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");
+ final ZooKeeperServerServiceProvider zooKeeperServerServiceProvider =
+ new ZooKeeperServerServiceProvider(zookeeperDirectory, zookeeperAddress, zookeeperPort);
+ try {
+ zooKeeperServerServiceProvider.startZookeeperServer();
+ final ContextParameters contextParameters = new ContextParameters();
+ final DistributorParameters distributorParameters = contextParameters.getDistributorParameters();
+ distributorParameters.setPluginClass(HazelcastContextDistributor.class.getCanonicalName());
+
+ final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
+ contextParameters.setLockManagerParameters(curatorParameters);
+ curatorParameters.setZookeeperAddress(zookeeperAddress);
+
+ runConcurrentContextMetrics("HazelcastMultiJVMCuratorLock");
+ } finally {
+ zooKeeperServerServiceProvider.stopZookeeperServer();
+ }
LOGGER.debug("Ran concurrentContextMetricsHazelcastMultiJVMCuratorLock metrics");
}
@@ -324,202 +299,24 @@ public class ConcurrentContextMetrics {
* 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 TestContextLongItem longItem = new TestContextLongItem();
- 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;
+ private void runConcurrentContextMetrics(final String testName) throws IOException, ApexException {
+ final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- try {
- for (int i = 0; i < longArraySize; i++) {
- total += ((TestContextLongItem) lTypeAlbum.get(Integer.toString(i))).getLongValue();
- }
+ LOGGER.info("Running {} ...", testName);
+ final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
- outMetricLine(testName, "Totaled");
- } catch (final Exception e) {
- e.printStackTrace();
+ long total = 0;
+ for (final Entry<String, TestContextLongItem> entry : result.entrySet()) {
+ LOGGER.trace("Album key: {}, value: {}", entry.getKey(), entry.getValue());
+ total += entry.getValue().getLongValue();
}
+ LOGGER.info("Album total value after execution: {}", total);
- 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");
- }
- }
+ LOGGER.info("Completed {} ...", testName);
}
- /**
- * 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/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java b/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java
deleted file mode 100644
index ed81e39a1..000000000
--- a/testsuites/performance/performance-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/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java b/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java
deleted file mode 100644
index 64bc0cab6..000000000
--- a/testsuites/performance/performance-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/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java b/testsuites/performance/performance-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java
deleted file mode 100644
index e207832c1..000000000
--- a/testsuites/performance/performance-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.TestContextLongItem;
-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 TestContextLongItem item = (TestContextLongItem) 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 TestContextLongItem item = (TestContextLongItem) 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 TestContextLongItem item = (TestContextLongItem) 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/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java b/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java
index 5607f8711..9f051eb82 100644
--- a/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java
+++ b/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java
@@ -22,36 +22,59 @@ package org.onap.policy.apex.plugins.context.metrics;
import static org.junit.Assert.fail;
+import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.TreeSet;
-import org.apache.curator.test.TestingServer;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.onap.policy.apex.context.test.utils.NetworkUtils;
+import org.onap.policy.apex.model.utilities.ResourceUtils;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
public class TestMetrics {
- // Zookeeper test server
- TestingServer zkTestServer;
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestMetrics.class);
+ private static final String HAZELCAST_CONFIG = "hazelcast.config";
- @Before
- public void beforeTest() throws Exception {
- zkTestServer = new TestingServer(62181);
- }
+ private static final String JAVA_NET_PREFER_IPV4_STACK = "java.net.preferIPv4Stack";
+ private static final String HAZELCAST_XML_FILE = "src/test/resources/hazelcast/hazelcast.xml";
+
+ @Rule
+ public final TemporaryFolder folder = new TemporaryFolder();
+
+ @BeforeClass
+ public static void configure() throws Exception {
+ System.setProperty(JAVA_NET_PREFER_IPV4_STACK, "true");
+ final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE);
+ System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation);
+
+ final TreeSet<String> ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses();
+
+ if (ipAddressSet.size() == 0) {
+ throw new Exception("cound not find real IP address for test");
+ }
+ LOGGER.info("For Infinispan, setting jgroups.tcp.address to: {}", ipAddressSet.first());
+ System.setProperty("jgroups.tcp.address", ipAddressSet.first());
- @After
- public void afterTest() throws IOException {
- zkTestServer.stop();
}
@Test
- public void getSingleJVMMetrics() {
- final String[] args = {"singleJVMTestNL", "1", "32", "1000", "65536", "0", "localhost:62181", "false"};
+ public void getSingleJVMMetrics() throws IOException {
+ final File zookeeperDirectory = folder.newFolder("zookeeperDirectory");
+ final String[] args = {"singleJVMTestNL", "1", "32", "1000", "65536", "0", "localhost", "62181",
+ zookeeperDirectory.getAbsolutePath()};
+ LOGGER.info("Starting with args: {}", Arrays.toString(args));
try {
ConcurrentContextMetrics.main(args);
- } catch (final Exception e) {
+ } catch (final Exception exception) {
+ LOGGER.error("Unexpected error", exception);
fail("Metrics test failed");
- e.printStackTrace();
}
}
}
diff --git a/testsuites/performance/performance-context-metrics/src/test/resources/hazelcast/hazelcast.xml b/testsuites/performance/performance-context-metrics/src/test/resources/hazelcast/hazelcast.xml
index 84da4951e..b70bdc36e 100644
--- a/testsuites/performance/performance-context-metrics/src/test/resources/hazelcast/hazelcast.xml
+++ b/testsuites/performance/performance-context-metrics/src/test/resources/hazelcast/hazelcast.xml
@@ -19,625 +19,45 @@
============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">
+<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>127.0.0.1</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>
+ <interface>127.0.0.*</interface>
+ </interfaces>
+ </network>
+ <properties>
+ <property name="hazelcast.icmp.enabled">false</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>
-
+ <property name="hazelcast.shutdownhook.enabled">false</property>
+ <property name="hazelcast.graceful.shutdown.max.wait">60</property>
+ <property name="hazelcast.operation.generic.thread.count">1</property>
+ <property name="hazelcast.operation.thread.count">1</property>
+ <property name="hazelcast.clientengine.thread.count">1</property>
+ <property name="hazelcast.client.event.thread.count">1</property>
+ <property name="hazelcast.event.thread.count">1</property>
+ <property name="hazelcast.io.output.thread.count">1</property>
+ <property name="hazelcast.io.thread.count">1</property>
+ <property name="hazelcast.executor.client.thread.count">1</property>
+ <property name="hazelcast.clientengine.thread.count">1</property>
+ </properties>
+ <executor-service>
+ <pool-size>2</pool-size>
+ </executor-service>
</hazelcast>
diff --git a/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/default-jgroups-tcp.xml b/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/default-jgroups-tcp.xml
new file mode 100644
index 000000000..028cf1df6
--- /dev/null
+++ b/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/default-jgroups-tcp.xml
@@ -0,0 +1,76 @@
+<?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=========================================================
+-->
+
+<config xmlns="urn:org:jgroups"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">
+ <TCP bind_addr="${jgroups.tcp.address:127.0.0.1}"
+ bind_port="${jgroups.tcp.port:7800}"
+ enable_diagnostics="false"
+ thread_naming_pattern="pl"
+ send_buf_size="640k"
+ sock_conn_timeout="300"
+ bundler_type="no-bundler"
+
+ thread_pool.min_threads="${jgroups.thread_pool.min_threads:0}"
+ thread_pool.max_threads="${jgroups.thread_pool.max_threads:200}"
+ thread_pool.keep_alive_time="60000"
+ />
+ <MPING bind_addr="${jgroups.tcp.address:127.0.0.1}"
+ mcast_addr="${jgroups.mping.mcast_addr:228.2.4.6}"
+ mcast_port="${jgroups.mping.mcast_port:43366}"
+ ip_ttl="${jgroups.udp.ip_ttl:2}"
+ />
+ <MERGE3 min_interval="10000"
+ max_interval="30000"
+ />
+ <FD_SOCK />
+ <FD_ALL timeout="60000"
+ interval="15000"
+ timeout_check_interval="5000"
+ />
+ <VERIFY_SUSPECT timeout="5000" />
+ <pbcast.NAKACK2 use_mcast_xmit="false"
+ xmit_interval="100"
+ xmit_table_num_rows="50"
+ xmit_table_msgs_per_row="1024"
+ xmit_table_max_compaction_time="30000"
+ resend_last_seqno="true"
+ />
+ <UNICAST3 xmit_interval="100"
+ xmit_table_num_rows="50"
+ xmit_table_msgs_per_row="1024"
+ xmit_table_max_compaction_time="30000"
+ conn_expiry_timeout="0"
+ />
+ <pbcast.STABLE stability_delay="500"
+ desired_avg_gossip="5000"
+ max_bytes="1M"
+ />
+ <pbcast.GMS print_local_addr="false"
+ install_view_locally_first="true"
+ join_timeout="${jgroups.join_timeout:5000}"
+ />
+ <MFC max_credits="2m"
+ min_threshold="0.40"
+ />
+ <FRAG3/>
+</config>
diff --git a/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml b/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml
index a8541333e..46722477a 100644
--- a/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml
+++ b/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml
@@ -23,7 +23,7 @@
<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" />
+ <stack-file name="external-file" path="infinispan/default-jgroups-tcp.xml" />
</jgroups>
<cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1">