* ============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.
* You may obtain a copy of the License at
@Override
public ClElementStatistics toAuthorative() {
- ClElementStatistics clElementStatistics = new ClElementStatistics();
+ var clElementStatistics = new ClElementStatistics();
clElementStatistics.setId(UUID.fromString(getKey().getReferenceKey().getLocalName()));
clElementStatistics.setTimeStamp(key.getInstant());
clElementStatistics.setParticipantId(new ToscaConceptIdentifier(participantId));
* ============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.
* You may obtain a copy of the License at
@Override
public ControlLoopElement toAuthorative() {
- ControlLoopElement element = new ControlLoopElement();
+ var element = new ControlLoopElement();
element.setId(UUID.fromString(getKey().getLocalName()));
element.setDefinition(new ToscaConceptIdentifier(definition));
* ============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.
* You may obtain a copy of the License at
@Override
public ParticipantStatistics toAuthorative() {
- ParticipantStatistics participantStatistics = new ParticipantStatistics();
+ var participantStatistics = new ParticipantStatistics();
participantStatistics.setTimeStamp(key.getTimeStamp().toInstant());
participantStatistics.setParticipantId(new ToscaConceptIdentifier(participantId));
participantStatistics.setState(state);
* ============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.
* You may obtain a copy of the License at
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
/**
* Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to controlloop runtime.
* ============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.
* You may obtain a copy of the License at
if (loop == null || loop.getComponents() == null || loop.getComponents().isEmpty()) {
return STATUS_NOT_FOUND;
}
- ExternalComponent externalComponent = loop.getComponents().get("DCAE");
+ var externalComponent = loop.getComponents().get("DCAE");
if (externalComponent == null || externalComponent.getComponentState() == null) {
return STATUS_NOT_FOUND;
}
* ============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.
* You may obtain a copy of the License at
ControlLoopOrderedState newState) {
switch (newState) {
case UNINITIALISED:
- Loop loop = clampClient.getstatus(LOOP);
+ var loop = clampClient.getstatus(LOOP);
if (loop != null) {
clampClient.undeploy(LOOP);
intermediaryApi.updateControlLoopElementState(controlLoopElementId, newState,
}
private Loop getStatus() throws PfModelException {
- Loop loop = clampClient.getstatus(LOOP);
+ var loop = clampClient.getstatus(LOOP);
if (loop == null) {
loop = clampClient.create(LOOP, TEMPLATE);
}
public void controlLoopElementUpdate(ControlLoopElement element, ToscaNodeTemplate nodeTemplate)
throws PfModelException {
try {
- Loop loop = getStatus();
+ var loop = getStatus();
if (BLUEPRINT_DEPLOYED.equals(ClampHttpClient.getStatusCode(loop))) {
deploy();
- boolean deployedFlag = false;
- for (int i = 0; i < checkCount; i++) {
+ var deployedFlag = false;
+ for (var i = 0; i < checkCount; i++) {
// sleep 10 seconds
TimeUnit.SECONDS.sleep(secCount);
loop = getStatus();
}
} catch (PfModelException e) {
throw e;
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new PfModelException(null, e.getMessage(), e);
} catch (Exception e) {
throw new PfModelException(null, e.getMessage(), e);
}
*/
@Override
public void handleStatistics(UUID controlLoopElementId) {
- ControlLoopElement clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
+ var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
if (clElement != null) {
- ClElementStatistics clElementStatistics = new ClElementStatistics();
+ var clElementStatistics = new ClElementStatistics();
clElementStatistics.setControlLoopState(clElement.getState());
clElementStatistics.setTimeStamp(Instant.now());
intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
* ============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.
* You may obtain a copy of the License at
ControlLoopElementHandler controlLoopElementHandler =
new ControlLoopElementHandler(clampClient, consulClient, commonTestData.getParticipantDcaeParameters());
- when(clampClient.getstatus(eq(LOOP))).thenReturn(new Loop());
+ when(clampClient.getstatus(LOOP)).thenReturn(new Loop());
ParticipantIntermediaryApi intermediaryApi = mock(ParticipantIntermediaryApi.class);
controlLoopElementHandler.setIntermediaryApi(intermediaryApi);
controlLoopElementHandler.controlLoopElementStateChange(controlLoopElementId, ControlLoopState.PASSIVE,
ControlLoopOrderedState.UNINITIALISED);
- verify(clampClient).undeploy(eq(LOOP));
+ verify(clampClient).undeploy(LOOP);
controlLoopElementHandler.handleStatistics(controlLoopElementId);
assertThat(intermediaryApi.getControlLoopElement(controlLoopElementId)).isNull();
}
void testCreate_ControlLoopElementUpdate() throws PfModelException, JSONException, CoderException {
ClampHttpClient clampClient = spy(mock(ClampHttpClient.class));
Loop loopDeployed = CODER.convert(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED), Loop.class);
- when(clampClient.create(eq(LOOP), eq(TEMPLATE))).thenReturn(loopDeployed);
- when(clampClient.deploy(eq(LOOP))).thenReturn(true);
+ when(clampClient.create(LOOP, TEMPLATE)).thenReturn(loopDeployed);
+ when(clampClient.deploy(LOOP)).thenReturn(true);
Loop loopInstalled =
CODER.convert(CommonTestData.createJsonStatus(MICROSERVICE_INSTALLED_SUCCESSFULLY), Loop.class);
- when(clampClient.getstatus(eq(LOOP))).thenReturn(null, loopInstalled);
+ when(clampClient.getstatus(LOOP)).thenReturn(null, loopInstalled);
ConsulDcaeHttpClient consulClient = spy(mock(ConsulDcaeHttpClient.class));
when(consulClient.deploy(any(String.class), any(String.class))).thenReturn(true);
controlLoopDefinition.getToscaTopologyTemplate().getNodeTemplates()
.get("org.onap.domain.pmsh.PMSH_DCAEMicroservice"));
- verify(clampClient).create(eq(LOOP), eq(TEMPLATE));
+ verify(clampClient).create(LOOP, TEMPLATE);
verify(consulClient).deploy(any(String.class), any(String.class));
- verify(clampClient).deploy(eq(LOOP));
+ verify(clampClient).deploy(LOOP);
}
@Test
Loop loopDeployed = CODER.convert(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED), Loop.class);
Loop loopInstalled =
CODER.convert(CommonTestData.createJsonStatus(MICROSERVICE_INSTALLED_SUCCESSFULLY), Loop.class);
- when(clampClient.getstatus(eq(LOOP))).thenReturn(loopDeployed, loopInstalled);
- when(clampClient.deploy(eq(LOOP))).thenReturn(true);
+ when(clampClient.getstatus(LOOP)).thenReturn(loopDeployed, loopInstalled);
+ when(clampClient.deploy(LOOP)).thenReturn(true);
ConsulDcaeHttpClient consulClient = spy(mock(ConsulDcaeHttpClient.class));
when(consulClient.deploy(any(String.class), any(String.class))).thenReturn(true);
controlLoopDefinition.getToscaTopologyTemplate().getNodeTemplates()
.get("org.onap.domain.pmsh.PMSH_DCAEMicroservice"));
- verify(clampClient, times(0)).create(eq(LOOP), eq(TEMPLATE));
+ verify(clampClient, times(0)).create(LOOP, TEMPLATE);
verify(consulClient).deploy(any(String.class), any(String.class));
- verify(clampClient).deploy(eq(LOOP));
+ verify(clampClient).deploy(LOOP);
}
}
* ========================LICENSE_START=================================
* Copyright (C) 2021 Nordix Foundation. 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
package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations;
-import org.apache.catalina.connector.Connector;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;
* ========================LICENSE_START=================================
* Copyright (C) 2021 Nordix Foundation. 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
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
* ========================LICENSE_START=================================
* Copyright (C) 2021 Nordix Foundation. 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
try (var out = new PrintStream(new FileOutputStream(getFile(chart)))) {
out.print(STANDARD_CODER.encode(chart));
} catch (Exception exc) {
- LOGGER.warn("Could not store chart: {} {}", chart.getChartId(), exc);
+ LOGGER.warn("Could not store chart: {}", chart.getChartId(), exc);
}
}
private synchronized void restoreFromLocalFileSystem() {
try {
- Path localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory());
+ var localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory());
Files.createDirectories(localChartDirectoryPath);
restoreFromLocalFileSystem(localChartDirectoryPath);
} catch (Exception ioe) {
- LOGGER.warn("Could not restore charts from local file system: {}", ioe);
+ LOGGER.warn("Could not restore charts from local file system", ioe);
}
}
* ============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.
* You may obtain a copy of the License at
}
}
- private void deletePolicyData(UUID controlLoopElementId, ControlLoopOrderedState newState) throws PfModelException {
+ private void deletePolicyData(UUID controlLoopElementId, ControlLoopOrderedState newState) {
// Delete all policies of this controlLoop from policy framework
for (Entry<String, String> policy : policyMap.entrySet()) {
apiHttpClient.deletePolicy(policy.getKey(), policy.getValue());
*/
@Override
public void handleStatistics(UUID controlLoopElementId) throws PfModelException {
- ControlLoopElement clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
+ var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
if (clElement != null) {
- ClElementStatistics clElementStatistics = new ClElementStatistics();
+ var clElementStatistics = new ClElementStatistics();
clElementStatistics.setControlLoopState(clElement.getState());
clElementStatistics.setTimeStamp(Instant.now());
intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
* ============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.
* You may obtain a copy of the License at
@Override
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
- Yaml yaml = new Yaml();
+ var yaml = new Yaml();
return yaml.loadAs(inputMessage.getBody(), clazz);
}
@Override
protected void writeInternal(T t, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
- Yaml yaml = new Yaml();
- try (OutputStreamWriter writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) {
+ var yaml = new Yaml();
+ try (var writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) {
yaml.dump(t, writer);
}
}
* ============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.
* You may obtain a copy of the License at
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseEntity<CommissioningResponse> handleBadRequest(ControlLoopException ex) {
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(ex.getErrorResponse().getErrorMessage());
return ResponseEntity.status(ex.getErrorResponse().getResponseCode().getStatusCode()).body(resp);
* ============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.
* You may obtain a copy of the License at
Map<String, Object> map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request),
ErrorAttributeOptions.defaults());
- StringBuilder sb = new StringBuilder();
+ var sb = new StringBuilder();
final Object error = map.get("error");
if (error != null) {
sb.append(error.toString() + " ");
* ============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.
* You may obtain a copy of the License at
HttpServletResponse res = (HttpServletResponse) response;
HttpServletRequest req = (HttpServletRequest) request;
+ /*
+ * Disabling sonar because of ONAP requires the request ID to be copied from the request
+ * to the response, and just a simulator used during testing.
+ */
String requestId = req.getHeader(REQUEST_ID_NAME);
- res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString());
+ res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString()); // NOSONAR
res.addHeader(VERSION_MINOR_NAME, "0");
res.addHeader(VERSION_PATCH_NAME, "0");
* ============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.
* You may obtain a copy of the License at
import java.util.function.Consumer;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.listeners.ScoListener;
* ============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.
* You may obtain a copy of the License at
LOGGER.warn("Cannot update Control loop element state, id is null");
}
- ControlLoopAck controlLoopStateChangeAck =
+ var controlLoopStateChangeAck =
new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK);
ControlLoopElement clElement = elementsOnThisParticipant.get(id);
if (clElement != null) {
* ============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.
* You may obtain a copy of the License at
this.participantStatistics.setHealthStatus(healthStatus);
this.participantStatistics.setTimeStamp(Instant.now());
- ParticipantStatus heartbeat = new ParticipantStatus();
+ var heartbeat = new ParticipantStatus();
heartbeat.setParticipantId(participantId);
heartbeat.setParticipantStatistics(participantStatistics);
heartbeat.setParticipantType(participantType);
* ============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.
* You may obtain a copy of the License at
HttpServletResponse res = (HttpServletResponse) response;
HttpServletRequest req = (HttpServletRequest) request;
+ /*
+ * Disabling sonar because of ONAP requires the request ID to be copied from the request
+ * to the response.
+ */
String requestId = req.getHeader(REQUEST_ID_NAME);
- res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString());
+ res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString()); // NOSONAR
res.addHeader(VERSION_MINOR_NAME, "0");
res.addHeader(VERSION_PATCH_NAME, "0");
* @param serviceName service name
*/
public void entering(HttpServletRequest request, String serviceName) {
- // MDC.clear();
checkNotNull(request);
// Extract MDC values from standard HTTP headers.
final String requestId =
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}