aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/main
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2021-06-20 19:39:39 +0000
committerGerrit Code Review <gerrit@onap.org>2021-06-20 19:39:39 +0000
commitf00ca4de37bbbf272e107dd89f4dbb901c787462 (patch)
tree419f19cfffa1a49e5a4be4b80d75cfc740c26cf0 /runtime-controlloop/src/main
parent18526e9a01fc0b0e085d2a6e3457957e6392ce27 (diff)
parent2d186df9e3ed47599dbc86c2f435f7884535398c (diff)
Merge "Clean up CLAMP Sonar and checkstyle issues"
Diffstat (limited to 'runtime-controlloop/src/main')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java14
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java310
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java56
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java206
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java1
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java31
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java9
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java83
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java69
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java19
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java8
15 files changed, 385 insertions, 433 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
index 88e8b1df9..74975e768 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
@@ -21,15 +21,12 @@
package org.onap.policy.clamp.controlloop.runtime.commissioning;
import java.io.IOException;
-import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
import org.onap.policy.clamp.controlloop.runtime.commissioning.rest.CommissioningController;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelRuntimeException;
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
index 50f6787b9..5bbf6a079 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -29,7 +29,6 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.models.base.PfModelException;
@@ -57,11 +56,10 @@ public class CommissioningProvider implements Closeable {
/**
* Create a commissioning provider.
- *
- * @throws ControlLoopRuntimeException on errors creating the provider
+ * @param databaseProviderParameters parameters for database access
+ * @throws PfModelRuntimeException on errors creating the database provider
*/
- public CommissioningProvider(PolicyModelsProviderParameters databaseProviderParameters)
- throws ControlLoopRuntimeException {
+ public CommissioningProvider(PolicyModelsProviderParameters databaseProviderParameters) {
try {
modelsProvider = new PolicyModelsProviderFactory()
.createPolicyModelsProvider(databaseProviderParameters);
@@ -98,7 +96,7 @@ public class CommissioningProvider implements Closeable {
modelsProvider.createServiceTemplate(serviceTemplate);
}
- CommissioningResponse response = new CommissioningResponse();
+ var response = new CommissioningResponse();
// @formatter:off
response.setAffectedControlLoopDefinitions(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates()
.values()
@@ -123,7 +121,7 @@ public class CommissioningProvider implements Closeable {
modelsProvider.deleteServiceTemplate(name, version);
}
- CommissioningResponse response = new CommissioningResponse();
+ var response = new CommissioningResponse();
response.setAffectedControlLoopDefinitions(
Collections.singletonList(new ToscaConceptIdentifier(name, version)));
@@ -201,7 +199,7 @@ public class CommissioningProvider implements Closeable {
* @throws PfModelException on errors getting control loop definitions
*/
public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException {
- ToscaServiceTemplates serviceTemplates = new ToscaServiceTemplates();
+ var serviceTemplates = new ToscaServiceTemplates();
serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
return serviceTemplates.getServiceTemplates().get(0);
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
index 4060ae5be..ebfbbd5ee 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
@@ -44,8 +44,6 @@ import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProv
import org.onap.policy.clamp.controlloop.runtime.main.rest.RestController;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.errors.concepts.ErrorResponse;
-import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
@@ -81,58 +79,56 @@ public class CommissioningController extends RestController {
value = "Commissions control loop definitions",
notes = "Commissions control loop definitions, returning the commissioned control loop definition IDs",
response = CommissioningResponse.class,
- tags = {
- "Control Loop Commissioning API"
- },
+ tags = {"Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@ApiResponses(
value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
}
)
// @formatter:on
- public Response create(
- @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Entity Body of Control Loop", required = true) ToscaServiceTemplate body) {
+ public Response create(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Entity Body of Control Loop", required = true) ToscaServiceTemplate body) {
try {
CommissioningResponse response = provider.createControlLoopDefinitions(body);
- return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId)
- .entity(response).build();
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Commissioning of the control loops failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -153,58 +149,56 @@ public class CommissioningController extends RestController {
@ApiOperation(value = "Delete a commissioned control loop",
notes = "Deletes a Commissioned Control Loop, returning optional error details",
response = CommissioningResponse.class,
- tags = {
- "Clamp Control Loop Commissioning API"
- },
+ tags = {"Clamp Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
name = REQUEST_ID_NAME,
description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
- @ApiResponses(value = {
+ @ApiResponses(
+ value = {
@ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
@ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
@ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
}
)
// @formatter:on
- public Response delete(
- @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
- @ApiParam(value = "Control Loop definition version", required = true)
- @QueryParam("version") String version) {
+ public Response delete(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true) @QueryParam("version") String version) {
try {
CommissioningResponse response = provider.deleteControlLoopDefinition(name, version);
- return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId)
- .entity(response).build();
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Decommisssioning of control loop failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -226,52 +220,49 @@ public class CommissioningController extends RestController {
notes = "Queries details of the requested commissioned control loop definitions, "
+ "returning all control loop details",
response = ToscaNodeTemplate.class,
- tags = {
- "Clamp Control Loop Commissioning API"
- },
+ tags = {"Clamp Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
}
)
@ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
)
// @formatter:on
public Response query(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true)
- @QueryParam("name") String name,
- @ApiParam(value = "Control Loop definition version", required = true)
- @QueryParam("version") String version) {
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true) @QueryParam("version") String version) {
try {
List<ToscaNodeTemplate> response = provider.getControlLoopDefinitions(name, version);
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
- .build();
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of control loop definitions failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -293,53 +284,50 @@ public class CommissioningController extends RestController {
notes = "Queries details of the requested commissioned tosca service template, "
+ "returning all tosca service template details",
response = ToscaServiceTemplate.class,
- tags = {
- "Clamp Control Loop Commissioning API"
- },
+ tags = {"Clamp Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
)
// @formatter:on
- public Response queryToscaServiceTemplate(@HeaderParam(REQUEST_ID_NAME)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Tosca service template name", required = true)
- @QueryParam("name") String name,
- @ApiParam(value = "Tosca service template version", required = true)
- @QueryParam("version") String version) {
+ public Response queryToscaServiceTemplate(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Tosca service template name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Tosca service template version", required = true) @QueryParam("version") String version) {
try {
- ToscaServiceTemplate response = provider.getToscaServiceTemplate(name, version);
+ var response = provider.getToscaServiceTemplate(name, version);
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
- .build();
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of tosca service template failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -361,60 +349,57 @@ public class CommissioningController extends RestController {
notes = "Queries details of the requested commissioned control loop element definitions, "
+ "returning all control loop elements' details",
response = ToscaNodeTemplate.class,
- tags = {
- "Clamp Control Loop Commissioning API"
- },
+ tags = {"Clamp Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
)
// @formatter:on
public Response queryElements(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true)
- @QueryParam("name") String name,
- @ApiParam(value = "Control Loop definition version", required = true)
- @QueryParam("version") String version) throws Exception {
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true) @QueryParam("version") String version) {
try {
List<ToscaNodeTemplate> nodeTemplate = provider.getControlLoopDefinitions(name, version);
- //Prevent ambiguous queries with multiple returns
+ // Prevent ambiguous queries with multiple returns
if (nodeTemplate.size() > 1) {
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails("Multiple ControlLoops are not supported");
return returnResponse(Response.Status.NOT_ACCEPTABLE, requestId, resp);
}
List<ToscaNodeTemplate> response = provider.getControlLoopElementDefinitions(nodeTemplate.get(0));
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
- .build();
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of control loop element definitions failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -422,7 +407,6 @@ public class CommissioningController extends RestController {
}
private Response returnResponse(Response.Status status, UUID requestId, CommissioningResponse resp) {
- return addLoggingHeaders(addVersionControlHeaders(Response.status(status)),
- requestId).entity(resp).build();
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(status)), requestId).entity(resp).build();
}
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
index eb72d9219..f458d7c51 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
@@ -63,6 +63,7 @@ public class ControlLoopInstantiationProvider implements Closeable {
* Create a instantiation provider.
*
* @param databaseProviderParameters the parameters for database access
+ * @throws PfModelRuntimeException on errors creating a provider
*/
public ControlLoopInstantiationProvider(PolicyModelsProviderParameters databaseProviderParameters) {
try {
@@ -89,10 +90,10 @@ public class ControlLoopInstantiationProvider implements Closeable {
synchronized (lockit) {
for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- ControlLoop checkControlLoop = controlLoopProvider.getControlLoop(controlLoop.getKey().asIdentifier());
+ var checkControlLoop = controlLoopProvider.getControlLoop(controlLoop.getKey().asIdentifier());
if (checkControlLoop != null) {
throw new PfModelException(Response.Status.BAD_REQUEST,
- controlLoop.getKey().asIdentifier() + " already defined");
+ controlLoop.getKey().asIdentifier() + " already defined");
}
}
BeanValidationResult validationResult = validateControlLoops(controlLoops);
@@ -102,9 +103,9 @@ public class ControlLoopInstantiationProvider implements Closeable {
controlLoopProvider.createControlLoops(controlLoops.getControlLoopList());
}
- InstantiationResponse response = new InstantiationResponse();
+ var response = new InstantiationResponse();
response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
- .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
+ .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
return response;
}
@@ -125,9 +126,9 @@ public class ControlLoopInstantiationProvider implements Closeable {
controlLoopProvider.updateControlLoops(controlLoops.getControlLoopList());
}
- InstantiationResponse response = new InstantiationResponse();
+ var response = new InstantiationResponse();
response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
- .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
+ .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
return response;
}
@@ -136,32 +137,29 @@ public class ControlLoopInstantiationProvider implements Closeable {
* Validate ControlLoops.
*
* @param controlLoops ControlLoops to validate
- * @result the result of validation
+ * @return the result of validation
* @throws PfModelException if controlLoops is not valid
*/
private BeanValidationResult validateControlLoops(ControlLoops controlLoops) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult("ControlLoops", controlLoops);
+ var result = new BeanValidationResult("ControlLoops", controlLoops);
for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- BeanValidationResult subResult = new BeanValidationResult(
- "entry " + controlLoop.getDefinition().getName(), controlLoop);
+ var subResult = new BeanValidationResult("entry " + controlLoop.getDefinition().getName(), controlLoop);
List<ToscaNodeTemplate> toscaNodeTemplates = commissioningProvider.getControlLoopDefinitions(
- controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
+ controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
if (toscaNodeTemplates.isEmpty()) {
- subResult
- .addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
- ValidationStatus.INVALID, "Commissioned control loop definition not FOUND"));
+ subResult.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
+ ValidationStatus.INVALID, "Commissioned control loop definition not FOUND"));
} else if (toscaNodeTemplates.size() > 1) {
- subResult
- .addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
- ValidationStatus.INVALID, "Commissioned control loop definition not VALID"));
+ subResult.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
+ ValidationStatus.INVALID, "Commissioned control loop definition not VALID"));
} else {
List<ToscaNodeTemplate> clElementDefinitions =
- commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplates.get(0));
+ commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplates.get(0));
// @formatter:off
Map<String, ToscaConceptIdentifier> definitions = clElementDefinitions
@@ -184,11 +182,11 @@ public class ControlLoopInstantiationProvider implements Closeable {
*
* @param definitions map of all ToscaConceptIdentifiers
* @param definition ToscaConceptIdentifier to validate
- * @result result the validation result
+ * @return the validation result
*/
private ValidationResult validateDefinition(Map<String, ToscaConceptIdentifier> definitions,
- ToscaConceptIdentifier definition) {
- BeanValidationResult result = new BeanValidationResult("entry " + definition.getName(), definition);
+ ToscaConceptIdentifier definition) {
+ var result = new BeanValidationResult("entry " + definition.getName(), definition);
ToscaConceptIdentifier identifier = definitions.get(definition.getName());
if (identifier == null) {
result.setResult(ValidationStatus.INVALID, "Not FOUND");
@@ -207,7 +205,7 @@ public class ControlLoopInstantiationProvider implements Closeable {
* @throws PfModelException on deletion errors
*/
public InstantiationResponse deleteControlLoop(String name, String version) throws PfModelException {
- InstantiationResponse response = new InstantiationResponse();
+ var response = new InstantiationResponse();
synchronized (lockit) {
List<ControlLoop> controlLoops = controlLoopProvider.getControlLoops(name, version);
if (controlLoops.isEmpty()) {
@@ -216,12 +214,12 @@ public class ControlLoopInstantiationProvider implements Closeable {
for (ControlLoop controlLoop : controlLoops) {
if (!ControlLoopState.UNINITIALISED.equals(controlLoop.getState())) {
throw new PfModelException(Response.Status.BAD_REQUEST,
- "Control Loop State is still " + controlLoop.getState());
+ "Control Loop State is still " + controlLoop.getState());
}
}
response.setAffectedControlLoops(Collections
- .singletonList(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier()));
+ .singletonList(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier()));
}
return response;
}
@@ -235,7 +233,7 @@ public class ControlLoopInstantiationProvider implements Closeable {
* @throws PfModelException on errors getting control loops
*/
public ControlLoops getControlLoops(String name, String version) throws PfModelException {
- ControlLoops controlLoops = new ControlLoops();
+ var controlLoops = new ControlLoops();
controlLoops.setControlLoopList(controlLoopProvider.getControlLoops(name, version));
return controlLoops;
@@ -250,7 +248,7 @@ public class ControlLoopInstantiationProvider implements Closeable {
* @throws ControlLoopException on ordered state invalid
*/
public InstantiationResponse issueControlLoopCommand(InstantiationCommand command)
- throws ControlLoopException, PfModelException {
+ throws ControlLoopException, PfModelException {
if (command.getOrderedState() == null) {
throw new ControlLoopException(Status.BAD_REQUEST, "ordered state invalid or not specified on command");
@@ -259,16 +257,16 @@ public class ControlLoopInstantiationProvider implements Closeable {
synchronized (lockit) {
List<ControlLoop> controlLoops = new ArrayList<>(command.getControlLoopIdentifierList().size());
for (ToscaConceptIdentifier id : command.getControlLoopIdentifierList()) {
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(id);
+ var controlLoop = controlLoopProvider.getControlLoop(id);
controlLoop.setCascadedOrderedState(command.getOrderedState());
controlLoops.add(controlLoop);
}
controlLoopProvider.updateControlLoops(controlLoops);
}
- SupervisionHandler supervisionHandler = SupervisionHandler.getInstance();
+ var supervisionHandler = SupervisionHandler.getInstance();
supervisionHandler.triggerControlLoopSupervision(command.getControlLoopIdentifierList());
- InstantiationResponse response = new InstantiationResponse();
+ var response = new InstantiationResponse();
response.setAffectedControlLoops(command.getControlLoopIdentifierList());
return response;
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
index d81e54ccf..67fd9455e 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
@@ -21,15 +21,12 @@
package org.onap.policy.clamp.controlloop.runtime.instantiation;
import java.io.IOException;
-import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
import org.onap.policy.clamp.controlloop.runtime.instantiation.rest.InstantiationController;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelRuntimeException;
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
index 7581aaf74..ea36c71fb 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
@@ -82,36 +82,35 @@ public class InstantiationController extends RestController {
value = "Commissions control loop definitions",
notes = "Commissions control loop definitions, returning the control loop IDs",
response = InstantiationResponse.class,
- tags = {
- "Control Loop Instantiation API"
- },
+ tags = {"Control Loop Instantiation API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
@ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
@ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ }
+ )
}
)
@ApiResponses(
@@ -156,22 +155,23 @@ public class InstantiationController extends RestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@@ -190,7 +190,7 @@ public class InstantiationController extends RestController {
required = true) @QueryParam("version") String version) {
try {
- ControlLoops response = provider.getControlLoops(name, version);
+ var response = provider.getControlLoops(name, version);
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
.build();
@@ -220,31 +220,32 @@ public class InstantiationController extends RestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
@ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
@ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ }
+ )
}
)
@ApiResponses(
@@ -289,33 +290,35 @@ public class InstantiationController extends RestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
}
)
- @ApiResponses(value = {
+ @ApiResponses(
+ value = {
@ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
@ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
@ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
@@ -358,21 +361,22 @@ public class InstantiationController extends RestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
}
)
}
@@ -407,7 +411,7 @@ public class InstantiationController extends RestController {
* @return the Instantiation Response
*/
private Response createInstantiationErrorResponse(ErrorResponseInfo e, UUID requestId) {
- InstantiationResponse resp = new InstantiationResponse();
+ var resp = new InstantiationResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).entity(resp).build();
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
index dd3fa30fc..4955e4a2f 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
@@ -102,6 +102,7 @@ public class RestController {
* Adds logging headers to the response.
*
* @param respBuilder response builder
+ * @param requestId unique ID for this request
* @return the response builder, with version logging
*/
public ResponseBuilder addLoggingHeaders(ResponseBuilder respBuilder, UUID requestId) {
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
index a4238a9c4..957f53600 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
@@ -64,6 +64,7 @@ public class ClRuntimeActivator extends ServiceManagerContainer {
* Instantiate the activator for the control loop runtime as a complete service.
*
* @param clRuntimeParameterGroup the parameters for the control loop runtime service
+ * @throws ControlLoopRuntimeException if the activator does not start
*/
public ClRuntimeActivator(final ClRuntimeParameterGroup clRuntimeParameterGroup) {
@@ -134,7 +135,7 @@ public class ClRuntimeActivator extends ServiceManagerContainer {
providerClasses.addAll(supervisionHandler.get().getProviderClasses());
providerClasses.addAll(monitoringHandler.get().getProviderClasses());
- RestServer server = new RestServer(clRuntimeParameterGroup.getRestServerParameters(),
+ var server = new RestServer(clRuntimeParameterGroup.getRestServerParameters(),
ControlLoopAafFilter.class,
providerClasses.toArray(new Class<?>[providerClasses.size()]));
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
index f36bb858b..54167e8a6 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
@@ -20,21 +20,14 @@
package org.onap.policy.clamp.controlloop.runtime.main.startstop;
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URL;
import java.util.Arrays;
import javax.ws.rs.core.Response;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
-import org.apache.commons.lang3.StringUtils;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments;
@@ -44,14 +37,11 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
* This class reads and handles command line parameters for the control loop runtime service.
*/
public class ClRuntimeCommandLineArguments {
- private static final String FILE_MESSAGE_PREAMBLE = " file \"";
- private static final int HELP_LINE_LENGTH = 120;
-
private final Options options;
private final CommonCommandLineArguments commonCommandLineArguments;
- @Getter()
- @Setter()
+ @Getter
+ @Setter
private String configurationFilePath = null;
/**
@@ -66,6 +56,7 @@ public class ClRuntimeCommandLineArguments {
* Construct the options for the CLI editor and parse in the given arguments.
*
* @param args The command line arguments
+ * @throws ControlLoopRuntimeException if the arguments are invalid
*/
public ClRuntimeCommandLineArguments(final String[] args) {
// Set up the options with the default constructor
@@ -76,7 +67,7 @@ public class ClRuntimeCommandLineArguments {
parse(args);
} catch (final ControlLoopException e) {
throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
- "parse error on control loop runtime parameters", e);
+ "parse error on control loop runtime parameters", e);
}
}
@@ -95,7 +86,7 @@ public class ClRuntimeCommandLineArguments {
commandLine = new DefaultParser().parse(options, args);
} catch (final ParseException e) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- "invalid command line arguments specified : " + e.getMessage());
+ "invalid command line arguments specified : " + e.getMessage());
}
// Arguments left over after Commons CLI does its stuff
@@ -103,7 +94,7 @@ public class ClRuntimeCommandLineArguments {
if (remainingArgs.length > 0) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- "too many command line arguments specified : " + Arrays.toString(args));
+ "too many command line arguments specified : " + Arrays.toString(args));
}
if (commandLine.hasOption('h')) {
@@ -138,14 +129,4 @@ public class ClRuntimeCommandLineArguments {
public String getFullConfigurationFilePath() {
return ResourceUtils.getFilePath4Resource(getConfigurationFilePath());
}
-
- /**
- * Sets the configuration file path.
- *
- * @param configurationFilePath the configuration file path
- */
- public void setConfigurationFilePath(final String configurationFilePath) {
- this.configurationFilePath = configurationFilePath;
-
- }
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
index 8e60d68cf..de1ce6f5d 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
@@ -46,13 +46,14 @@ public class Main {
* Instantiates the control loop runtime service.
*
* @param args the command line arguments
+ * @throws ControlLoopRuntimeException if the CLAMP runtime fails to start
*/
public Main(final String[] args) {
- final String argumentString = Arrays.toString(args);
+ final var argumentString = Arrays.toString(args);
LOGGER.info("Starting the control loop runtime service with arguments - {}", argumentString);
// Check the arguments
- final ClRuntimeCommandLineArguments arguments = new ClRuntimeCommandLineArguments();
+ final var arguments = new ClRuntimeCommandLineArguments();
try {
// The arguments return a string if there is a message to print and we should exit
final String argumentMessage = arguments.parse(args);
@@ -82,12 +83,14 @@ public class Main {
// Add a shutdown hook to shut everything down in an orderly manner
Runtime.getRuntime().addShutdownHook(new ClRuntimeShutdownHookClass());
- String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_CLAMP);
+ var successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_CLAMP);
LOGGER.info(successMsg);
}
/**
* Check if main is running.
+ *
+ * @return true if the CLAMP runtime is running
*/
public boolean isRunning() {
return activator != null && activator.isAlive();
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
index a7ad9180a..1584766f1 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
@@ -21,15 +21,12 @@
package org.onap.policy.clamp.controlloop.runtime.monitoring;
import java.io.IOException;
-import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.monitoring.rest.MonitoringQueryController;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelRuntimeException;
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
index 193f8d557..1bc1312e7 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
@@ -30,7 +30,6 @@ import java.util.Map;
import lombok.NonNull;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
@@ -55,6 +54,8 @@ public class MonitoringProvider implements Closeable {
/**
* Create a Monitoring provider.
*
+ * @param parameters parameters for accessing the database for monitoring
+ * @throws PfModelRuntimeException on errors creating the provider
*/
public MonitoringProvider(PolicyModelsProviderParameters parameters) {
@@ -83,9 +84,9 @@ public class MonitoringProvider implements Closeable {
*/
public ParticipantStatisticsList createParticipantStatistics(List<ParticipantStatistics> participantStatistics)
throws PfModelException {
- ParticipantStatisticsList participantStatisticsList = new ParticipantStatisticsList();
- participantStatisticsList.setStatisticsList(participantStatisticsProvider
- .createParticipantStatistics(participantStatistics));
+ var participantStatisticsList = new ParticipantStatisticsList();
+ participantStatisticsList
+ .setStatisticsList(participantStatisticsProvider.createParticipantStatistics(participantStatistics));
return participantStatisticsList;
}
@@ -99,9 +100,9 @@ public class MonitoringProvider implements Closeable {
*/
public ClElementStatisticsList createClElementStatistics(List<ClElementStatistics> clElementStatisticsList)
throws PfModelException {
- ClElementStatisticsList elementStatisticsList = new ClElementStatisticsList();
- elementStatisticsList.setClElementStatistics(clElementStatisticsProvider
- .createClElementStatistics(clElementStatisticsList));
+ var elementStatisticsList = new ClElementStatisticsList();
+ elementStatisticsList
+ .setClElementStatistics(clElementStatisticsProvider.createClElementStatistics(clElementStatisticsList));
return elementStatisticsList;
}
@@ -117,38 +118,36 @@ public class MonitoringProvider implements Closeable {
* @return the participant found
*/
public ParticipantStatisticsList fetchFilteredParticipantStatistics(@NonNull final String name,
- final String version, int recordCount,
- Instant startTime, Instant endTime) {
- ParticipantStatisticsList participantStatisticsList = new ParticipantStatisticsList();
+ final String version, int recordCount, Instant startTime, Instant endTime) {
+ var participantStatisticsList = new ParticipantStatisticsList();
- //Additional parameters can be added in filterMap for filtering data.
+ // Additional parameters can be added in filterMap for filtering data.
Map<String, Object> filterMap = null;
- participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(
- name, version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
+ participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(name,
+ version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
return participantStatisticsList;
}
/**
- * Get all participant statistics records found for a specific control loop. *
+ * Get all participant statistics records found for a specific control loop. *
*
* @param controlLoopName name of the control loop
* @param controlLoopVersion version of the control loop
* @return All the participant statistics found
- * @throws PfModelException on errors getting participant statistics
+ * @throws PfModelRuntimeException on errors getting participant statistics
*/
public ParticipantStatisticsList fetchParticipantStatsPerControlLoop(@NonNull final String controlLoopName,
- @NonNull final String controlLoopVersion)
- throws PfModelException {
- ParticipantStatisticsList statisticsList = new ParticipantStatisticsList();
+ @NonNull final String controlLoopVersion) {
+ var statisticsList = new ParticipantStatisticsList();
List<ParticipantStatistics> participantStatistics = new ArrayList<>();
try {
- //Fetch all participantIds for a specific control loop
- List<ToscaConceptIdentifier> participantIds = getAllParticipantIdsPerControlLoop(controlLoopName,
- controlLoopVersion);
- for (ToscaConceptIdentifier id: participantIds) {
- participantStatistics.addAll(participantStatisticsProvider.getFilteredParticipantStatistics(
- id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0));
+ // Fetch all participantIds for a specific control loop
+ List<ToscaConceptIdentifier> participantIds =
+ getAllParticipantIdsPerControlLoop(controlLoopName, controlLoopVersion);
+ for (ToscaConceptIdentifier id : participantIds) {
+ participantStatistics.addAll(participantStatisticsProvider
+ .getFilteredParticipantStatistics(id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0));
}
statisticsList.setStatisticsList(participantStatistics);
} catch (PfModelException e) {
@@ -157,8 +156,6 @@ public class MonitoringProvider implements Closeable {
return statisticsList;
}
-
-
/**
* Get clElement statistics based on specific filters.
*
@@ -172,46 +169,42 @@ public class MonitoringProvider implements Closeable {
* @throws PfModelException on errors getting control loop statistics
*/
public ClElementStatisticsList fetchFilteredClElementStatistics(@NonNull final String name, final String version,
- final String id, Instant startTime, Instant endTime,
- int recordCount) throws PfModelException {
- ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
+ final String id, Instant startTime, Instant endTime, int recordCount) throws PfModelException {
+ var clElementStatisticsList = new ClElementStatisticsList();
Map<String, Object> filterMap = new HashMap<>();
- //Adding UUID in filter if present
+ // Adding UUID in filter if present
if (id != null) {
filterMap.put("localName", id);
}
- clElementStatisticsList.setClElementStatistics(clElementStatisticsProvider.getFilteredClElementStatistics(
- name, version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
+ clElementStatisticsList.setClElementStatistics(clElementStatisticsProvider.getFilteredClElementStatistics(name,
+ version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
return clElementStatisticsList;
}
-
/**
* Get clElement statistics per control loop.
*
* @param name the name of the control loop
* @param version the version of the control loop
* @return the clElement statistics found
- * @throws PfModelException on errors getting control loop statistics
+ * @throws PfModelRuntimeException on errors getting control loop statistics
*/
public ClElementStatisticsList fetchClElementStatsPerControlLoop(@NonNull final String name,
- @NonNull final String version)
- throws PfModelException {
- ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
+ @NonNull final String version) {
+ var clElementStatisticsList = new ClElementStatisticsList();
List<ClElementStatistics> clElementStats = new ArrayList<>();
try {
List<ControlLoopElement> clElements = new ArrayList<>();
- //Fetch all control loop elements for the control loop
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name,
- version));
+ // Fetch all control loop elements for the control loop
+ var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
if (controlLoop != null) {
clElements.addAll(controlLoop.getElements().values());
- //Collect control loop element statistics for each cl element.
+ // Collect control loop element statistics for each cl element.
for (ControlLoopElement clElement : clElements) {
clElementStats.addAll(fetchFilteredClElementStatistics(clElement.getParticipantId().getName(),
- clElement.getParticipantId().getVersion(), clElement.getId().toString(), null,
- null, 0).getClElementStatistics());
+ clElement.getParticipantId().getVersion(), clElement.getId().toString(), null, null, 0)
+ .getClElementStatistics());
}
}
clElementStatisticsList.setClElementStatistics(clElementStats);
@@ -233,7 +226,7 @@ public class MonitoringProvider implements Closeable {
public List<ToscaConceptIdentifier> getAllParticipantIdsPerControlLoop(String name, String version)
throws PfModelException {
List<ToscaConceptIdentifier> participantIds = new ArrayList<>();
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
+ var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
if (controlLoop != null) {
for (ControlLoopElement clElement : controlLoop.getElements().values()) {
participantIds.add(clElement.getParticipantId());
@@ -254,7 +247,7 @@ public class MonitoringProvider implements Closeable {
public Map<String, ToscaConceptIdentifier> getAllClElementsIdPerControlLoop(String name, String version)
throws PfModelException {
Map<String, ToscaConceptIdentifier> clElementId = new HashMap<>();
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
+ var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
if (controlLoop != null) {
for (ControlLoopElement clElement : controlLoop.getElements().values()) {
clElementId.put(clElement.getId().toString(), clElement.getParticipantId());
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
index 2e19ffe3a..7fde5fba3 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
@@ -67,7 +67,10 @@ public class MonitoringQueryController extends RestController {
*
* @param requestId request ID used in ONAP logging
* @param name the name of the participant to get, null for all participants statistics
+ * @param version the version of the participant to get, null for all participants with the given name
* @param recordCount the record count to be fetched
+ * @param startTime the time from which to get statistics
+ * @param endTime the time to which to get statistics
* @return the participant statistics
*/
// @formatter:off
@@ -91,13 +94,14 @@ public class MonitoringQueryController extends RestController {
@ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
}
)
@ApiResponses(
@@ -174,13 +178,14 @@ public class MonitoringQueryController extends RestController {
@ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
})
@ApiResponses(
value = {
@@ -203,7 +208,7 @@ public class MonitoringQueryController extends RestController {
.entity(response)
.build();
- } catch (PfModelRuntimeException | PfModelException e) {
+ } catch (PfModelRuntimeException e) {
LOGGER.warn("Monitoring of Cl participant statistics failed", e);
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).build();
@@ -242,13 +247,14 @@ public class MonitoringQueryController extends RestController {
@ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
})
@ApiResponses(
value = {
@@ -271,7 +277,7 @@ public class MonitoringQueryController extends RestController {
.entity(response)
.build();
- } catch (PfModelRuntimeException | PfModelException e) {
+ } catch (PfModelRuntimeException e) {
LOGGER.warn("Monitoring of Cl Element statistics failed", e);
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).build();
@@ -290,6 +296,8 @@ public class MonitoringQueryController extends RestController {
* @param version version of the control loop
* @param id Id of the control loop element
* @param recordCount the record count to be fetched
+ * @param startTime the time from which to get statistics
+ * @param endTime the time to which to get statistics
* @return the control loop element statistics
*/
// @formatter:off
@@ -313,13 +321,14 @@ public class MonitoringQueryController extends RestController {
@ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
})
@ApiResponses(
value = {
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
index 63bff00fc..7c7dc3a69 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
@@ -20,7 +20,6 @@
package org.onap.policy.clamp.controlloop.runtime.supervision;
-import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.ws.rs.core.Response;
@@ -40,7 +39,6 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningHandler;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringHandler;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
@@ -54,7 +52,6 @@ import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.common.utils.services.ServiceManager;
import org.onap.policy.common.utils.services.ServiceManagerException;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,7 +71,6 @@ public class SupervisionHandler extends ControlLoopHandler {
private ControlLoopProvider controlLoopProvider;
private ParticipantProvider participantProvider;
- private CommissioningProvider commissioningProvider;
private MonitoringProvider monitoringProvider;
// Publishers for participant communication
@@ -139,7 +135,7 @@ public class SupervisionHandler extends ControlLoopHandler {
for (ToscaConceptIdentifier controlLoopId : controlLoopIdentifierList) {
try {
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(controlLoopId);
+ var controlLoop = controlLoopProvider.getControlLoop(controlLoopId);
superviseControlLoop(controlLoop);
@@ -223,9 +219,10 @@ public class SupervisionHandler extends ControlLoopHandler {
* Supervise a control loop, performing whatever actions need to be performed on the control loop.
*
* @param controlLoop the control loop to supervises
+ * @throws PfModelException on accessing models in the database
* @throws ControlLoopException on supervision errors
*/
- private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
+ private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
switch (controlLoop.getOrderedState()) {
case UNINITIALISED:
superviseControlLoopUninitialization(controlLoop);
@@ -332,18 +329,18 @@ public class SupervisionHandler extends ControlLoopHandler {
}
private void sendControlLoopUpdate(ControlLoop controlLoop) throws PfModelException {
- ParticipantControlLoopUpdate pclu = new ParticipantControlLoopUpdate();
+ var pclu = new ParticipantControlLoopUpdate();
pclu.setControlLoopId(controlLoop.getKey().asIdentifier());
pclu.setControlLoop(controlLoop);
// TODO: We should look up the correct TOSCA node template here for the control loop
// Tiny hack implemented to return the tosca service template entry from the database and be passed onto dmaap
- commissioningProvider = CommissioningHandler.getInstance().getProvider();
+ var commissioningProvider = CommissioningHandler.getInstance().getProvider();
pclu.setControlLoopDefinition(commissioningProvider.getToscaServiceTemplate(null, null));
controlLoopUpdatePublisher.send(pclu);
}
private void sendControlLoopStateChange(ControlLoop controlLoop) {
- ParticipantControlLoopStateChange clsc = new ParticipantControlLoopStateChange();
+ var clsc = new ParticipantControlLoopStateChange();
clsc.setControlLoopId(controlLoop.getKey().asIdentifier());
clsc.setMessageId(UUID.randomUUID());
clsc.setOrderedState(controlLoop.getOrderedState());
@@ -363,7 +360,7 @@ public class SupervisionHandler extends ControlLoopHandler {
participantStatusMessage.getParticipantId().getVersion());
if (CollectionUtils.isEmpty(participantList)) {
- Participant participant = new Participant();
+ var participant = new Participant();
participant.setName(participantStatusMessage.getParticipantId().getName());
participant.setVersion(participantStatusMessage.getParticipantId().getVersion());
participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
@@ -397,7 +394,7 @@ public class SupervisionHandler extends ControlLoopHandler {
"PARTICIPANT_STATUS message references unknown control loop: " + controlLoop);
}
- ControlLoop dbControlLoop = controlLoopProvider
+ var dbControlLoop = controlLoopProvider
.getControlLoop(new ToscaConceptIdentifier(controlLoop.getName(), controlLoop.getVersion()));
if (dbControlLoop == null) {
exceptionOccured(Response.Status.NOT_FOUND,
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
index 0ccfddff3..4f3faf8af 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
@@ -21,17 +21,9 @@
package org.onap.policy.clamp.controlloop.runtime.supervision;
import java.io.Closeable;
-import java.util.Collection;
-import java.util.List;
-import java.util.TimerTask;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;