summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2023-08-28 17:32:18 +0100
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2023-08-28 17:32:18 +0100
commitd6f6ebc925506cdf18b903df2cd3cbcef311082d (patch)
treeeda1d495b15f2df896f4f81cbb0e4f1ab7c6f1a3
parentc05015ae25604825d9a1d951e3a2d0981b955eae (diff)
Remove pdp statistics implementations from drools-pdp
Issue-ID: POLICY-4109 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I9fd807e4df5392cef680202ad80c7cc269d7b349
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java63
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java10
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java59
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java27
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java1
-rw-r--r--policy-management/pom.xml1
-rw-r--r--policy-management/src/main/resources/openapi/openapi.yaml62
-rw-r--r--policy-management/src/main/resources/swagger/swagger.json88
8 files changed, 0 insertions, 311 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 4ded8dc9..c946f3b2 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -61,7 +61,6 @@ import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
@@ -164,9 +163,6 @@ public class LifecycleFsm implements Startable {
@Getter
protected final Map<ToscaConceptIdentifier, ToscaPolicy> policiesMap = new HashMap<>();
- @Getter
- protected final PdpStatistics stats = new PdpStatistics();
-
/**
* Constructor.
*/
@@ -206,7 +202,6 @@ public class LifecycleFsm implements Startable {
public String getPdpName() {
if (this.pdpName == null) {
this.pdpName = PolicyEngineConstants.getManager().getPdpName();
- this.stats.setPdpInstanceId(pdpName);
}
return this.pdpName;
@@ -224,7 +219,6 @@ public class LifecycleFsm implements Startable {
*/
public synchronized void setGroup(String group) {
this.group = group;
- this.stats.setPdpGroupName(group);
}
/**
@@ -232,7 +226,6 @@ public class LifecycleFsm implements Startable {
*/
public synchronized void setSubGroup(String subGroup) {
this.subGroup = subGroup;
- this.stats.setPdpSubGroupName(subGroup);
}
/* ** FSM events - entry points of events into the FSM ** */
@@ -240,7 +233,6 @@ public class LifecycleFsm implements Startable {
@Override
public synchronized boolean start() {
this.pdpName = PolicyEngineConstants.getManager().getPdpName();
- stats.setPdpInstanceId(pdpName);
logger.info("lifecycle event: start engine");
return state.start();
}
@@ -462,8 +454,6 @@ public class LifecycleFsm implements Startable {
deploymentsCounter.labels(state.state().name(),
PrometheusUtils.DEPLOY_OPERATION,
PdpResponseStatus.SUCCESS.name()).inc();
- getStats().setPolicyDeployCount(getStats().getPolicyDeployCount() + 1);
- getStats().setPolicyDeploySuccessCount(getStats().getPolicyDeploySuccessCount() + 1);
return policy;
});
}
@@ -475,8 +465,6 @@ public class LifecycleFsm implements Startable {
deploymentsCounter.labels(state.state().name(),
PrometheusUtils.UNDEPLOY_OPERATION,
PdpResponseStatus.SUCCESS.name()).inc();
- getStats().setPolicyUndeployCount(getStats().getPolicyUndeployCount() + 1);
- getStats().setPolicyUndeploySuccessCount(getStats().getPolicyUndeploySuccessCount() + 1);
return null;
});
}
@@ -485,52 +473,16 @@ public class LifecycleFsm implements Startable {
deploymentsCounter.labels(state.state().name(),
PrometheusUtils.DEPLOY_OPERATION,
PdpResponseStatus.FAIL.name()).inc();
- getStats().setPolicyDeployCount(getStats().getPolicyDeployCount() + 1);
- getStats().setPolicyDeployFailCount(getStats().getPolicyDeployFailCount() + 1);
}
protected void failedUndeployPolicyAction(ToscaPolicy failedPolicy) {
deploymentsCounter.labels(state.state().name(),
PrometheusUtils.UNDEPLOY_OPERATION,
PdpResponseStatus.FAIL.name()).inc();
- getStats().setPolicyUndeployCount(getStats().getPolicyUndeployCount() + 1);
- getStats().setPolicyUndeployFailCount(getStats().getPolicyUndeployFailCount() + 1);
policiesMap.remove(failedPolicy.getIdentifier());
}
- protected void updateDeployCountsAction(Long deployCount, Long deploySuccesses, Long deployFailures) {
- PdpStatistics statistics = getStats();
- if (deployCount != null) {
- statistics.setPolicyDeployCount(deployCount);
- }
-
- if (deploySuccesses != null) {
- statistics.setPolicyDeploySuccessCount(deploySuccesses);
- }
-
- if (deployFailures != null) {
- statistics.setPolicyDeployFailCount(deployFailures);
- }
- }
-
- protected void updateUndeployCountsAction(Long undeployCount, Long undeploySuccesses, Long undeployFailures) {
- PdpStatistics statistics = getStats();
- if (undeployCount != null) {
- statistics.setPolicyUndeployCount(undeployCount);
- }
-
- if (undeploySuccesses != null) {
- statistics.setPolicyUndeploySuccessCount(undeploySuccesses);
- }
-
- if (undeployFailures != null) {
- statistics.setPolicyUndeployFailCount(undeployFailures);
- }
- }
-
protected List<ToscaPolicy> resetPoliciesAction() {
- updateDeployCountsAction(0L, 0L, 0L);
- updateUndeployCountsAction(0L, 0L, 0L);
List<ToscaPolicy> policies = new ArrayList<>(getActivePolicies());
policiesMap.clear();
return policies;
@@ -671,21 +623,6 @@ public class LifecycleFsm implements Startable {
return status;
}
- /**
- * It provides a snapshot of the current statistics.
- */
- public PdpStatistics statisticsPayload() {
- var updateStats = new PdpStatistics(stats);
- updateStats.setTimeStamp(Instant.now());
-
- try {
- BeanUtils.copyProperties(updateStats, PolicyEngineConstants.getManager().getStats().getGroupStat());
- } catch (IllegalAccessException | InvocationTargetException ex) {
- logger.debug("statistics mapping failure", ex);
- }
-
- return updateStats;
- }
private boolean source() {
List<TopicSource> sources = TopicEndpointManager.getManager().addTopicSources(properties);
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
index 7282a59b..cad980f5 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
@@ -375,16 +375,6 @@ public class RestLifecycleManager implements LifecycleApi {
return Response.status(Response.Status.OK).entity(Collections.emptyList()).build();
}
- /**
- * Get current counts.
- */
-
- @Override
- @GET
- @Path("statistics")
- public Response stats() {
- return Response.status(Response.Status.OK).entity(LifecycleFeature.getFsm().statisticsPayload()).build();
- }
private Response deployUndeployOperation(String policy, boolean deploy) {
var toscaPolicy = getToscaPolicy(policy);
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
index ff8b1042..c08ac9fe 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
@@ -189,14 +189,12 @@ public class LifecycleFsmTest {
public void testSetGroup() {
fsm.setGroup("bar");
assertEquals("bar", fsm.getGroup());
- assertEquals("bar", fsm.getStats().getPdpGroupName());
}
@Test
public void testSetSubGroup() {
fsm.setSubGroup("foo");
assertEquals("foo", fsm.getSubGroup());
- assertEquals("foo", fsm.getStats().getPdpSubGroupName());
}
@Test
@@ -204,31 +202,6 @@ public class LifecycleFsmTest {
assertEquals("foo", fsm.getPdpType());
}
- @Test
- public void testDeployedPolicyAction() {
- fsm.deployedPolicyAction(controllerPolicy);
- assertEquals(1, fsm.getStats().getPolicyDeploySuccessCount());
-
- fsm.undeployedPolicyAction(controllerPolicy);
- assertEquals(1, fsm.getStats().getPolicyDeploySuccessCount());
- assertEquals(1, fsm.getStats().getPolicyUndeploySuccessCount());
-
- fsm.resetPoliciesAction();
- assertEquals(0, fsm.getStats().getPolicyUndeployCount());
- assertEquals(0, fsm.getStats().getPolicyUndeploySuccessCount());
- }
-
- @Test
- public void testRestDeployCountsAction() {
- deployAllPolicies();
- assertEquals(8, fsm.getStats().getPolicyDeploySuccessCount());
- assertEquals(0, fsm.getStats().getPolicyUndeployCount());
-
- fsm.resetPoliciesAction();
- assertEquals(0, fsm.getStats().getPolicyDeploySuccessCount());
- assertEquals(0, fsm.getStats().getPolicyDeployFailCount());
- assertEquals(0, fsm.getStats().getPolicyDeployCount());
- }
@Test
public void testMergePolicies() {
@@ -262,38 +235,6 @@ public class LifecycleFsmTest {
fsm.getPolicyIds(List.of(opPolicy, controllerPolicy)).toString());
}
- @Test
- public void testUpdateCountsAction() {
- fsm.resetPoliciesAction();
-
- assertDeployUndeployValues(0, 0, 0, 0, 0, 0);
-
- fsm.updateDeployCountsAction(3L, 2L, 1L);
- assertDeployUndeployValues(3, 2, 1, 0, 0, 0);
-
- fsm.updateUndeployCountsAction(1L, 1L, 0L);
- assertDeployUndeployValues(3, 2, 1, 1, 1, 0);
-
- // shouldn't update values
- fsm.updateDeployCountsAction(null, null, null);
- fsm.updateUndeployCountsAction(null, null, null);
-
- assertDeployUndeployValues(3, 2, 1, 1, 1, 0);
- fsm.resetPoliciesAction();
-
- assertDeployUndeployValues(0, 0, 0, 0, 0, 0);
- }
-
- protected void assertDeployUndeployValues(long deployCount, long deploySuccess, long deployFail,
- long undeployCount, long undeploySuccess, long undeployFail) {
- assertEquals(deployCount, fsm.getStats().getPolicyDeployCount());
- assertEquals(deploySuccess, fsm.getStats().getPolicyDeploySuccessCount());
- assertEquals(deployFail, fsm.getStats().getPolicyDeployFailCount());
- assertEquals(undeployCount, fsm.getStats().getPolicyUndeployCount());
- assertEquals(undeploySuccess, fsm.getStats().getPolicyUndeploySuccessCount());
- assertEquals(undeployFail, fsm.getStats().getPolicyUndeployFailCount());
- }
-
protected void deployAllPolicies() {
fsm.deployedPolicyAction(controllerPolicy);
fsm.deployedPolicyAction(controller2Policy);
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
index 5d56143d..90c0d94c 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
@@ -258,7 +258,6 @@ public class LifecycleFsmUpdateTest {
assertTrue(fsm.update(getPdpUpdate(List.of(), List.of(artifactPolicy))));
assertEquals(1, PolicyControllerConstants.getFactory().inventory().size());
assertFalse(PolicyControllerConstants.getFactory().get("lifecycle").getDrools().isBrained());
- verifyUndeployStats(5, 5, 0);
// Delta: +artifactPolicy
// from deltas, all delta updates should be successfully applied
@@ -270,7 +269,6 @@ public class LifecycleFsmUpdateTest {
// from deltas, all delta updates should be successfully applied
assertTrue(fsm.update(getPdpUpdate(List.of(), List.of(controllerPolicy))));
assertEquals(0, PolicyControllerConstants.getFactory().inventory().size());
- verifyUndeployStats(6, 6, 0);
// Delta: +controllerPolicy
// from deltas, all delta updates should be successfully applied
@@ -333,8 +331,6 @@ public class LifecycleFsmUpdateTest {
verifyActivePoliciesWithDisables(
List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy),
List.of(opPolicy.getIdentifier(), op2Policy.getIdentifier()));
- verifyDeployStats(17, 16, 1);
- verifyUndeployStats(10, 10, 0);
// Delta: -opPolicy, -op2Policy, -controller2Policy, -valPolicy, -artifact2Policy, -unvalPolicy
// from deltas, -opPolicy and -op2Policy undeploys will fail since there is not controller with that
@@ -346,7 +342,6 @@ public class LifecycleFsmUpdateTest {
assertEquals(0, PolicyControllerConstants.getFactory().inventory().size());
verifyDeploy(List.of(), 17, 16, 1, 16, 14, 2);
- verifyFullStats(33, 30, 3);
fsm.shutdown();
}
@@ -354,7 +349,6 @@ public class LifecycleFsmUpdateTest {
assertEquals(0, fsm.getPoliciesMap().size());
assertEquals("ACTIVE", fsm.state().toString());
assertEquals(0, PolicyControllerConstants.getFactory().inventory().size());
- verifyDeployStats(0, 0, 0);
}
protected PdpUpdate getPdpUpdate(List<ToscaPolicy> policiesToDeploy, List<ToscaPolicy> policiesToUndeploy) {
@@ -377,8 +371,6 @@ public class LifecycleFsmUpdateTest {
private void verifyDeploy(List<ToscaPolicy> active, long deployCount, long deploySuccess, long deployFail,
long undeployCount, long undeploySuccess, long undeployFail) throws CoderException {
verifyActivePolicies(active);
- verifyDeployStats(deployCount, deploySuccess, deployFail);
- verifyUndeployStats(undeployCount, undeploySuccess, undeployFail);
}
protected void verifyExists(boolean exists, String controller, List<ToscaPolicy> policies) {
@@ -533,25 +525,6 @@ public class LifecycleFsmUpdateTest {
candidateNativeArtifactPolicies.isEmpty());
}
- protected void verifyDeployStats(long count, long success, long fail) {
- assertEquals(count, fsm.getStats().getPolicyDeployCount());
- assertEquals(success, fsm.getStats().getPolicyDeploySuccessCount());
- assertEquals(fail, fsm.getStats().getPolicyDeployFailCount());
- }
-
- protected void verifyUndeployStats(long count, long success, long fail) {
- assertEquals(count, fsm.getStats().getPolicyUndeployCount());
- assertEquals(success, fsm.getStats().getPolicyUndeploySuccessCount());
- assertEquals(fail, fsm.getStats().getPolicyUndeployFailCount());
- }
-
- protected void verifyFullStats(long count, long success, long fail) {
- assertEquals(count, fsm.getStats().getPolicyDeployCount() + fsm.getStats().getPolicyUndeployCount());
- assertEquals(success,
- fsm.getStats().getPolicyDeploySuccessCount() + fsm.getStats().getPolicyUndeploySuccessCount());
- assertEquals(fail, fsm.getStats().getPolicyDeployFailCount() + fsm.getStats().getPolicyUndeployFailCount());
- }
-
protected List<NativeArtifactPolicy> getNativeArtifactPoliciesBut(List<ToscaPolicy> nativePolicies,
String controllerName) {
return nativePolicies.stream().map(nativePolicy -> {
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
index 7fcf1e5a..85294306 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
@@ -245,7 +245,6 @@ public class RestLifecycleManagerTest {
resourceLists("policies", 2);
get("policies/example.controller/1.0.0", Status.OK.getStatusCode());
get("policies/example.artifact/1.0.0", Status.OK.getStatusCode());
- get("statistics", Status.OK.getStatusCode());
/* add tosca compliant operational policy */
diff --git a/policy-management/pom.xml b/policy-management/pom.xml
index 5f605553..64e9f6b4 100644
--- a/policy-management/pom.xml
+++ b/policy-management/pom.xml
@@ -167,7 +167,6 @@
ControllerConfiguration=org.onap.policy.drools.protocol.configuration.ControllerConfiguration,
DroolsController=org.onap.policy.drools.controller.DroolsController,
JsonProtocolFilter=org.onap.policy.drools.protocol.coders.JsonProtocolFilter,
- PdpStatistics=org.onap.policy.models.pdp.concepts.PdpStatistics,
PdpdConfiguration=org.onap.policy.drools.protocol.configuration.PdpdConfiguration,
PolicyController=org.onap.policy.drools.system.PolicyController,
PolicyControllerFeatureApi=org.onap.policy.drools.features.PolicyControllerFeatureApi,
diff --git a/policy-management/src/main/resources/openapi/openapi.yaml b/policy-management/src/main/resources/openapi/openapi.yaml
index 612ad10e..a763150b 100644
--- a/policy-management/src/main/resources/openapi/openapi.yaml
+++ b/policy-management/src/main/resources/openapi/openapi.yaml
@@ -465,22 +465,6 @@ paths:
application/yaml:
schema:
$ref: '#/components/schemas/Response'
- /lifecycle/statistics:
- get:
- tags:
- - pdp-d-lifecycle
- summary: Gets Policy Statistics
- operationId: stats
- responses:
- 200:
- description: successful operation
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Response'
- application/yaml:
- schema:
- $ref: '#/components/schemas/Response'
/lifecycle/properties:
get:
tags:
@@ -3006,52 +2990,6 @@ components:
lastStart:
type: integer
format: int64
- PdpStatistics:
- type: object
- properties:
- pdpInstanceId:
- type: string
- timeStamp:
- type: integer
- format: int64
- generatedId:
- type: integer
- format: int64
- pdpGroupName:
- type: string
- pdpSubGroupName:
- type: string
- policyExecutedCount:
- type: integer
- format: int64
- policyExecutedSuccessCount:
- type: integer
- format: int64
- policyExecutedFailCount:
- type: integer
- format: int64
- policyDeployCount:
- type: integer
- format: int64
- policyDeploySuccessCount:
- type: integer
- format: int64
- policyDeployFailCount:
- type: integer
- format: int64
- policyUndeployCount:
- type: integer
- format: int64
- policyUndeploySuccessCount:
- type: integer
- format: int64
- policyUndeployFailCount:
- type: integer
- format: int64
- engineStats:
- type: array
- items:
- $ref: '#/components/schemas/PdpEngineWorkerStatistics'
TopicSource:
type: object
properties:
diff --git a/policy-management/src/main/resources/swagger/swagger.json b/policy-management/src/main/resources/swagger/swagger.json
index 1a6a7c17..f26a1bfe 100644
--- a/policy-management/src/main/resources/swagger/swagger.json
+++ b/policy-management/src/main/resources/swagger/swagger.json
@@ -672,30 +672,6 @@
}
}
},
- "/lifecycle/statistics" : {
- "get" : {
- "tags" : [ "pdp-d-lifecycle" ],
- "summary" : "Gets Policy Statistics",
- "operationId" : "stats",
- "responses" : {
- "200" : {
- "description" : "successful operation",
- "content" : {
- "application/json" : {
- "schema" : {
- "$ref" : "#/components/schemas/Response"
- }
- },
- "application/yaml" : {
- "schema" : {
- "$ref" : "#/components/schemas/Response"
- }
- }
- }
- }
- }
- }
- },
"/lifecycle/properties" : {
"get" : {
"tags" : [ "pdp-d-lifecycle" ],
@@ -4300,70 +4276,6 @@
}
}
},
- "PdpStatistics" : {
- "type" : "object",
- "properties" : {
- "pdpInstanceId" : {
- "type" : "string"
- },
- "timeStamp" : {
- "type" : "integer",
- "format" : "int64"
- },
- "generatedId" : {
- "type" : "integer",
- "format" : "int64"
- },
- "pdpGroupName" : {
- "type" : "string"
- },
- "pdpSubGroupName" : {
- "type" : "string"
- },
- "policyExecutedCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "policyExecutedSuccessCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "policyExecutedFailCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "policyDeployCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "policyDeploySuccessCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "policyDeployFailCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "policyUndeployCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "policyUndeploySuccessCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "policyUndeployFailCount" : {
- "type" : "integer",
- "format" : "int64"
- },
- "engineStats" : {
- "type" : "array",
- "items" : {
- "$ref" : "#/components/schemas/PdpEngineWorkerStatistics"
- }
- }
- }
- },
"TopicSource" : {
"type" : "object",
"properties" : {