diff options
Diffstat (limited to 'controlloop')
30 files changed, 525 insertions, 562 deletions
diff --git a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java index 8660aa3e2..323b54d9c 100644 --- a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java +++ b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017-2018 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018-2019 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. @@ -34,10 +34,10 @@ import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.rest.RESTManager; -import org.onap.policy.vfc.VFCHealActionVmInfo; -import org.onap.policy.vfc.VFCHealAdditionalParams; -import org.onap.policy.vfc.VFCHealRequest; -import org.onap.policy.vfc.VFCRequest; +import org.onap.policy.vfc.VfcHealActionVmInfo; +import org.onap.policy.vfc.VfcHealAdditionalParams; +import org.onap.policy.vfc.VfcHealRequest; +import org.onap.policy.vfc.VfcRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,11 +86,11 @@ public class VfcActorServiceProvider implements Actor { * @param vnfResponse the VNF response * @return the constructed request */ - public static VFCRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, + public static VfcRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy, AaiGetVnfResponse vnfResponse) { // Construct an VFC request - VFCRequest request = new VFCRequest(); + VfcRequest request = new VfcRequest(); String serviceInstance = onset.getAai().get("service-instance.service-instance-id"); if (serviceInstance == null || "".equals(serviceInstance)) { AaiGetVnfResponse tempVnfResp = vnfResponse; @@ -103,16 +103,16 @@ public class VfcActorServiceProvider implements Actor { } serviceInstance = tempVnfResp.getServiceId(); } - request.setNSInstanceId(serviceInstance); + request.setNsInstanceId(serviceInstance); request.setRequestId(onset.getRequestId()); - request.setHealRequest(new VFCHealRequest()); + request.setHealRequest(new VfcHealRequest()); request.getHealRequest().setVnfInstanceId(onset.getAai().get("generic-vnf.vnf-id")); request.getHealRequest().setCause(operation.getMessage()); - request.getHealRequest().setAdditionalParams(new VFCHealAdditionalParams()); + request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams()); if (policy.getRecipe().toLowerCase().equalsIgnoreCase(RECIPE_RESTART)) { request.getHealRequest().getAdditionalParams().setAction("restartvm"); - request.getHealRequest().getAdditionalParams().setActionInfo(new VFCHealActionVmInfo()); + request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo()); request.getHealRequest().getAdditionalParams().getActionInfo() .setVmid(onset.getAai().get("vserver.vserver-id")); request.getHealRequest().getAdditionalParams().getActionInfo() diff --git a/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java b/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java index 02387b641..9e6b5b827 100644 --- a/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java +++ b/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java @@ -1,9 +1,9 @@ /*- * ============LICENSE_START======================================================= - * TestVFCActorServiceProvider + * ONAP - Policy Drools Applications * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corp. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corp. 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. @@ -39,7 +39,7 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.simulators.Util; -import org.onap.policy.vfc.VFCRequest; +import org.onap.policy.vfc.VfcRequest; public class VfcActorServiceProviderTest { @@ -97,7 +97,7 @@ public class VfcActorServiceProviderTest { policy.setRecipe("Restart"); assertNotNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse())); - VFCRequest request = + VfcRequest request = VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse()); assertEquals(requestId, Objects.requireNonNull(request).getRequestId()); diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index 5abfca47b..36db9fe53 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * controlloop operation manager * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -54,7 +54,7 @@ import org.onap.policy.guard.Util; import org.onap.policy.sdnc.SdncResponse; import org.onap.policy.sdnr.PciResponseWrapper; import org.onap.policy.so.SOResponseWrapper; -import org.onap.policy.vfc.VFCResponse; +import org.onap.policy.vfc.VfcResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -351,11 +351,11 @@ public class ControlLoopOperationManager implements Serializable { // Cast SO response and handle it // return onResponse((SOResponseWrapper) response); - } else if (response instanceof VFCResponse) { + } else if (response instanceof VfcResponse) { // // Cast VFC response and handle it // - return onResponse((VFCResponse) response); + return onResponse((VfcResponse) response); } else if (response instanceof SdncResponse) { // // Cast SDNC response and handle it @@ -563,7 +563,7 @@ public class ControlLoopOperationManager implements Serializable { * @param vfcResponse the VFC response * @return The result of the response handling */ - private PolicyResult onResponse(VFCResponse vfcResponse) { + private PolicyResult onResponse(VfcResponse vfcResponse) { if ("finished".equalsIgnoreCase(vfcResponse.getResponseDescriptor().getStatus())) { // // Consider it as success diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java index 0afe9d2d3..f761d69b7 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * unit test * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -73,8 +73,8 @@ import org.onap.policy.controlloop.processor.ControlLoopProcessor; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.so.SOResponse; import org.onap.policy.so.SOResponseWrapper; -import org.onap.policy.vfc.VFCResponse; -import org.onap.policy.vfc.VFCResponseDescriptor; +import org.onap.policy.vfc.VfcResponse; +import org.onap.policy.vfc.VfcResponseDescriptor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -753,8 +753,8 @@ public class ControlLoopOperationManagerTest { soResponse.setHttpResponseCode(500); assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw)); - VFCResponse vfcResponse = new VFCResponse(); - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + VfcResponse vfcResponse = new VfcResponse(); + VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); vfcResponse.setResponseDescriptor(responseDescriptor); responseDescriptor.setStatus("finished"); diff --git a/controlloop/common/feature-controlloop-trans/checkstyle-suppressions.xml b/controlloop/common/feature-controlloop-trans/checkstyle-suppressions.xml deleted file mode 100644 index f4ceebd66..000000000 --- a/controlloop/common/feature-controlloop-trans/checkstyle-suppressions.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2018 AT&T Technologies. All rights reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - SPDX-License-Identifier: Apache-2.0 - ============LICENSE_END========================================================= ---> - -<!DOCTYPE suppressions PUBLIC - "-//Puppy Crawl//DTD Suppressions 1.0//EN" - "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd"> - -<suppressions> - <suppress checks="OneTopLevelClass" - files="ControlLoopMetrics.java" - lines="1-9999"/> -</suppressions> diff --git a/controlloop/common/feature-controlloop-trans/pom.xml b/controlloop/common/feature-controlloop-trans/pom.xml index 1a6261c43..0aa320ad3 100644 --- a/controlloop/common/feature-controlloop-trans/pom.xml +++ b/controlloop/common/feature-controlloop-trans/pom.xml @@ -2,7 +2,7 @@ ============LICENSE_START======================================================= ONAP ================================================================================ - Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2018-2019 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. @@ -104,7 +104,6 @@ <includeTestResources>true</includeTestResources> <excludes> </excludes> - <suppressionsLocation>${project.basedir}/checkstyle-suppressions.xml</suppressionsLocation> <consoleOutput>true</consoleOutput> <failsOnViolation>true</failsOnViolation> <violationSeverity>warning</violationSeverity> diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java new file mode 100644 index 000000000..c5d6a32ac --- /dev/null +++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java @@ -0,0 +1,360 @@ +/* + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.drools.apps.controlloop.feature.trans; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + +import java.time.Instant; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +import org.onap.policy.controlloop.ControlLoopOperation; +import org.onap.policy.controlloop.VirtualControlLoopNotification; +import org.onap.policy.drools.persistence.SystemPersistence; +import org.onap.policy.drools.system.PolicyController; +import org.onap.policy.drools.utils.logging.MDCTransaction; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Control Loop Metrics Tracker Implementation. + */ +class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics { + + private static final Logger logger = LoggerFactory.getLogger(CacheBasedControlLoopMetricsManager.class); + + private LoadingCache<UUID, VirtualControlLoopNotification> cache; + private long cacheSize = ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_DEFAULT; + + private long transactionTimeout = ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT; + + public CacheBasedControlLoopMetricsManager() { + + Properties properties = + SystemPersistence.manager.getProperties(ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME); + + /* cache size */ + + try { + this.cacheSize = + Long.parseLong(properties.getProperty(ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_PROPERTY, + "" + ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_DEFAULT)); + } catch (Exception e) { + logger.warn("{}:{} property cannot be accessed", ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME, + ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_PROPERTY, e); + } + + /* transaction timeout */ + + try { + this.transactionTimeout = Long + .parseLong(properties.getProperty(ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY, + "" + ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT)); + } catch (Exception e) { + logger.warn("{}:{} property cannot be accessed", ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME, + ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY, e); + } + + resetCache(this.cacheSize, this.transactionTimeout); + } + + @Override + public void resetCache(long cacheSize, long transactionTimeout) { + this.cacheSize = cacheSize; + this.transactionTimeout = transactionTimeout; + + CacheLoader<UUID, VirtualControlLoopNotification> loader = + new CacheLoader<UUID, VirtualControlLoopNotification>() { + + @Override + public VirtualControlLoopNotification load(UUID key) throws Exception { + return null; + } + }; + + RemovalListener<UUID, VirtualControlLoopNotification> listener = + new RemovalListener<UUID, VirtualControlLoopNotification>() { + @Override + public void onRemoval(RemovalNotification<UUID, VirtualControlLoopNotification> notification) { + if (notification.wasEvicted()) { + evicted(notification.getValue()); + } else { + logger.info("REMOVAL: {} because of {}", notification.getValue().getRequestId(), + notification.getCause().name()); + } + } + }; + + synchronized (this) { + if (this.cache != null) { + this.cache.cleanUp(); + this.cache.invalidateAll(); + } + + this.cache = CacheBuilder.newBuilder().maximumSize(this.cacheSize) + .expireAfterWrite(transactionTimeout, TimeUnit.SECONDS).removalListener(listener).build(loader); + } + } + + @Override + public void refresh() { + this.cache.cleanUp(); + } + + @Override + public List<UUID> getTransactionIds() { + return new ArrayList<>(this.cache.asMap().keySet()); + } + + @Override + public List<VirtualControlLoopNotification> getTransactions() { + return new ArrayList<>(this.cache.asMap().values()); + } + + @Override + public void transactionEvent(PolicyController controller, VirtualControlLoopNotification notification) { + if (notification == null || notification.getRequestId() == null || notification.getNotification() == null) { + logger.warn("Invalid notification: {}", notification); + return; + } + + if (notification.getNotificationTime() == null) { + notification.setNotificationTime(ZonedDateTime.now()); + } + + notification.setFrom(notification.getFrom() + ":" + controller.getName()); + + switch (notification.getNotification()) { + case REJECTED: + case FINAL_FAILURE: + case FINAL_SUCCESS: + case FINAL_OPENLOOP: + endTransaction(notification); + break; + case ACTIVE: + case OPERATION: + case OPERATION_SUCCESS: + case OPERATION_FAILURE: + /* any other value is an in progress transaction */ + inProgressTransaction(notification); + break; + default: + /* unexpected */ + logger.warn("unexpected notification type {} in notification {}", + notification.getNotification().toString(), notification); + break; + } + } + + @Override + public VirtualControlLoopNotification getTransaction(UUID requestId) { + return cache.getIfPresent(requestId); + } + + @Override + public void removeTransaction(UUID requestId) { + cache.invalidate(requestId); + } + + /** + * Tracks an in progress control loop transaction. + * + * @param notification control loop notification + */ + protected void inProgressTransaction(VirtualControlLoopNotification notification) { + if (cache.getIfPresent(notification.getRequestId()) == null) { + cache.put(notification.getRequestId(), notification); + } + + this.metric(notification); + } + + /** + * End of a control loop transaction. + * + * @param notification control loop notification + */ + protected void endTransaction(VirtualControlLoopNotification notification) { + ZonedDateTime startTime; + VirtualControlLoopNotification startNotification = cache.getIfPresent(notification.getRequestId()); + if (startNotification != null) { + startTime = startNotification.getNotificationTime(); + } else { + startTime = notification.getNotificationTime(); + } + + this.transaction(notification, startTime); + if (startNotification != null) { + cache.invalidate(startNotification); + } + } + + protected void evicted(VirtualControlLoopNotification notification) { + MDCTransaction + .newTransaction(notification.getRequestId().toString(), notification.getFrom()) + .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget()) + .setStartTime(notification.getNotificationTime().toInstant()).setEndTime(Instant.now()) + .setResponseDescription("EVICTED").setStatusCode(false).metric().resetTransaction(); + } + + @Override + public long getCacheSize() { + return this.cacheSize; + } + + @Override + public void setMaxCacheSize(long cacheSize) { + this.cacheSize = cacheSize; + } + + @Override + public long getTransactionTimeout() { + return this.transactionTimeout; + } + + @Override + public void setTransactionTimeout(long transactionTimeout) { + this.transactionTimeout = transactionTimeout; + } + + @Override + public long getCacheOccupancy() { + return this.cache.size(); + } + + protected void metric(VirtualControlLoopNotification notification) { + MDCTransaction trans = MDCTransaction + .newTransaction(notification.getRequestId().toString(), notification.getFrom()) + .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget()); + + List<ControlLoopOperation> operations = notification.getHistory(); + switch (notification.getNotification()) { + case ACTIVE: + trans.setStatusCode(true); + trans.metric().resetTransaction(); + break; + case OPERATION: + trans.setStatusCode(true); + if (!operations.isEmpty()) { + ControlLoopOperation operation = operations.get(operations.size() - 1); + trans.setTargetEntity(operation.getTarget()); + trans.setTargetServiceName(operation.getActor()); + } + trans.metric().resetTransaction(); + break; + case OPERATION_SUCCESS: + trans.setStatusCode(true); + operation(trans, operations); + trans.transaction().resetTransaction(); + break; + case OPERATION_FAILURE: + trans.setStatusCode(false); + operation(trans, operations); + trans.transaction().resetTransaction(); + break; + default: + /* unexpected */ + logger.warn("unexpected notification type {} in notification {}", + notification.getNotification().toString(), notification); + break; + } + } + + protected void operation(MDCTransaction trans, List<ControlLoopOperation> operations) { + if (!operations.isEmpty()) { + ControlLoopOperation operation = operations.get(operations.size() - 1); + + if (operation.getTarget() != null) { + trans.setTargetEntity(operation.getTarget()); + } + + if (operation.getActor() != null) { + trans.setTargetServiceName(operation.getActor()); + } + + if (operation.getMessage() != null) { + trans.setResponseDescription(operation.getMessage()); + } + + trans.setInvocationId(operation.getSubRequestId()); + + if (operation.getOutcome() != null) { + trans.setResponseCode(operation.getOutcome()); + } + + if (operation.getStart() != null) { + trans.setStartTime(operation.getStart()); + } + + if (operation.getEnd() != null) { + trans.setEndTime(operation.getEnd()); + } + } + } + + protected void transaction(VirtualControlLoopNotification notification, ZonedDateTime startTime) { + MDCTransaction trans = MDCTransaction + .newTransaction(notification.getRequestId().toString(), notification.getFrom()) + .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget()) + .setStartTime(startTime.toInstant()).setEndTime(notification.getNotificationTime().toInstant()) + .setResponseDescription(notification.getMessage()); + + switch (notification.getNotification()) { + case FINAL_OPENLOOP: + trans.setStatusCode(true); + break; + case FINAL_SUCCESS: + trans.setStatusCode(true); + break; + case FINAL_FAILURE: + trans.setStatusCode(false); + break; + case REJECTED: + trans.setStatusCode(false); + break; + default: + /* unexpected */ + logger.warn("unexpected notification type {} in notification {}", + notification.getNotification(), notification); + break; + } + + trans.transaction().resetTransaction(); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("CacheBasedControlLoopMetricsManager{"); + sb.append("cacheSize=").append(cacheSize); + sb.append(", transactionTimeout=").append(transactionTimeout); + sb.append('}'); + return sb.toString(); + } +} diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java index 2d7bfa6c0..a7c8f11df 100644 --- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java +++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. @@ -20,27 +20,10 @@ package org.onap.policy.drools.apps.controlloop.feature.trans; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - -import java.time.Instant; -import java.time.ZonedDateTime; -import java.util.ArrayList; import java.util.List; -import java.util.Properties; import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.drools.persistence.SystemPersistence; import org.onap.policy.drools.system.PolicyController; -import org.onap.policy.drools.utils.logging.MDCTransaction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Control Loop Metrics Tracker. @@ -137,321 +120,3 @@ public interface ControlLoopMetrics { */ void refresh(); } - - -/** - * Control Loop Metrics Tracker Implementation. - */ -class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics { - - private static final Logger logger = LoggerFactory.getLogger(CacheBasedControlLoopMetricsManager.class); - - private LoadingCache<UUID, VirtualControlLoopNotification> cache; - private long cacheSize = ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_DEFAULT; - - private long transactionTimeout = ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT; - - public CacheBasedControlLoopMetricsManager() { - - Properties properties = - SystemPersistence.manager.getProperties(ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME); - - /* cache size */ - - try { - this.cacheSize = - Long.parseLong(properties.getProperty(ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_PROPERTY, - "" + ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_DEFAULT)); - } catch (Exception e) { - logger.warn("{}:{} property cannot be accessed", ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME, - ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_PROPERTY, e); - } - - /* transaction timeout */ - - try { - this.transactionTimeout = Long - .parseLong(properties.getProperty(ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY, - "" + ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT)); - } catch (Exception e) { - logger.warn("{}:{} property cannot be accessed", ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME, - ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY, e); - } - - resetCache(this.cacheSize, this.transactionTimeout); - } - - @Override - public void resetCache(long cacheSize, long transactionTimeout) { - this.cacheSize = cacheSize; - this.transactionTimeout = transactionTimeout; - - CacheLoader<UUID, VirtualControlLoopNotification> loader = - new CacheLoader<UUID, VirtualControlLoopNotification>() { - - @Override - public VirtualControlLoopNotification load(UUID key) throws Exception { - return null; - } - }; - - RemovalListener<UUID, VirtualControlLoopNotification> listener = - new RemovalListener<UUID, VirtualControlLoopNotification>() { - @Override - public void onRemoval(RemovalNotification<UUID, VirtualControlLoopNotification> notification) { - if (notification.wasEvicted()) { - evicted(notification.getValue()); - } else { - logger.info("REMOVAL: {} because of {}", notification.getValue().getRequestId(), - notification.getCause().name()); - } - } - }; - - synchronized (this) { - if (this.cache != null) { - this.cache.cleanUp(); - this.cache.invalidateAll(); - } - - this.cache = CacheBuilder.newBuilder().maximumSize(this.cacheSize) - .expireAfterWrite(transactionTimeout, TimeUnit.SECONDS).removalListener(listener).build(loader); - } - } - - @Override - public void refresh() { - this.cache.cleanUp(); - } - - @Override - public List<UUID> getTransactionIds() { - return new ArrayList<>(this.cache.asMap().keySet()); - } - - @Override - public List<VirtualControlLoopNotification> getTransactions() { - return new ArrayList<>(this.cache.asMap().values()); - } - - @Override - public void transactionEvent(PolicyController controller, VirtualControlLoopNotification notification) { - if (notification == null || notification.getRequestId() == null || notification.getNotification() == null) { - logger.warn("Invalid notification: {}", notification); - return; - } - - if (notification.getNotificationTime() == null) { - notification.setNotificationTime(ZonedDateTime.now()); - } - - notification.setFrom(notification.getFrom() + ":" + controller.getName()); - - switch (notification.getNotification()) { - case REJECTED: - case FINAL_FAILURE: - case FINAL_SUCCESS: - case FINAL_OPENLOOP: - endTransaction(notification); - break; - case ACTIVE: - case OPERATION: - case OPERATION_SUCCESS: - case OPERATION_FAILURE: - /* any other value is an in progress transaction */ - inProgressTransaction(notification); - break; - default: - /* unexpected */ - logger.warn("unexpected notification type {} in notification {}", - notification.getNotification().toString(), notification); - break; - } - } - - @Override - public VirtualControlLoopNotification getTransaction(UUID requestId) { - return cache.getIfPresent(requestId); - } - - @Override - public void removeTransaction(UUID requestId) { - cache.invalidate(requestId); - } - - /** - * Tracks an in progress control loop transaction. - * - * @param notification control loop notification - */ - protected void inProgressTransaction(VirtualControlLoopNotification notification) { - if (cache.getIfPresent(notification.getRequestId()) == null) { - cache.put(notification.getRequestId(), notification); - } - - this.metric(notification); - } - - /** - * End of a control loop transaction. - * - * @param notification control loop notification - */ - protected void endTransaction(VirtualControlLoopNotification notification) { - ZonedDateTime startTime; - VirtualControlLoopNotification startNotification = cache.getIfPresent(notification.getRequestId()); - if (startNotification != null) { - startTime = startNotification.getNotificationTime(); - } else { - startTime = notification.getNotificationTime(); - } - - this.transaction(notification, startTime); - if (startNotification != null) { - cache.invalidate(startNotification); - } - } - - protected void evicted(VirtualControlLoopNotification notification) { - MDCTransaction - .newTransaction(notification.getRequestId().toString(), notification.getFrom()) - .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget()) - .setStartTime(notification.getNotificationTime().toInstant()).setEndTime(Instant.now()) - .setResponseDescription("EVICTED").setStatusCode(false).metric().resetTransaction(); - } - - @Override - public long getCacheSize() { - return this.cacheSize; - } - - @Override - public void setMaxCacheSize(long cacheSize) { - this.cacheSize = cacheSize; - } - - @Override - public long getTransactionTimeout() { - return this.transactionTimeout; - } - - @Override - public void setTransactionTimeout(long transactionTimeout) { - this.transactionTimeout = transactionTimeout; - } - - @Override - public long getCacheOccupancy() { - return this.cache.size(); - } - - protected void metric(VirtualControlLoopNotification notification) { - MDCTransaction trans = MDCTransaction - .newTransaction(notification.getRequestId().toString(), notification.getFrom()) - .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget()); - - List<ControlLoopOperation> operations = notification.getHistory(); - switch (notification.getNotification()) { - case ACTIVE: - trans.setStatusCode(true); - trans.metric().resetTransaction(); - break; - case OPERATION: - trans.setStatusCode(true); - if (!operations.isEmpty()) { - ControlLoopOperation operation = operations.get(operations.size() - 1); - trans.setTargetEntity(operation.getTarget()); - trans.setTargetServiceName(operation.getActor()); - } - trans.metric().resetTransaction(); - break; - case OPERATION_SUCCESS: - trans.setStatusCode(true); - operation(trans, operations); - trans.transaction().resetTransaction(); - break; - case OPERATION_FAILURE: - trans.setStatusCode(false); - operation(trans, operations); - trans.transaction().resetTransaction(); - break; - default: - /* unexpected */ - logger.warn("unexpected notification type {} in notification {}", - notification.getNotification().toString(), notification); - break; - } - } - - protected void operation(MDCTransaction trans, List<ControlLoopOperation> operations) { - if (!operations.isEmpty()) { - ControlLoopOperation operation = operations.get(operations.size() - 1); - - if (operation.getTarget() != null) { - trans.setTargetEntity(operation.getTarget()); - } - - if (operation.getActor() != null) { - trans.setTargetServiceName(operation.getActor()); - } - - if (operation.getMessage() != null) { - trans.setResponseDescription(operation.getMessage()); - } - - trans.setInvocationId(operation.getSubRequestId()); - - if (operation.getOutcome() != null) { - trans.setResponseCode(operation.getOutcome()); - } - - if (operation.getStart() != null) { - trans.setStartTime(operation.getStart()); - } - - if (operation.getEnd() != null) { - trans.setEndTime(operation.getEnd()); - } - } - } - - protected void transaction(VirtualControlLoopNotification notification, ZonedDateTime startTime) { - MDCTransaction trans = MDCTransaction - .newTransaction(notification.getRequestId().toString(), notification.getFrom()) - .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget()) - .setStartTime(startTime.toInstant()).setEndTime(notification.getNotificationTime().toInstant()) - .setResponseDescription(notification.getMessage()); - - switch (notification.getNotification()) { - case FINAL_OPENLOOP: - trans.setStatusCode(true); - break; - case FINAL_SUCCESS: - trans.setStatusCode(true); - break; - case FINAL_FAILURE: - trans.setStatusCode(false); - break; - case REJECTED: - trans.setStatusCode(false); - break; - default: - /* unexpected */ - logger.warn("unexpected notification type {} in notification {}", - notification.getNotification(), notification); - break; - } - - trans.transaction().resetTransaction(); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("CacheBasedControlLoopMetricsManager{"); - sb.append("cacheSize=").append(cacheSize); - sb.append(", transactionTimeout=").append(transactionTimeout); - sb.append('}'); - return sb.toString(); - } -} diff --git a/controlloop/common/model-impl/vfc/checkstyle-suppressions.xml b/controlloop/common/model-impl/vfc/checkstyle-suppressions.xml deleted file mode 100644 index ea04e03f1..000000000 --- a/controlloop/common/model-impl/vfc/checkstyle-suppressions.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2018 AT&T Technologies. All rights reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - SPDX-License-Identifier: Apache-2.0 - ============LICENSE_END========================================================= ---> - -<!DOCTYPE suppressions PUBLIC - "-//Puppy Crawl//DTD Suppressions 1.0//EN" - "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd"> - -<suppressions> - <suppress checks="AbbreviationAsWordInName" - files="VFCManager.java|VFCHealActionVmInfo.java|VFCHealAdditionalParams.java|VFCHealRequest.java|VFCRequest.java|VFCResponseDescriptor.java|VFCResponse.java" - lines="1-9999"/> -</suppressions> diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml index d5de89f6e..1df42831b 100644 --- a/controlloop/common/model-impl/vfc/pom.xml +++ b/controlloop/common/model-impl/vfc/pom.xml @@ -92,7 +92,6 @@ <includeTestResources>true</includeTestResources> <excludes> </excludes> - <suppressionsLocation>${project.basedir}/checkstyle-suppressions.xml</suppressionsLocation> <consoleOutput>true</consoleOutput> <failsOnViolation>true</failsOnViolation> <violationSeverity>warning</violationSeverity> diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealActionVmInfo.java index 0286a7d8b..c154f7226 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealActionVmInfo.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -23,7 +23,7 @@ import com.google.gson.annotations.SerializedName; import java.io.Serializable; -public class VFCHealActionVmInfo implements Serializable { +public class VfcHealActionVmInfo implements Serializable { private static final long serialVersionUID = 3208673205100673119L; @@ -33,8 +33,8 @@ public class VFCHealActionVmInfo implements Serializable { @SerializedName("vmname") private String vmname; - public VFCHealActionVmInfo() { - // Default constructor for VFCHealActionVmInfo + public VfcHealActionVmInfo() { + // Default constructor } public String getVmid() { diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealAdditionalParams.java index 393e3761f..2c5de3a22 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealAdditionalParams.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -23,7 +23,7 @@ import com.google.gson.annotations.SerializedName; import java.io.Serializable; -public class VFCHealAdditionalParams implements Serializable { +public class VfcHealAdditionalParams implements Serializable { private static final long serialVersionUID = 2656694137285096191L; @@ -31,10 +31,10 @@ public class VFCHealAdditionalParams implements Serializable { private String action; @SerializedName("actionvminfo") - private VFCHealActionVmInfo actionInfo; + private VfcHealActionVmInfo actionInfo; - public VFCHealAdditionalParams() { - // Default constructor for VFCHealAdditionalParams + public VfcHealAdditionalParams() { + // Default constructor } public String getAction() { @@ -45,11 +45,11 @@ public class VFCHealAdditionalParams implements Serializable { this.action = action; } - public VFCHealActionVmInfo getActionInfo() { + public VfcHealActionVmInfo getActionInfo() { return actionInfo; } - public void setActionInfo(VFCHealActionVmInfo actionInfo) { + public void setActionInfo(VfcHealActionVmInfo actionInfo) { this.actionInfo = actionInfo; } } diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealRequest.java index 75b9566b1..55ca4ac5c 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealRequest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -23,7 +23,7 @@ import com.google.gson.annotations.SerializedName; import java.io.Serializable; -public class VFCHealRequest implements Serializable { +public class VfcHealRequest implements Serializable { private static final long serialVersionUID = -7341931593089709247L; @@ -34,10 +34,10 @@ public class VFCHealRequest implements Serializable { private String cause; @SerializedName("additionalParams") - private VFCHealAdditionalParams additionalParams; + private VfcHealAdditionalParams additionalParams; - public VFCHealRequest() { - // Default constructor for VFCHealRequest + public VfcHealRequest() { + // Default constructor } public String getVnfInstanceId() { @@ -56,11 +56,11 @@ public class VFCHealRequest implements Serializable { this.cause = cause; } - public VFCHealAdditionalParams getAdditionalParams() { + public VfcHealAdditionalParams getAdditionalParams() { return additionalParams; } - public void setAdditionalParams(VFCHealAdditionalParams additionalParams) { + public void setAdditionalParams(VfcHealAdditionalParams additionalParams) { this.additionalParams = additionalParams; } } diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java index d84d0403f..2a004bd04 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017-2018 Intel Corp, AT&T. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -32,15 +32,15 @@ import org.onap.policy.vfc.util.Serialization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public final class VFCManager implements Runnable { +public final class VfcManager implements Runnable { private static final String SYSTEM_LS = System.lineSeparator(); private String vfcUrlBase; private String username; private String password; - private VFCRequest vfcRequest; + private VfcRequest vfcRequest; private WorkingMemory workingMem; - private static final Logger logger = LoggerFactory.getLogger(VFCManager.class); + private static final Logger logger = LoggerFactory.getLogger(VfcManager.class); private static final Logger netLogger = LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER); @@ -53,10 +53,10 @@ public final class VFCManager implements Runnable { * @param wm Drools working memory * @param request request */ - public VFCManager(WorkingMemory wm, VFCRequest request) { + public VfcManager(WorkingMemory wm, VfcRequest request) { if (wm == null || request == null) { throw new IllegalArgumentException( - "the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null"); + "the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null"); } workingMem = wm; vfcRequest = request; @@ -64,7 +64,7 @@ public final class VFCManager implements Runnable { restManager = new RESTManager(); // use getPEManagerEnvProperty() for required properties; others are optional - setVFCParams(getPEManagerEnvProperty("vfc.url"), PolicyEngine.manager.getEnvironmentProperty("vfc.username"), + setVfcParams(getPeManagerEnvProperty("vfc.url"), PolicyEngine.manager.getEnvironmentProperty("vfc.username"), PolicyEngine.manager.getEnvironmentProperty("vfc.password")); } @@ -75,7 +75,7 @@ public final class VFCManager implements Runnable { * @param name username * @param pwd password */ - public void setVFCParams(String baseUrl, String name, String pwd) { + public void setVfcParams(String baseUrl, String name, String pwd) { vfcUrlBase = baseUrl + "/api/nslcm/v1"; username = name; password = pwd; @@ -86,12 +86,12 @@ public final class VFCManager implements Runnable { Map<String, String> headers = new HashMap<>(); Pair<Integer, String> httpDetails; - VFCResponse responseError = new VFCResponse(); - responseError.setResponseDescriptor(new VFCResponseDescriptor()); + VfcResponse responseError = new VfcResponse(); + responseError.setResponseDescriptor(new VfcResponseDescriptor()); responseError.getResponseDescriptor().setStatus("error"); headers.put("Accept", "application/json"); - String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.getNSInstanceId() + "/heal"; + String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.getNsInstanceId() + "/heal"; try { String vfcRequestJson = Serialization.gsonPretty.toJson(vfcRequest); netLogger.info("[OUT|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, vfcRequestJson); @@ -114,7 +114,7 @@ public final class VFCManager implements Runnable { } try { - VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VFCResponse.class); + VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); netLogger.info("[IN|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, httpDetails.second); String body = Serialization.gsonPretty.toJson(response); logger.debug("Response to VFC Heal post:"); @@ -124,12 +124,12 @@ public final class VFCManager implements Runnable { int attemptsLeft = 20; String urlGet = vfcUrlBase + "/jobs/" + jobId; - VFCResponse responseGet = null; + VfcResponse responseGet = null; while (attemptsLeft-- > 0) { netLogger.info("[OUT|{}|{}|]", "VFC", urlGet); Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers); - responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.second, VFCResponse.class); + responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.second, VfcResponse.class); netLogger.info("[IN|{}|{}|]{}{}", "VFC", urlGet, SYSTEM_LS, httpDetailsGet.second); responseGet.setRequestId(vfcRequest.getRequestId().toString()); body = Serialization.gsonPretty.toJson(responseGet); @@ -152,12 +152,12 @@ public final class VFCManager implements Runnable { workingMem.insert(responseGet); } } catch (JsonSyntaxException e) { - logger.error("Failed to deserialize into VFCResponse {}", e.getLocalizedMessage(), e); + logger.error("Failed to deserialize into VfcResponse {}", e.getLocalizedMessage(), e); } catch (InterruptedException e) { logger.error("Interrupted exception: {}", e.getLocalizedMessage(), e); Thread.currentThread().interrupt(); } catch (Exception e) { - logger.error("Unknown error deserializing into VFCResponse {}", e.getLocalizedMessage(), e); + logger.error("Unknown error deserializing into VfcResponse {}", e.getLocalizedMessage(), e); } } @@ -178,7 +178,7 @@ public final class VFCManager implements Runnable { * @return the property value */ - private String getPEManagerEnvProperty(String enginePropertyName) { + private String getPeManagerEnvProperty(String enginePropertyName) { String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName); if (enginePropertyValue == null) { throw new IllegalArgumentException("The value of policy engine manager environment property \"" diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcRequest.java index cfcaf8039..c4473e7f1 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcRequest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import com.google.gson.annotations.SerializedName; import java.io.Serializable; import java.util.UUID; -public class VFCRequest implements Serializable { +public class VfcRequest implements Serializable { private static final long serialVersionUID = 3736300970326332512L; // These fields are not serialized and not part of JSON @@ -32,17 +32,17 @@ public class VFCRequest implements Serializable { private transient UUID requestId; @SerializedName("healVnfData") - private VFCHealRequest healRequest; + private VfcHealRequest healRequest; - public VFCRequest() { - // Default constructor for VFCRequest + public VfcRequest() { + // Default constructor } - public String getNSInstanceId() { + public String getNsInstanceId() { return nsInstanceId; } - public void setNSInstanceId(String nsInstanceId) { + public void setNsInstanceId(String nsInstanceId) { this.nsInstanceId = nsInstanceId; } @@ -54,11 +54,11 @@ public class VFCRequest implements Serializable { this.requestId = requestId; } - public VFCHealRequest getHealRequest() { + public VfcHealRequest getHealRequest() { return healRequest; } - public void setHealRequest(VFCHealRequest healRequest) { + public void setHealRequest(VfcHealRequest healRequest) { this.healRequest = healRequest; } } diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponse.java index 21e9472b7..2183be71b 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponse.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -23,7 +23,7 @@ import com.google.gson.annotations.SerializedName; import java.io.Serializable; -public class VFCResponse implements Serializable { +public class VfcResponse implements Serializable { private static final long serialVersionUID = 9151443891238218455L; @@ -31,12 +31,12 @@ public class VFCResponse implements Serializable { private String jobId; @SerializedName("responseDescriptor") - private VFCResponseDescriptor responseDescriptor; + private VfcResponseDescriptor responseDescriptor; private transient String requestId; - public VFCResponse() { - // Default constructor for VFCResponse + public VfcResponse() { + // Default constructor } public String getJobId() { @@ -47,11 +47,11 @@ public class VFCResponse implements Serializable { this.jobId = jobId; } - public VFCResponseDescriptor getResponseDescriptor() { + public VfcResponseDescriptor getResponseDescriptor() { return responseDescriptor; } - public void setResponseDescriptor(VFCResponseDescriptor responseDescriptor) { + public void setResponseDescriptor(VfcResponseDescriptor responseDescriptor) { this.responseDescriptor = responseDescriptor; } diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponseDescriptor.java index cdd4a39a9..147b937dc 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponseDescriptor.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import com.google.gson.annotations.SerializedName; import java.io.Serializable; import java.util.List; -public class VFCResponseDescriptor implements Serializable { +public class VfcResponseDescriptor implements Serializable { private static final long serialVersionUID = 6827782899144150158L; @@ -44,10 +44,10 @@ public class VFCResponseDescriptor implements Serializable { private String responseId; @SerializedName("responseHistoryList") - private List<VFCResponseDescriptor> responseHistoryList; + private List<VfcResponseDescriptor> responseHistoryList; - public VFCResponseDescriptor() { - // Default constructor for VFCResponseDescriptor + public VfcResponseDescriptor() { + // Default constructor } public String getStatus() { @@ -86,11 +86,11 @@ public class VFCResponseDescriptor implements Serializable { this.responseId = responseId; } - public List<VFCResponseDescriptor> getResponseHistoryList() { + public List<VfcResponseDescriptor> getResponseHistoryList() { return responseHistoryList; } - public void setResponseHistoryList(List<VFCResponseDescriptor> responseHistoryList) { + public void setResponseHistoryList(List<VfcResponseDescriptor> responseHistoryList) { this.responseHistoryList = responseHistoryList; } diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java index dae87b6a6..d334d232f 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -28,30 +28,30 @@ public class DemoTest { @Test public void test() { - VFCRequest request = new VFCRequest(); + VfcRequest request = new VfcRequest(); - request.setNSInstanceId("100"); - request.setHealRequest(new VFCHealRequest()); + request.setNsInstanceId("100"); + request.setHealRequest(new VfcHealRequest()); request.getHealRequest().setVnfInstanceId("1"); request.getHealRequest().setCause("vm is down"); - request.getHealRequest().setAdditionalParams(new VFCHealAdditionalParams()); + request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams()); request.getHealRequest().getAdditionalParams().setAction("restartvm"); - request.getHealRequest().getAdditionalParams().setActionInfo(new VFCHealActionVmInfo()); + request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo()); request.getHealRequest().getAdditionalParams().getActionInfo().setVmid("33"); request.getHealRequest().getAdditionalParams().getActionInfo().setVmname("xgw-smp11"); String body = Serialization.gsonPretty.toJson(request); System.out.println(body); - VFCResponse response = new VFCResponse(); + VfcResponse response = new VfcResponse(); response.setJobId("1"); body = Serialization.gsonPretty.toJson(response); System.out.println(body); - response.setResponseDescriptor(new VFCResponseDescriptor()); + response.setResponseDescriptor(new VfcResponseDescriptor()); response.getResponseDescriptor().setProgress("40"); response.getResponseDescriptor().setStatus("processing"); response.getResponseDescriptor().setStatusDescription("OMC VMs are decommissioned in VIM"); @@ -60,7 +60,7 @@ public class DemoTest { body = Serialization.gsonPretty.toJson(response); System.out.println(body); - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); responseDescriptor.setProgress("20"); responseDescriptor.setStatus("processing"); responseDescriptor.setStatusDescription("OMC VMs are decommissioned in VIM"); @@ -73,7 +73,7 @@ public class DemoTest { body = Serialization.gsonPretty.toJson(response); System.out.println(body); - response = Serialization.gsonPretty.fromJson(body, VFCResponse.class); + response = Serialization.gsonPretty.fromJson(body, VfcResponse.class); body = Serialization.gsonPretty.toJson(response); System.out.println(body); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java index 10964a909..8b5b118d2 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class VfcHealActionVmInfoTest { @Test public void testVfcHealActionVmInfo() { - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); assertNotNull(actionInfo); assertNotEquals(0, actionInfo.hashCode()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java index ca2d844c1..e7cb79fef 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class VfcHealAdditionalParamsTest { @Test public void testVfcHealAdditionalParameters() { - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); assertNotNull(additionalParams); assertNotEquals(0, additionalParams.hashCode()); @@ -39,7 +39,7 @@ public class VfcHealAdditionalParamsTest { additionalParams.setAction(action); assertEquals(action, additionalParams.getAction()); - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); additionalParams.setActionInfo(actionInfo ); assertEquals(actionInfo, additionalParams.getActionInfo()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java index 0a256a59b..b67b9ac07 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class VfcHealRequestTest { @Test public void testVfcHealRequest() { - VFCHealRequest request = new VFCHealRequest(); + VfcHealRequest request = new VfcHealRequest(); assertNotNull(request); assertNotEquals(0, request.hashCode()); @@ -43,7 +43,7 @@ public class VfcHealRequestTest { request.setCause(cause); assertEquals(cause, request.getCause()); - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); request.setAdditionalParams(additionalParams); assertEquals(additionalParams, request.getAdditionalParams()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java index ab8161164..f5d06de36 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson, AT&T. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -56,8 +56,8 @@ public class VfcManagerTest { private Pair<Integer, String> httpResponseBadResponse; private Pair<Integer, String> httpResponseErr; - private VFCRequest request; - private VFCResponse response; + private VfcRequest request; + private VfcResponse response; @BeforeClass public static void beforeTestVfcManager() { @@ -82,28 +82,28 @@ public class VfcManagerTest { */ @Before public void createRequestAndResponse() { - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); actionInfo.setVmid("TheWizard"); actionInfo.setVmname("The Wizard of Oz"); - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); additionalParams.setAction("Go Home"); additionalParams.setActionInfo(actionInfo); - VFCHealRequest healRequest = new VFCHealRequest(); + VfcHealRequest healRequest = new VfcHealRequest(); healRequest.setAdditionalParams(additionalParams); healRequest.setCause("WestWitch"); healRequest.setVnfInstanceId("EmeraldCity"); final UUID requestId = UUID.randomUUID(); - request = new VFCRequest(); + request = new VfcRequest(); request.setHealRequest(healRequest); - request.setNSInstanceId("Dorothy"); + request.setNsInstanceId("Dorothy"); request.setRequestId(requestId); - List<VFCResponseDescriptor> responseHistoryList = new ArrayList<>();; + List<VfcResponseDescriptor> responseHistoryList = new ArrayList<>();; - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); responseDescriptor.setErrorCode("1234"); responseDescriptor.setProgress("Follow The Yellow Brick Road"); responseDescriptor.setResponseHistoryList(responseHistoryList); @@ -111,7 +111,7 @@ public class VfcManagerTest { responseDescriptor.setStatus("finished"); responseDescriptor.setStatusDescription("There's no place like home"); - response = new VFCResponse(); + response = new VfcResponse(); response.setJobId("1234"); response.setRequestId(request.getRequestId().toString()); response.setResponseDescriptor(responseDescriptor); @@ -130,25 +130,25 @@ public class VfcManagerTest { @Test public void testVfcInitiation() { try { - new VFCManager(null, null); + new VfcManager(null, null); fail("test should throw an exception here"); } catch (IllegalArgumentException e) { - assertEquals("the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null", + assertEquals("the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null", e.getMessage()); } try { - new VFCManager(mockedWorkingMemory, null); + new VfcManager(mockedWorkingMemory, null); fail("test should throw an exception here"); } catch (IllegalArgumentException e) { - assertEquals("the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null", + assertEquals("the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null", e.getMessage()); } try { - new VFCManager(mockedWorkingMemory, request); + new VfcManager(mockedWorkingMemory, request); fail("test should throw an exception here"); } catch (IllegalArgumentException e) { @@ -158,14 +158,14 @@ public class VfcManagerTest { // add url; username & password are not required PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - new VFCManager(mockedWorkingMemory, request); + new VfcManager(mockedWorkingMemory, request); // url & username, but no password PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); // url, username, and password PolicyEngine.manager.getEnvironment().put("vfc.password", "Toto"); - new VFCManager(mockedWorkingMemory, request); + new VfcManager(mockedWorkingMemory, request); } @Test @@ -174,7 +174,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "Exception"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); @@ -202,7 +202,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "Null"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); @@ -225,7 +225,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "Error0"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); @@ -248,7 +248,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "BadResponse"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); @@ -271,7 +271,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "OK"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java index 95589154f..7dede1b7b 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -33,19 +33,19 @@ public class VfcRequestTest { @Test public void testVfcRequest() { - VFCRequest request = new VFCRequest(); + VfcRequest request = new VfcRequest(); assertNotNull(request); assertNotEquals(0, request.hashCode()); String nsInstanceId = "Dorothy"; - request.setNSInstanceId(nsInstanceId); - assertEquals(nsInstanceId, request.getNSInstanceId()); + request.setNsInstanceId(nsInstanceId); + assertEquals(nsInstanceId, request.getNsInstanceId()); UUID requestId = UUID.randomUUID(); request.setRequestId(requestId); assertEquals(requestId, request.getRequestId()); - VFCHealRequest healRequest = new VFCHealRequest(); + VfcHealRequest healRequest = new VfcHealRequest(); request.setHealRequest(healRequest); assertEquals(healRequest, request.getHealRequest()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java index 9ab180767..b4dc81b44 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -34,7 +34,7 @@ public class VfcResponseDescriptorTest { @Test public void testVfcResponseDescriptor() { - VFCResponseDescriptor descriptor = new VFCResponseDescriptor(); + VfcResponseDescriptor descriptor = new VfcResponseDescriptor(); assertNotNull(descriptor); assertNotEquals(0, descriptor.hashCode()); @@ -46,7 +46,7 @@ public class VfcResponseDescriptorTest { descriptor.setProgress(progress); assertEquals(progress, descriptor.getProgress()); - List<VFCResponseDescriptor> responseHistoryList = new ArrayList<>(); + List<VfcResponseDescriptor> responseHistoryList = new ArrayList<>(); descriptor.setResponseHistoryList(responseHistoryList); assertEquals(responseHistoryList, descriptor.getResponseHistoryList()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java index f333c4165..15ba6f520 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class VfcResponseTest { @Test public void testVfcResponse() { - VFCResponse response = new VFCResponse(); + VfcResponse response = new VfcResponse(); assertNotNull(response); assertNotEquals(0, response.hashCode()); @@ -43,7 +43,7 @@ public class VfcResponseTest { response.setRequestId(requestId); assertEquals(requestId, response.getRequestId()); - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); response.setResponseDescriptor(responseDescriptor); assertEquals(responseDescriptor, response.getResponseDescriptor()); diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java index 0e083bb6c..6e778d86c 100644 --- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java +++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * simulators * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -33,7 +33,7 @@ import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.drools.utils.logging.LoggerUtil; import org.onap.policy.rest.RESTManager; import org.onap.policy.rest.RESTManager.Pair; -import org.onap.policy.vfc.VFCResponse; +import org.onap.policy.vfc.VfcResponse; import org.onap.policy.vfc.util.Serialization; public class VfcSimulatorTest { @@ -64,7 +64,7 @@ public class VfcSimulatorTest { new HashMap<String, String>(), "application/json", "Some Request Here"); assertNotNull(httpDetails); assertTrue(httpDetails.first == 202); - final VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VFCResponse.class); + final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); assertNotNull(response); } @@ -73,7 +73,7 @@ public class VfcSimulatorTest { final Pair<Integer, String> httpDetails = new RESTManager().get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password", new HashMap<String, String>()); assertNotNull(httpDetails); - final VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VFCResponse.class); + final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); assertNotNull(response); } } diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl index be399d9f7..160b75c61 100644 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -45,9 +45,9 @@ import org.onap.policy.sdnr.PciRequestWrapper; import org.onap.policy.sdnr.PciResponseWrapper; import org.onap.policy.sdnr.PciRequest; import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.vfc.VFCRequest; -import org.onap.policy.vfc.VFCResponse; -import org.onap.policy.vfc.VFCManager; +import org.onap.policy.vfc.VfcRequest; +import org.onap.policy.vfc.VfcResponse; +import org.onap.policy.vfc.VfcManager; import org.onap.policy.so.SOManager; import org.onap.policy.so.SORequest; import org.onap.policy.so.SORequestStatus; @@ -594,9 +594,9 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" } break; case "VFC": - if (request instanceof VFCRequest) { + if (request instanceof VfcRequest) { // Start VFC thread - Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request)); + Thread t = new Thread(new VfcManager(drools.getWorkingMemory(), (VfcRequest)request)); t.start(); } break; @@ -1252,7 +1252,7 @@ rule "${policyName}.VFC.RESPONSE" $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired ) $lock : TargetLock (requestID == $event.getRequestId()) - $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() ) + $response : VfcResponse( requestId.toString() == $event.getRequestId().toString() ) then Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl index dc585261c..d8e34313e 100644 --- a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. @@ -46,9 +46,9 @@ import org.onap.policy.sdnr.PciRequestWrapper; import org.onap.policy.sdnr.PciResponseWrapper; import org.onap.policy.sdnr.PciRequest; import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.vfc.VFCRequest; -import org.onap.policy.vfc.VFCResponse; -import org.onap.policy.vfc.VFCManager; +import org.onap.policy.vfc.VfcRequest; +import org.onap.policy.vfc.VfcResponse; +import org.onap.policy.vfc.VfcManager; import org.onap.policy.so.SOManager; import org.onap.policy.so.SORequest; import org.onap.policy.so.SORequestStatus; @@ -543,9 +543,9 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" } break; case "VFC": - if (request instanceof VFCRequest) { + if (request instanceof VfcRequest) { // Start VFC thread - Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request)); + Thread t = new Thread(new VfcManager(drools.getWorkingMemory(), (VfcRequest)request)); t.start(); } break; @@ -1093,7 +1093,7 @@ rule "VFC.RESPONSE" $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired ) $lock : TargetLock (requestID == $event.getRequestId()) - $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() ) + $response : VfcResponse( requestId.toString() == $event.getRequestId().toString() ) then Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); logger.info("{}: {}", $clName, $params.getPolicyName() + "." + drools.getRule().getName()); diff --git a/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl index f7f04af81..feb5bf499 100644 --- a/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. @@ -42,9 +42,9 @@ import org.onap.policy.appclcm.LcmResponseWrapper; import org.onap.policy.appclcm.LcmRequest; import org.onap.policy.appclcm.LcmResponse; import org.onap.policy.appclcm.LcmCommonHeader; -import org.onap.policy.vfc.VFCRequest; -import org.onap.policy.vfc.VFCResponse; -import org.onap.policy.vfc.VFCManager; +import org.onap.policy.vfc.VfcRequest; +import org.onap.policy.vfc.VfcResponse; +import org.onap.policy.vfc.VfcManager; import org.onap.policy.so.SOManager; import org.onap.policy.so.SORequest; import org.onap.policy.so.SORequestStatus; @@ -599,9 +599,9 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" } break; case "VFC": - if (request instanceof VFCRequest) { + if (request instanceof VfcRequest) { // Start VFC thread - Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request)); + Thread t = new Thread(new VfcManager(drools.getWorkingMemory(), (VfcRequest)request)); t.start(); } break; @@ -1103,7 +1103,7 @@ rule "${policyName}.VFC.RESPONSE" $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() ) $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() ) $lock : TargetLock (requestID == $event.getRequestId()) - $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() ) + $response : VfcResponse( requestId.toString() == $event.getRequestId().toString() ) then Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java index aa4c108c5..57ed52ad7 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java @@ -3,7 +3,7 @@ * demo * ================================================================================ * Copyright (C) 2017-2018 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018-2019 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. @@ -57,7 +57,7 @@ import org.onap.policy.drools.protocol.coders.JsonProtocolFilter; import org.onap.policy.drools.system.PolicyController; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.onap.policy.vfc.VFCRequest; +import org.onap.policy.vfc.VfcRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -340,7 +340,7 @@ public class VfcControlLoopTest implements TopicListener { logger.debug("The control loop timed out"); fail("Control Loop Timed Out"); } - } else if (obj instanceof VFCRequest) { + } else if (obj instanceof VfcRequest) { logger.debug("\n============ VFC received the request!!! ===========\n"); } } |