summaryrefslogtreecommitdiffstats
path: root/services/services-engine
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-01-09 14:34:54 +0000
committerGerrit Code Review <gerrit@onap.org>2020-01-09 14:34:54 +0000
commiteaf16c2ca33c67752c71d1e23ebe1fe5f8cc23d7 (patch)
treeaf3a7e74a0c1235f7393e3b752768bf7fe8d5e75 /services/services-engine
parentb358f3bc90fd033044113aa306ac3f1a1de904ed (diff)
parentb2bb847016d780377ea4ff26b389885e9295e7ff (diff)
Merge "Populate the PdpStatistics data in heartbeat"
Diffstat (limited to 'services/services-engine')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java15
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java19
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManager.java175
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java25
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java19
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java23
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/engdep/DummyEngineService.java18
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java28
8 files changed, 297 insertions, 25 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
index 6c86c1eff..169f8154a 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.apex.service.engine.main;
import java.io.IOException;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Stream;
@@ -31,6 +32,7 @@ import lombok.Setter;
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.ModelService;
+import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.handling.PolicyModelMerger;
import org.onap.policy.apex.model.utilities.TextFileUtils;
@@ -266,6 +268,17 @@ public class ApexActivator {
}
/**
+ * Get the Apex engine worker stats.
+ */
+ public List<AxEngineModel> getEngineStats() {
+ List<AxEngineModel> engineStats = null;
+ if (apexEngineService != null) {
+ engineStats = apexEngineService.getEngineStats();
+ }
+ return engineStats;
+ }
+
+ /**
* Terminate the Apex engine.
*
* @throws ApexException on termination errors
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
index 14b57b2d1..cea70ce7a 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modification Copyright (C) 2019 Nordix Foundation.
+ * Modification Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ package org.onap.policy.apex.service.engine.main;
import java.util.Arrays;
import java.util.Base64;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
@@ -34,6 +35,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
+import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
@@ -258,8 +260,19 @@ public class ApexMain {
}
/**
- * The Class ApexMainShutdownHookClass terminates the Apex engine for the Apex service when its run method is
- * called.
+ * Get the Engine Stats.
+ */
+ public List<AxEngineModel> getEngineStats() {
+ List<AxEngineModel> engineStats = null;
+ if (activator != null) {
+ engineStats = activator.getEngineStats();
+ }
+ return engineStats;
+ }
+
+ /**
+ * The Class ApexMainShutdownHookClass terminates the Apex engine for the Apex service when its run
+ * method is called.
*/
private class ApexMainShutdownHookClass extends Thread {
/**
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManager.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManager.java
new file mode 100644
index 000000000..0200af37d
--- /dev/null
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManager.java
@@ -0,0 +1,175 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.service.engine.main;
+
+import java.util.concurrent.atomic.AtomicLong;
+import org.onap.policy.common.utils.services.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ApexPolicyStatisticsManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexPolicyStatisticsManager.class);
+ public static final String REG_APEX_PDP_POLICY_COUNTER = "object:pdp/statistics/policy/counter";
+ private final AtomicLong policyDeployCount = new AtomicLong(0);
+ private final AtomicLong policyDeploySuccessCount = new AtomicLong(0);
+ private final AtomicLong policyDeployFailCount = new AtomicLong(0);
+ private final AtomicLong policyExecutedCount = new AtomicLong(0);
+ private final AtomicLong policyExecutedSuccessCount = new AtomicLong(0);
+ private final AtomicLong policyExecutedFailCount = new AtomicLong(0);
+
+ /**
+ * Constructs the object.
+ */
+ public ApexPolicyStatisticsManager() {
+ super();
+ }
+
+ /**
+ * To get the ApexPolicyStatisticsManager in Registry.
+ *
+ * @return ApexPolicyStatisticsManager The obj in Registry.
+ */
+ public static ApexPolicyStatisticsManager getInstanceFromRegistry() {
+ ApexPolicyStatisticsManager instance = null;
+ try {
+ instance = Registry.get(ApexPolicyStatisticsManager.REG_APEX_PDP_POLICY_COUNTER);
+ } catch (IllegalArgumentException e) {
+ LOGGER.debug("ApexPolicyStatisticsManager is not registered yet");
+ }
+ return instance;
+ }
+
+
+ /**
+ * Update the policy deploy count.
+ */
+ public void updatePolicyDeployCounter(final boolean isSuccessful) {
+ this.updatepPolicyDeployCount();
+ if (!isSuccessful) {
+ this.updatePolicyDeployFailCount();
+ } else {
+ this.updatePolicyDeploySuccessCount();
+ }
+ }
+
+ /**
+ * Update the policy executed count.
+ */
+ public void updatePolicyExecutedCounter(final boolean isSuccessful) {
+ this.updatePolicyExecutedCount();
+ if (isSuccessful) {
+ this.updatePolicyExecutedSuccessCount();
+ } else {
+ this.updatePolicyExecutedFailCount();
+ }
+ }
+
+ /**
+ * Method to update the total policy deploy count.
+ *
+ * @return the updated value of policyDeployCount
+ */
+ private long updatepPolicyDeployCount() {
+ return policyDeployCount.incrementAndGet();
+ }
+
+ /**
+ * Method to update the total policy deploy failed count.
+ *
+ * @return the updated value of totalPolicyDeployCount
+ */
+ private long updatePolicyDeployFailCount() {
+ return policyDeployFailCount.incrementAndGet();
+ }
+
+ /**
+ * Method to update the policy deploy success count.
+ *
+ * @return the updated value of policyDeploySuccessCount
+ */
+ private long updatePolicyDeploySuccessCount() {
+ return policyDeploySuccessCount.incrementAndGet();
+ }
+
+
+ /**
+ * Method to update the total policy executed count.
+ *
+ * @return the updated value of policyExecutedCount
+ */
+ private long updatePolicyExecutedCount() {
+ return policyExecutedCount.incrementAndGet();
+ }
+
+ /**
+ * Method to update the policy executed success count.
+ *
+ * @return the updated value of policyExecutedSuccessCount
+ */
+ private long updatePolicyExecutedSuccessCount() {
+ return policyExecutedSuccessCount.incrementAndGet();
+ }
+
+ /**
+ * Method to update the policy executed failure count.
+ *
+ * @return the updated value of policyExecutedFailCount
+ */
+ private long updatePolicyExecutedFailCount() {
+ return policyExecutedFailCount.incrementAndGet();
+ }
+
+ /**
+ * Reset all the statistics counts to 0.
+ */
+ public void resetAllStatistics() {
+ policyDeployCount.set(0L);
+ policyDeployFailCount.set(0L);
+ policyDeploySuccessCount.set(0L);
+ policyExecutedCount.set(0L);
+ policyExecutedSuccessCount.set(0L);
+ policyExecutedFailCount.set(0L);
+ }
+
+ public long getPolicyDeployCount() {
+ return policyDeployCount.get();
+ }
+
+ public long getPolicyDeployFailCount() {
+ return policyDeployFailCount.get();
+ }
+
+ public long getPolicyDeploySuccessCount() {
+ return policyDeploySuccessCount.get();
+ }
+
+ public long getPolicyExecutedCount() {
+ return policyExecutedCount.get();
+ }
+
+ public long getPolicyExecutedSuccessCount() {
+ return policyExecutedSuccessCount.get();
+ }
+
+ public long getPolicyExecutedFailCount() {
+ return policyExecutedFailCount.get();
+ }
+}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java
index ef17a8eab..48595c5b0 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
@@ -21,9 +22,10 @@
package org.onap.policy.apex.service.engine.runtime;
import java.util.Collection;
-
+import java.util.List;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -154,7 +156,7 @@ public interface EngineService {
/**
* This method checks if all Apex engines in the engine service are started.
- *
+ *
* <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
* stopping
*
@@ -164,7 +166,7 @@ public interface EngineService {
/**
* This method checks if an Apex engine in the engine service is started.
- *
+ *
* <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
* stopping
*
@@ -175,7 +177,7 @@ public interface EngineService {
/**
* This method checks if all Apex engines in the engine service are stopped.
- *
+ *
* <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
* stopping
*
@@ -185,7 +187,7 @@ public interface EngineService {
/**
* This method checks if an Apex engine in the engine service is stopped.
- *
+ *
* <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
* stopping
*
@@ -219,6 +221,13 @@ public interface EngineService {
String getStatus(AxArtifactKey engineKey) throws ApexException;
/**
+ * Get the engine status information.
+ *
+ * @return the Apex status information
+ */
+ List<AxEngineModel> getEngineStats();
+
+ /**
* This method gets the runtime information of all Apex engines in the engine service.
*
* @param engineKey the engine key
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
index f5e36e864..a558b9946 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,11 @@
package org.onap.policy.apex.service.engine.runtime.impl;
import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.BlockingQueue;
@@ -37,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
+import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.service.engine.event.ApexEvent;
@@ -704,13 +707,25 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
LOGGER.warn(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX);
throw new ApexException(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX);
}
-
// Return the information for this worker
return engineWorkerMap.get(engineKey).getStatus(engineKey);
}
/**
* {@inheritDoc}.
+ *
+ */
+ @Override
+ public List<AxEngineModel> getEngineStats() {
+ List<AxEngineModel> engineStats = new ArrayList<>();
+ for (final EngineService engine : engineWorkerMap.values()) {
+ engineStats.addAll(engine.getEngineStats());
+ }
+ return engineStats;
+ }
+
+ /**
+ * {@inheritDoc}.
*/
@Override
public String getRuntimeInfo(final AxArtifactKey engineKey) throws ApexException {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
index e00515bd0..5b5c7f49b 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,8 +27,10 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.BlockingQueue;
@@ -54,6 +56,7 @@ import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.impl.enevent.ApexEvent2EnEventConverter;
+import org.onap.policy.apex.service.engine.main.ApexPolicyStatisticsManager;
import org.onap.policy.apex.service.engine.runtime.ApexEventListener;
import org.onap.policy.apex.service.engine.runtime.EngineService;
import org.onap.policy.apex.service.engine.runtime.EngineServiceEventInterface;
@@ -465,6 +468,16 @@ final class EngineWorker implements EngineService {
* {@inheritDoc}.
*/
@Override
+ public List<AxEngineModel> getEngineStats() {
+ List<AxEngineModel> engineStats = new ArrayList<>();
+ engineStats.add(engine.getEngineStatus());
+ return engineStats;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
public String getRuntimeInfo(final AxArtifactKey engineKey) {
// We'll build up the JSON string for runtime information bit by bit
final StringBuilder runtimeJsonStringBuilder = new StringBuilder();
@@ -594,13 +607,13 @@ final class EngineWorker implements EngineService {
LOGGER.debug("Engine {} processing interrupted ", engineWorkerKey);
break;
}
-
+ boolean executedResult = false;
try {
if (event != null) {
debugEventIfDebugEnabled(event);
final EnEvent enevent = apexEnEventConverter.fromApexEvent(event);
- engine.handleEvent(enevent);
+ executedResult = engine.handleEvent(enevent);
}
} catch (final ApexException e) {
LOGGER.warn("Engine {} failed to process event {}", engineWorkerKey, event.toString(), e);
@@ -608,6 +621,10 @@ final class EngineWorker implements EngineService {
LOGGER.warn("Engine {} terminated processing event {}", engineWorkerKey, event.toString(), e);
stopFlag = true;
}
+ ApexPolicyStatisticsManager apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ if (!stopFlag && apexPolicyCounter != null) {
+ apexPolicyCounter.updatePolicyExecutedCounter(executedResult);
+ }
}
LOGGER.debug("Engine {} completed processing", engineWorkerKey);
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/engdep/DummyEngineService.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/engdep/DummyEngineService.java
index ef54e8e0e..f917fcf48 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/engdep/DummyEngineService.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/engdep/DummyEngineService.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
@@ -27,6 +28,7 @@ import java.util.List;
import org.apache.commons.lang3.NotImplementedException;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.service.engine.runtime.ApexEventListener;
@@ -94,7 +96,7 @@ public class DummyEngineService implements EngineService {
@Override
public AxArtifactKey getApexModelKey() {
modelKeyGetCalled++;
-
+
return new AxArtifactKey("DummyApexModelKey:0.0.1");
}
@@ -128,6 +130,14 @@ public class DummyEngineService implements EngineService {
* {@inheritDoc}.
*/
@Override
+ public List<AxEngineModel> getEngineStats() {
+ throw new NotImplementedException("Not implemented on dummy class");
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
public void startAll() throws ApexException {
throw new NotImplementedException("Not implemented on dummy class");
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
index a6040d969..dee58b8e9 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
@@ -55,7 +56,9 @@ import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.utilities.TextFileUtils;
import org.onap.policy.apex.service.engine.event.ApexEvent;
+import org.onap.policy.apex.service.engine.main.ApexPolicyStatisticsManager;
import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.utils.services.Registry;
/**
* Test the engine worker class.
@@ -69,7 +72,7 @@ public class EngineWorkerTest {
/**
* Read the models into strings.
- *
+ *
* @throws IOException on model reading errors
* @throws ApexModelException on model reading exceptions
*/
@@ -129,6 +132,7 @@ public class EngineWorkerTest {
"org.onap.policy.apex.service.engine.runtime.impl.DummySfe");
engineParameters.getExecutorParameterMap().put("MVEL", jsExecutorParameters);
ParameterService.register(engineParameters);
+
}
/**
@@ -151,6 +155,7 @@ public class EngineWorkerTest {
@Test
public void testEngineWorker() {
+
BlockingQueue<ApexEvent> eventQueue = new LinkedBlockingQueue<>();
EngineWorker worker = new EngineWorker(new AxArtifactKey("Worker", "0.0.1"), eventQueue, atFactory);
@@ -330,6 +335,8 @@ public class EngineWorkerTest {
@Test
public void testApexImplModelWIthModel() throws ApexException {
+ Registry.newRegistry();
+ Registry.register(ApexPolicyStatisticsManager.REG_APEX_PDP_POLICY_COUNTER, new ApexPolicyStatisticsManager());
BlockingQueue<ApexEvent> eventQueue = new LinkedBlockingQueue<>();
EngineWorker worker = new EngineWorker(new AxArtifactKey("Worker", "0.0.1"), eventQueue, atFactory);
@@ -444,5 +451,18 @@ public class EngineWorkerTest {
}
assertNotNull(worker.getApexModelKey());
+
+ final ApexPolicyStatisticsManager policyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ assertNotNull(policyCounter);
+ assertEquals(policyCounter.getPolicyExecutedCount(),
+ policyCounter.getPolicyExecutedFailCount() + policyCounter.getPolicyExecutedSuccessCount());
+ policyCounter.resetAllStatistics();
+ assertEquals(0, policyCounter.getPolicyExecutedCount());
+ assertEquals(0, policyCounter.getPolicyExecutedFailCount());
+ assertEquals(0, policyCounter.getPolicyExecutedSuccessCount());
+ assertEquals(0, policyCounter.getPolicyDeployCount());
+ assertEquals(0, policyCounter.getPolicyDeployFailCount());
+ assertEquals(0, policyCounter.getPolicyDeploySuccessCount());
+
}
}