summaryrefslogtreecommitdiffstats
path: root/services
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
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')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java15
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java6
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java9
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java31
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java12
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java8
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java19
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java12
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java12
-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
21 files changed, 118 insertions, 113 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
index 1194a2ce8..9522e30ca 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
@@ -156,7 +156,7 @@ public class EventRequestorConsumer implements ApexEventConsumer, Runnable {
while (consumerThread.isAlive() && !stopOrderedFlag) {
try {
// Take the next event from the queue
- final Object eventObject =
+ final var eventObject =
incomingEventRequestQueue.poll(EVENT_REQUESTOR_WAIT_SLEEP_TIME, TimeUnit.MILLISECONDS);
if (eventObject == null) {
// Poll timed out, wait again
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java
index 36f3b9423..8cd6156a7 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java
@@ -108,7 +108,7 @@ public class EventRequestorProducer implements ApexEventProducer {
public void sendEvent(final long executionId, final Properties executorProperties, final String eventName,
final Object eventObject) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache =
+ final var synchronousEventCache =
(SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
index a85997315..086d5f75d 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
@@ -127,7 +127,7 @@ public class FileCarrierTechnologyParameters extends CarrierTechnologyParameters
String absoluteFileName = null;
// Resolve the file name if it is a relative file name
- File theFile = new File(fileName);
+ var theFile = new File(fileName);
if (theFile.isAbsolute()) {
absoluteFileName = fileName;
} else {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java
index 85ae52702..2c30c456f 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. 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.
* 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=========================================================
*/
@@ -104,13 +105,13 @@ public class CharacterDelimitedTextBlockReader implements TextBlockReader {
*/
private StringBuilder readTextBlockText() throws IOException {
// Holder for the text block
- final StringBuilder textBlockBuilder = new StringBuilder();
+ final var textBlockBuilder = new StringBuilder();
+
+ var nestingLevel = 0;
- int nestingLevel = 0;
-
// Read the next text block
while (true) {
- final char nextChar = (char) inputStream.read();
+ final var nextChar = (char) inputStream.read();
// Check for EOF
if (nextChar == (char) -1) {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java
index c2f14a261..b127abfa5 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java
@@ -106,7 +106,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable
this.inputStream = incomingInputStream;
// Configure and start the text reading thread
- Thread textConsumputionThread = new ApplicationThreadFactory(this.getClass().getName()).newThread(this);
+ var textConsumputionThread = new ApplicationThreadFactory(this.getClass().getName()).newThread(this);
textConsumputionThread.setDaemon(true);
textConsumputionThread.start();
}
@@ -117,7 +117,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable
@Override
public TextBlock readTextBlock() throws IOException {
// Holder for the current text block
- final StringBuilder textBlockBuilder = new StringBuilder();
+ final var textBlockBuilder = new StringBuilder();
// Wait for the timeout period if there is no input
if (!eofOnInputStream && textLineQueue.isEmpty()) {
@@ -169,7 +169,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable
*/
@Override
public void run() {
- try (BufferedReader textReader = new BufferedReader(new InputStreamReader(inputStream))) {
+ try (var textReader = new BufferedReader(new InputStreamReader(inputStream))) {
// Read the input line by line until we see end of file on the stream
String line;
while ((line = textReader.readLine()) != null) {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java
index fb57a2d7b..bf2c4c210 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. 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.
* 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=========================================================
*/
@@ -64,7 +65,7 @@ public class TextBlockReaderFactory {
(EventProtocolTextTokenDelimitedParameters) eventProtocolParameters;
// Create the text block reader
- final HeaderDelimitedTextBlockReader headerDelimitedTextBlockReader =
+ final var headerDelimitedTextBlockReader =
new HeaderDelimitedTextBlockReader(tokenDelimitedParameters);
headerDelimitedTextBlockReader.init(inputStream);
return headerDelimitedTextBlockReader;
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 b686d3e2a..f69eae664 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 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.
@@ -21,9 +22,7 @@
package org.onap.policy.apex.service.engine.runtime.impl;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -41,7 +40,6 @@ import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.core.engine.engine.ApexEngine;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
-import org.onap.policy.apex.core.engine.event.EnEvent;
import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -49,7 +47,6 @@ 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.handling.ApexModelWriter;
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.enginemodel.concepts.AxEngineState;
@@ -450,7 +447,7 @@ final class EngineWorker implements EngineService {
// Convert that information into a string
try {
- final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream();
+ final var baOutputStream = new ByteArrayOutputStream();
final ApexModelWriter<AxEngineModel> modelWriter = new ApexModelWriter<>(AxEngineModel.class);
modelWriter.setJsonOutput(true);
modelWriter.write(apexEngineModel, baOutputStream);
@@ -477,14 +474,14 @@ final class EngineWorker implements EngineService {
@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();
+ final var runtimeJsonStringBuilder = new StringBuilder();
// Get the engine information
final AxEngineModel engineModel = engine.getEngineStatus();
final Map<AxArtifactKey, Map<String, Object>> engineContextAlbums = engine.getEngineContext();
// Use GSON to convert our context information into JSON
- final Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ final var gson = new GsonBuilder().setPrettyPrinting().create();
// Get context into a JSON string
runtimeJsonStringBuilder.append("{\"TimeStamp\":");
@@ -497,7 +494,7 @@ final class EngineWorker implements EngineService {
// Get context into a JSON string
runtimeJsonStringBuilder.append(",\"ContextAlbums\":[");
- boolean firstAlbum = true;
+ var firstAlbum = true;
for (final Entry<AxArtifactKey, Map<String, Object>> contextAlbumEntry : engineContextAlbums.entrySet()) {
if (firstAlbum) {
firstAlbum = false;
@@ -510,7 +507,7 @@ final class EngineWorker implements EngineService {
runtimeJsonStringBuilder.append(",\"AlbumContent\":[");
// Get the schema helper to use to marshal context album objects to JSON
- final AxContextAlbum axContextAlbum =
+ final var axContextAlbum =
ModelService.getModel(AxContextAlbums.class).get(contextAlbumEntry.getKey());
SchemaHelper schemaHelper = null;
@@ -520,7 +517,7 @@ final class EngineWorker implements EngineService {
schemaHelper = new SchemaHelperFactory().createSchemaHelper(axContextAlbum.getKey(),
axContextAlbum.getItemSchema());
} catch (final ContextRuntimeException e) {
- final String resultString =
+ final var resultString =
"could not find schema helper to marshal context album \"" + axContextAlbum + "\" to JSON";
LOGGER.warn(resultString, e);
@@ -531,7 +528,7 @@ final class EngineWorker implements EngineService {
continue;
}
- boolean firstEntry = true;
+ var firstEntry = true;
for (final Entry<String, Object> contextEntry : contextAlbumEntry.getValue().entrySet()) {
if (firstEntry) {
firstEntry = false;
@@ -554,8 +551,8 @@ final class EngineWorker implements EngineService {
runtimeJsonStringBuilder.append("]}");
// Tidy up the JSON string
- final JsonElement jsonElement = JsonParser.parseString(runtimeJsonStringBuilder.toString());
- final String tidiedRuntimeString = gson.toJson(jsonElement);
+ final var jsonElement = JsonParser.parseString(runtimeJsonStringBuilder.toString());
+ final var tidiedRuntimeString = gson.toJson(jsonElement);
LOGGER.debug("runtime information={}", tidiedRuntimeString);
@@ -592,7 +589,7 @@ final class EngineWorker implements EngineService {
// Take events from the event processing queue of the worker and pass them to the engine
// for processing
- boolean stopFlag = false;
+ var stopFlag = false;
while (processorThread != null && !processorThread.isInterrupted() && !stopFlag) {
ApexEvent event = null;
try {
@@ -603,12 +600,12 @@ final class EngineWorker implements EngineService {
LOGGER.debug("Engine {} processing interrupted ", engineWorkerKey);
break;
}
- boolean executedResult = false;
+ var executedResult = false;
try {
if (event != null) {
debugEventIfDebugEnabled(event);
- final EnEvent enevent = apexEnEventConverter.fromApexEvent(event);
+ final var enevent = apexEnEventConverter.fromApexEvent(event);
executedResult = engine.handleEvent(enevent);
}
} catch (final ApexException e) {
@@ -617,7 +614,7 @@ final class EngineWorker implements EngineService {
LOGGER.warn("Engine {} terminated processing event {}", engineWorkerKey, event.toString(), e);
stopFlag = true;
}
- ApexPolicyStatisticsManager apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ var apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
if (!stopFlag && apexPolicyCounter != null) {
apexPolicyCounter.updatePolicyExecutedCounter(executedResult);
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java
index 46e7f842f..d55c49d0f 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 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.
@@ -24,7 +25,6 @@ package org.onap.policy.apex.service.parameters.carriertechnology;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
@@ -71,7 +71,7 @@ public class CarrierTechnologyParametersJsonAdapter
@Override
public JsonElement serialize(final CarrierTechnologyParameters src, final Type typeOfSrc,
final JsonSerializationContext context) {
- final String returnMessage = "serialization of Apex carrier technology parameters to Json is not supported";
+ final var returnMessage = "serialization of Apex carrier technology parameters to Json is not supported";
LOGGER.error(returnMessage);
throw new ParameterRuntimeException(returnMessage);
}
@@ -82,10 +82,10 @@ public class CarrierTechnologyParametersJsonAdapter
@Override
public CarrierTechnologyParameters deserialize(final JsonElement json, final Type typeOfT,
final JsonDeserializationContext context) {
- final JsonObject jsonObject = json.getAsJsonObject();
+ final var jsonObject = json.getAsJsonObject();
// Get the carrier technology label primitive
- final JsonPrimitive labelJsonPrimitive = (JsonPrimitive) jsonObject.get(CARRIER_TECHNOLOGY_TOKEN);
+ final var labelJsonPrimitive = (JsonPrimitive) jsonObject.get(CARRIER_TECHNOLOGY_TOKEN);
// Check if we found our carrier technology
if (labelJsonPrimitive == null) {
@@ -107,7 +107,7 @@ public class CarrierTechnologyParametersJsonAdapter
// Get the technology carrier parameter class for the carrier technology plugin class from
// the configuration parameters
- final JsonPrimitive classNameJsonPrimitive = (JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME);
+ final var classNameJsonPrimitive = (JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME);
// If no technology carrier parameter class was specified, we try to use a built in carrier
// technology
@@ -142,7 +142,7 @@ public class CarrierTechnologyParametersJsonAdapter
}
// Deserialise the class
- CarrierTechnologyParameters carrierTechnologyParameters =
+ var carrierTechnologyParameters = (CarrierTechnologyParameters)
context.deserialize(jsonObject.get(CARRIER_TECHNOLOGY_PARAMETERS), carrierTechnologyParameterClass);
if (carrierTechnologyParameters == null) {
// OK no parameters for the carrier technology have been specified, just instantiate the
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
index 9e47926bc..66f253b56 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
@@ -183,7 +183,7 @@ public class RestPluginCarrierTechnologyParameters extends CarrierTechnologyPara
return null;
}
- Matcher matcher = patternErrorKey.matcher(url2);
+ var matcher = patternErrorKey.matcher(url2);
if (matcher.find()) {
final String urlInvalidMessage = "invalid URL has been set for event sending on " + getLabel();
return new ObjectValidationResult("url", url2, ValidationStatus.INVALID, urlInvalidMessage);
@@ -202,13 +202,13 @@ public class RestPluginCarrierTechnologyParameters extends CarrierTechnologyPara
return null;
}
- BeanValidationResult result = new BeanValidationResult(HTTP_HEADERS, httpHeaders);
+ var result = new BeanValidationResult(HTTP_HEADERS, httpHeaders);
- int item = 0;
+ var item = 0;
for (String[] httpHeader : httpHeaders) {
final String label = "entry " + (item++);
final List<String> value = (httpHeader == null ? null : Arrays.asList(httpHeader));
- BeanValidationResult result2 = new BeanValidationResult(label, value);
+ var result2 = new BeanValidationResult(label, value);
if (httpHeader == null) {
// note: add to result, not result2
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java
index 5319d763e..dee3a15bb 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 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.
@@ -78,7 +79,7 @@ public class EngineServiceParametersJsonAdapter
@Override
public JsonElement serialize(final EngineParameters src, final Type typeOfSrc,
final JsonSerializationContext context) {
- final String returnMessage = "serialization of Apex parameters to Json is not supported";
+ final var returnMessage = "serialization of Apex parameters to Json is not supported";
LOGGER.error(returnMessage);
throw new ParameterRuntimeException(returnMessage);
}
@@ -89,9 +90,9 @@ public class EngineServiceParametersJsonAdapter
@Override
public EngineParameters deserialize(final JsonElement json, final Type typeOfT,
final JsonDeserializationContext context) {
- final JsonObject engineParametersJsonObject = json.getAsJsonObject();
+ final var engineParametersJsonObject = json.getAsJsonObject();
- final EngineParameters engineParameters = new EngineParameters();
+ final var engineParameters = new EngineParameters();
// Deserialise context parameters, they may be a subclass of the ContextParameters class
engineParameters.setContextParameters(
@@ -151,12 +152,12 @@ public class EngineServiceParametersJsonAdapter
}
// We do this because the JSON parameters may be for a subclass of ContextParameters
- final ContextParameters contextParameters = (ContextParameters) deserializeParameters(CONTEXT_PARAMETERS,
+ final var contextParameters = (ContextParameters) deserializeParameters(CONTEXT_PARAMETERS,
contextParametersElement, context);
// We know this will work because if the context parameters was not a Json object, the
// previous deserializeParameters() call would not have worked
- final JsonObject contextParametersObject = engineParametersJsonObject.get(CONTEXT_PARAMETERS).getAsJsonObject();
+ final var contextParametersObject = engineParametersJsonObject.get(CONTEXT_PARAMETERS).getAsJsonObject();
// Now get the distributor, lock manager, and persistence parameters
final JsonElement distributorParametersElement = contextParametersObject.get(DISTRIBUTOR_PARAMETERS);
@@ -204,11 +205,11 @@ public class EngineServiceParametersJsonAdapter
}
// Deserialize the executor parameters
- final JsonObject executorParametersJsonObject = engineParametersJsonObject.get(EXECUTOR_PARAMETERS)
+ final var executorParametersJsonObject = engineParametersJsonObject.get(EXECUTOR_PARAMETERS)
.getAsJsonObject();
for (final Entry<String, JsonElement> executorEntries : executorParametersJsonObject.entrySet()) {
- final ExecutorParameters executorParameters = (ExecutorParameters) deserializeParameters(
+ final var executorParameters = (ExecutorParameters) deserializeParameters(
EXECUTOR_PARAMETERS + ':' + executorEntries.getKey(), executorEntries.getValue(), context);
engineParameters.getExecutorParameterMap().put(executorEntries.getKey(), executorParameters);
}
@@ -235,7 +236,7 @@ public class EngineServiceParametersJsonAdapter
}
// Deserialize the executor parameters
- final JsonObject schemaHelperParametersJsonObject = contextParametersJsonObject.get(SCHEMA_PARAMETERS)
+ final var schemaHelperParametersJsonObject = contextParametersJsonObject.get(SCHEMA_PARAMETERS)
.getAsJsonObject();
for (final Entry<String, JsonElement> schemaHelperEntries : schemaHelperParametersJsonObject.entrySet()) {
@@ -286,7 +287,7 @@ public class EngineServiceParametersJsonAdapter
}
// Check the parameter has a value
- final String parameterClassName = parameterClassNameElement.getAsString();
+ final var parameterClassName = parameterClassNameElement.getAsString();
if (parameterClassName == null || parameterClassName.trim().length() == 0) {
final String returnMessage = "value for field \"" + PARAMETER_CLASS_NAME + "\" in \"" + parametersLabel
+ "\" entry is not specified or is blank";
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java
index ce1860ecf..f0074872f 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 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.
@@ -24,7 +25,6 @@ package org.onap.policy.apex.service.parameters.eventprotocol;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
@@ -69,7 +69,7 @@ public class EventProtocolParametersJsonAdapter
@Override
public JsonElement serialize(final EventProtocolParameters src, final Type typeOfSrc,
final JsonSerializationContext context) {
- final String returnMessage = "serialization of Apex event protocol parameters to Json is not supported";
+ final var returnMessage = "serialization of Apex event protocol parameters to Json is not supported";
LOGGER.error(returnMessage);
throw new ParameterRuntimeException(returnMessage);
}
@@ -80,10 +80,10 @@ public class EventProtocolParametersJsonAdapter
@Override
public EventProtocolParameters deserialize(final JsonElement json, final Type typeOfT,
final JsonDeserializationContext context) {
- final JsonObject jsonObject = json.getAsJsonObject();
+ final var jsonObject = json.getAsJsonObject();
// Get the event protocol label primitive
- final JsonPrimitive labelJsonPrimitive = (JsonPrimitive) jsonObject.get(EVENT_PROTOCOL_TOKEN);
+ final var labelJsonPrimitive = (JsonPrimitive) jsonObject.get(EVENT_PROTOCOL_TOKEN);
// Check if we found our event protocol
if (labelJsonPrimitive == null) {
@@ -105,7 +105,7 @@ public class EventProtocolParametersJsonAdapter
// Get the event protocol parameter class for the event protocol plugin class from the
// configuration parameters
- final JsonPrimitive classNameJsonPrimitive = (JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME);
+ final var classNameJsonPrimitive = (JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME);
// If no event protocol parameter class was specified, we use the default
if (classNameJsonPrimitive == null) {
@@ -137,7 +137,7 @@ public class EventProtocolParametersJsonAdapter
}
// Deserialise the class
- EventProtocolParameters eventProtocolParameters =
+ var eventProtocolParameters = (EventProtocolParameters)
context.deserialize(jsonObject.get(EVENT_PROTOCOL_PARAMETERS), eventProtocolParameterClass);
if (eventProtocolParameters == null) {
// OK no parameters for the event protocol have been specified, just instantiate the
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java
index 068880a9d..dd960b298 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 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.
@@ -138,11 +139,12 @@ public class SynchronousEventCacheTest {
final SynchronousEventCache cache =
new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, producer, timeout);
- assertThatCode(() -> {
- cache.cacheSynchronizedEventFromApex(executionId, new Object());
- cache.cacheSynchronizedEventFromApex(executionId, new Object());
- })
- .isInstanceOf(ApexEventRuntimeException.class);
+ final var obj1 = new Object();
+ cache.cacheSynchronizedEventFromApex(executionId, obj1);
+
+ final var obj2 = new Object();
+ assertThatCode(() -> cache.cacheSynchronizedEventFromApex(executionId, obj2))
+ .isInstanceOf(ApexEventRuntimeException.class);
}
@Test
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);