aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-onappf/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-27 14:49:41 -0400
committerJim Hahn <jrh3@att.com>2021-08-27 15:48:46 -0400
commit9d8894092ced589c0bdc5b9e85ee1bf1c85d3e36 (patch)
tree88ff5f3891e8780cf8386bb46283dec82c0b3897 /services/services-onappf/src
parent18c8028c79d1bdd7bca80fe1e22e2cd9bc072695 (diff)
Address more sonars in apex-pdp
Fixed services-engine thru utilities. Fixed: - use "var" - use Files.delete() - only one method call in assert() Issue-ID: POLICY-3093 Change-Id: I6f62108c770c15e8b84bc51746066fefa409e0fc Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'services/services-onappf/src')
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java10
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java6
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java2
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java19
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java17
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java17
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java26
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java2
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java2
9 files changed, 52 insertions, 49 deletions
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
index 2993bbe07..a4cd8a004 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
@@ -109,9 +109,9 @@ public class ApexStarterActivator {
throw new ApexStarterRunTimeException(e);
}
- final PdpUpdateListener pdpUpdateListener = new PdpUpdateListener();
- final PdpStateChangeListener pdpStateChangeListener = new PdpStateChangeListener();
- final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler();
+ final var pdpUpdateListener = new PdpUpdateListener();
+ final var pdpStateChangeListener = new PdpStateChangeListener();
+ final var pdpMessageHandler = new PdpMessageHandler();
supportedPolicyTypes =
pdpMessageHandler.getSupportedPolicyTypesFromParameters(apexStarterParameterGroup.getPdpStatusParameters());
@@ -160,7 +160,7 @@ public class ApexStarterActivator {
* Method to stop and unregister the pdp status publisher.
*/
private void stopAndRemovePdpStatusPublisher() {
- final PdpStatusPublisher pdpStatusPublisher =
+ final var pdpStatusPublisher =
Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
pdpStatusPublisher.terminate();
Registry.unregister(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
@@ -196,7 +196,7 @@ public class ApexStarterActivator {
throw new IllegalStateException("activator is not running");
}
try {
- final PdpStatusPublisher pdpStatusPublisher =
+ final var pdpStatusPublisher =
Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
// send a final heartbeat with terminated status
pdpStatusPublisher.send(new PdpMessageHandler().getTerminatedPdpStatus());
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
index 2976f8260..7912d377f 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
@@ -54,11 +54,11 @@ public class ApexStarterMain {
* @param args the command line arguments
*/
public ApexStarterMain(final String[] args) {
- final String params = Arrays.toString(args);
+ final var params = Arrays.toString(args);
LOGGER.info("In ApexStarter with parameters {}", params);
// Check the arguments
- final ApexStarterCommandLineArguments arguments = new ApexStarterCommandLineArguments();
+ final var arguments = new ApexStarterCommandLineArguments();
try {
// The arguments return a string if there is a message to print and we should exit
final String argumentMessage = arguments.parse(args);
@@ -90,7 +90,7 @@ public class ApexStarterMain {
// Add a shutdown hook to shut everything down in an orderly manner
Runtime.getRuntime().addShutdownHook(new ApexStarterShutdownHookClass());
- String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_APEX_PDP);
+ var successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_APEX_PDP);
LOGGER.info(successMsg);
}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
index dcd368371..499a0280a 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
@@ -61,7 +61,7 @@ public class PdpStatusPublisher extends TimerTask {
@Override
public void run() {
- final PdpStatus pdpStatus = new PdpMessageHandler().createPdpStatusFromContext();
+ final var pdpStatus = new PdpMessageHandler().createPdpStatusFromContext();
topicSinkClient.send(pdpStatus);
LOGGER.debug("Sent heartbeat to PAP - {}", pdpStatus);
}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
index 7aa663c58..b676450a3 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -31,7 +32,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.TaskParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -103,7 +103,7 @@ public class ApexEngineHandler {
policiesToUnDeploy.removeIf(p -> !runningPolicies.contains(p));
Map<ToscaConceptIdentifier, ApexMain> undeployedPoliciesMainMap = new LinkedHashMap<>();
policiesToUnDeploy.forEach(policyId -> {
- ApexMain apexMain = apexMainMap.get(policyId);
+ var apexMain = apexMainMap.get(policyId);
try {
apexMain.shutdown();
undeployedPoliciesMainMap.put(policyId, apexMain);
@@ -183,7 +183,7 @@ public class ApexEngineHandler {
.stream().filter(key -> !outputParamKeysToRetain.contains(key)).collect(Collectors.toList());
eventInputParamKeysToRemove.forEach(existingParameters.getEventInputParameters()::remove);
eventOutputParamKeysToRemove.forEach(existingParameters.getEventOutputParameters()::remove);
- EngineParameters engineParameters = main.getApexParameters().getEngineServiceParameters().getEngineParameters();
+ var engineParameters = main.getApexParameters().getEngineServiceParameters().getEngineParameters();
final List<TaskParameters> taskParametersToRemove = engineParameters.getTaskParameters().stream()
.filter(taskParameter -> !taskParametersToRetain.contains(taskParameter)).collect(Collectors.toList());
final List<String> executorParamKeysToRemove = engineParameters.getExecutorParameterMap().keySet().stream()
@@ -191,8 +191,7 @@ public class ApexEngineHandler {
final List<String> schemaParamKeysToRemove =
engineParameters.getContextParameters().getSchemaParameters().getSchemaHelperParameterMap().keySet()
.stream().filter(key -> !schemaParamKeysToRetain.contains(key)).collect(Collectors.toList());
- EngineParameters aggregatedEngineParameters =
- existingParameters.getEngineServiceParameters().getEngineParameters();
+ var aggregatedEngineParameters = existingParameters.getEngineServiceParameters().getEngineParameters();
aggregatedEngineParameters.getTaskParameters().removeAll(taskParametersToRemove);
executorParamKeysToRemove.forEach(aggregatedEngineParameters.getExecutorParameterMap()::remove);
schemaParamKeysToRemove.forEach(aggregatedEngineParameters.getContextParameters().getSchemaParameters()
@@ -248,9 +247,9 @@ public class ApexEngineHandler {
Map<ToscaConceptIdentifier, ApexMain> failedPoliciesMainMap = new LinkedHashMap<>();
for (ToscaPolicy policy : policies) {
String policyName = policy.getIdentifier().getName();
- final StandardCoder standardCoder = new StandardCoder();
- ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
- ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate();
+ final var standardCoder = new StandardCoder();
+ var toscaServiceTemplate = new ToscaServiceTemplate();
+ var toscaTopologyTemplate = new ToscaTopologyTemplate();
toscaTopologyTemplate.setPolicies(List.of(Map.of(policyName, policy)));
toscaServiceTemplate.setToscaTopologyTemplate(toscaTopologyTemplate);
File file;
@@ -260,9 +259,9 @@ public class ApexEngineHandler {
} catch (CoderException | IOException e) {
throw new ApexStarterException(e);
}
- final String[] apexArgs = {"-p", file.getAbsolutePath()};
+ final var apexArgs = new String[] {"-p", file.getAbsolutePath()};
LOGGER.info("Starting apex engine for policy {}", policy.getIdentifier());
- ApexMain apexMain = new ApexMain(apexArgs);
+ var apexMain = new ApexMain(apexArgs);
if (apexMain.isAlive()) {
apexMainMap.put(policy.getIdentifier(), apexMain);
} else {
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
index 134b45c14..97feba152 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -63,7 +64,7 @@ public class PdpMessageHandler {
*/
public PdpStatus createPdpStatusFromParameters(final String instanceId,
final PdpStatusParameters pdpStatusParameters) {
- final PdpStatus pdpStatus = new PdpStatus();
+ final var pdpStatus = new PdpStatus();
pdpStatus.setPdpGroup(pdpStatusParameters.getPdpGroup());
pdpStatus.setPdpType(pdpStatusParameters.getPdpType());
pdpStatus.setState(PdpState.PASSIVE);
@@ -97,8 +98,8 @@ public class PdpMessageHandler {
* @return PdpStatus the pdp status message
*/
public PdpStatus createPdpStatusFromContext() {
- final PdpStatus pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
- final PdpStatus pdpStatus = new PdpStatus();
+ final var pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+ final var pdpStatus = new PdpStatus();
pdpStatus.setName(pdpStatusContext.getName());
pdpStatus.setPdpType(pdpStatusContext.getPdpType());
pdpStatus.setState(pdpStatusContext.getState());
@@ -128,7 +129,7 @@ public class PdpMessageHandler {
*/
private PdpStatistics getStatistics(final PdpStatus pdpStatusContext, final ApexEngineHandler apexEngineHandler) {
- PdpStatistics pdpStatistics = new PdpStatistics();
+ var pdpStatistics = new PdpStatistics();
pdpStatistics.setPdpInstanceId(pdpStatusContext.getName());
pdpStatistics.setTimeStamp(Instant.now());
pdpStatistics.setPdpGroupName(pdpStatusContext.getPdpGroup());
@@ -136,7 +137,7 @@ public class PdpMessageHandler {
if (apexEngineHandler != null) {
pdpStatistics.setEngineStats(getEngineWorkerStats(apexEngineHandler));
}
- final ApexPolicyStatisticsManager apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ final var apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
if (apexPolicyCounter != null) {
pdpStatistics.setPolicyDeploySuccessCount(apexPolicyCounter.getPolicyDeploySuccessCount());
pdpStatistics.setPolicyDeployFailCount(apexPolicyCounter.getPolicyDeployFailCount());
@@ -158,7 +159,7 @@ public class PdpMessageHandler {
List<AxEngineModel> engineModels = apexEngineHandler.getEngineStats();
if (engineModels != null) {
engineModels.forEach(engineModel -> {
- PdpEngineWorkerStatistics workerStatistics = new PdpEngineWorkerStatistics();
+ var workerStatistics = new PdpEngineWorkerStatistics();
workerStatistics.setEngineWorkerState(transferEngineState(engineModel.getState()));
workerStatistics.setEngineId(engineModel.getId());
workerStatistics.setEventCount(engineModel.getStats().getEventCount());
@@ -195,7 +196,7 @@ public class PdpMessageHandler {
* @return PdpStatus the pdp status message
*/
public PdpStatus getTerminatedPdpStatus() {
- final PdpStatus pdpStatusInContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+ final var pdpStatusInContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
pdpStatusInContext.setState(PdpState.TERMINATED);
pdpStatusInContext.setDescription("Apex pdp shutting down.");
return createPdpStatusFromContext();
@@ -212,7 +213,7 @@ public class PdpMessageHandler {
*/
public PdpResponseDetails createPdpResonseDetails(final String requestId, final PdpResponseStatus status,
final String responseMessage) {
- final PdpResponseDetails pdpResponseDetails = new PdpResponseDetails();
+ final var pdpResponseDetails = new PdpResponseDetails();
pdpResponseDetails.setResponseTo(requestId);
pdpResponseDetails.setResponseStatus(status);
pdpResponseDetails.setResponseMessage(responseMessage);
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
index bbdbb22db..e6fd9e477 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -52,9 +53,10 @@ public class PdpStateChangeMessageHandler {
* @param pdpStateChangeMsg pdp state change message
*/
public void handlePdpStateChangeEvent(final PdpStateChange pdpStateChangeMsg) {
- final PdpStatus pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
- final PdpStatusPublisher pdpStatusPublisher = Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
- final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler();
+ final var pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+ final var pdpStatusPublisher =
+ Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
+ final var pdpMessageHandler = new PdpMessageHandler();
PdpResponseDetails pdpResponseDetails = null;
if (pdpStateChangeMsg.appliesTo(pdpStatusContext.getName(), pdpStatusContext.getPdpGroup(),
pdpStatusContext.getPdpSubgroup())) {
@@ -68,7 +70,7 @@ public class PdpStateChangeMessageHandler {
default:
break;
}
- final PdpStatus pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
+ final var pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
pdpStatus.setResponse(pdpResponseDetails);
pdpStatus.setDescription("Pdp status response message for PdpStateChange");
pdpStatusPublisher.send(pdpStatus);
@@ -115,7 +117,7 @@ public class PdpStateChangeMessageHandler {
final PdpMessageHandler pdpMessageHandler, final List<ToscaPolicy> policies) {
PdpResponseDetails pdpResponseDetails;
try {
- final ApexEngineHandler apexEngineHandler = new ApexEngineHandler(policies);
+ final var apexEngineHandler = new ApexEngineHandler(policies);
Registry.registerOrReplace(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, apexEngineHandler);
if (apexEngineHandler.isApexEngineRunning()) {
List<ToscaConceptIdentifier> runningPolicies = apexEngineHandler.getRunningPolicies();
@@ -127,7 +129,7 @@ public class PdpStateChangeMessageHandler {
pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(),
PdpResponseStatus.SUCCESS, "Apex engine started. State changed to active.");
} else {
- StringBuilder message = new StringBuilder(
+ var message = new StringBuilder(
"Apex engine started. But, only the following polices are running - ");
for (ToscaConceptIdentifier policy : runningPolicies) {
message.append(policy.getName()).append(":").append(policy.getVersion()).append(" ");
@@ -146,8 +148,7 @@ public class PdpStateChangeMessageHandler {
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(),
PdpResponseStatus.FAIL, "Apex engine service running failed. " + e.getMessage());
}
- final ApexPolicyStatisticsManager apexPolicyStatisticsManager =
- ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ final var apexPolicyStatisticsManager = ApexPolicyStatisticsManager.getInstanceFromRegistry();
if (apexPolicyStatisticsManager != null) {
apexPolicyStatisticsManager
.updatePolicyDeployCounter(pdpResponseDetails.getResponseStatus() == PdpResponseStatus.SUCCESS);
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
index 09fb92dd3..24ebc14de 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -58,8 +59,8 @@ public class PdpUpdateMessageHandler {
* @param pdpUpdateMsg pdp update message
*/
public void handlePdpUpdateEvent(final PdpUpdate pdpUpdateMsg) {
- final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler();
- final PdpStatus pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+ final var pdpMessageHandler = new PdpMessageHandler();
+ final var pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
PdpResponseDetails pdpResponseDetails = null;
if (pdpUpdateMsg.appliesTo(pdpStatusContext.getName(), pdpStatusContext.getPdpGroup(),
pdpStatusContext.getPdpSubgroup())) {
@@ -69,9 +70,9 @@ public class PdpUpdateMessageHandler {
} else {
pdpResponseDetails = handlePdpUpdate(pdpUpdateMsg, pdpMessageHandler, pdpStatusContext);
}
- final PdpStatusPublisher pdpStatusPublisherTemp =
- Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
- final PdpStatus pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
+ final var pdpStatusPublisherTemp =
+ Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
+ final var pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
pdpStatus.setResponse(pdpResponseDetails);
pdpStatus.setDescription("Pdp status response message for PdpUpdate");
pdpStatusPublisherTemp.send(pdpStatus);
@@ -89,7 +90,8 @@ public class PdpUpdateMessageHandler {
private PdpResponseDetails handlePdpUpdate(final PdpUpdate pdpUpdateMsg, final PdpMessageHandler pdpMessageHandler,
final PdpStatus pdpStatusContext) {
PdpResponseDetails pdpResponseDetails = null;
- final PdpStatusPublisher pdpStatusPublisher = Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
+ final var pdpStatusPublisher =
+ Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
if (null != pdpUpdateMsg.getPdpHeartbeatIntervalMs() && pdpUpdateMsg.getPdpHeartbeatIntervalMs() > 0
&& pdpStatusPublisher.getInterval() != pdpUpdateMsg.getPdpHeartbeatIntervalMs()) {
updateInterval(pdpUpdateMsg.getPdpHeartbeatIntervalMs());
@@ -109,7 +111,7 @@ public class PdpUpdateMessageHandler {
if (pdpStatusContext.getState().equals(PdpState.ACTIVE)) {
pdpResponseDetails = startOrStopApexEngineBasedOnPolicies(pdpUpdateMsg, pdpMessageHandler);
- ApexEngineHandler apexEngineHandler =
+ var apexEngineHandler =
Registry.getOrDefault(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, ApexEngineHandler.class, null);
// in hearbeat while in active state, only the policies which are running should be there.
// if some policy fails, that shouldn't go in the heartbeat.
@@ -210,7 +212,7 @@ public class PdpUpdateMessageHandler {
List<ToscaConceptIdentifier> policiesToBeUndeployed = pdpUpdateMsg.getPoliciesToBeUndeployed();
if (runningPolicies.containsAll(policiesToBeDeployed)
&& !containsAny(runningPolicies, policiesToBeUndeployed)) {
- StringBuilder message = new StringBuilder("Apex engine started. ");
+ var message = new StringBuilder("Apex engine started. ");
if (!policiesToBeDeployed.isEmpty()) {
message.append("Deployed policies are: ");
for (ToscaConceptIdentifier policy : policiesToBeDeployed) {
@@ -226,7 +228,7 @@ public class PdpUpdateMessageHandler {
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
PdpResponseStatus.SUCCESS, message.toString());
} else {
- StringBuilder message =
+ var message =
new StringBuilder("Apex engine started. But, only the following polices are running - ");
for (ToscaConceptIdentifier policy : runningPolicies) {
message.append(policy.getName()).append(":").append(policy.getVersion()).append(" ");
@@ -262,7 +264,8 @@ public class PdpUpdateMessageHandler {
* @param interval time interval received in the pdp update message from pap
*/
public void updateInterval(final long interval) {
- final PdpStatusPublisher pdpStatusPublisher = Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
+ final var pdpStatusPublisher =
+ Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
pdpStatusPublisher.terminate();
final List<TopicSink> topicSinks = Registry.get(ApexStarterConstants.REG_APEX_PDP_TOPIC_SINKS);
Registry.registerOrReplace(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER,
@@ -287,8 +290,7 @@ public class PdpUpdateMessageHandler {
* @param pdpResponseDetails the pdp response
*/
private void updateDeploymentCounts(final PdpUpdate pdpUpdateMsg, PdpResponseDetails pdpResponseDetails) {
- final ApexPolicyStatisticsManager statisticsManager =
- ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ final var statisticsManager = ApexPolicyStatisticsManager.getInstanceFromRegistry();
if (statisticsManager != null) {
if (pdpUpdateMsg.getPoliciesToBeDeployed() != null && !pdpUpdateMsg.getPoliciesToBeDeployed().isEmpty()) {
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
index 691b30d2d..7eba23028 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
@@ -55,7 +55,7 @@ public class ApexStarterParameterHandler {
// Read the parameters
try {
// Read the parameters from JSON
- final File file = new File(arguments.getFullConfigurationFilePath());
+ final var file = new File(arguments.getFullConfigurationFilePath());
apexStarterParameterGroup = CODER.decode(file, ApexStarterParameterGroup.class);
} catch (final CoderException e) {
final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java
index 1c6b88700..b6962e925 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java
@@ -47,7 +47,7 @@ public class HealthCheckProvider {
Registry.get(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, ApexStarterActivator.class);
final boolean alive = activator.isAlive();
- final HealthCheckReport report = new HealthCheckReport();
+ final var report = new HealthCheckReport();
report.setName(activator.getInstanceId());
report.setUrl(URL);
report.setHealthy(alive);