summaryrefslogtreecommitdiffstats
path: root/controlloop/common/policy-yaml/src/main/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-08-13 13:24:59 -0400
committerPamela Dragosh <pdragosh@research.att.com>2018-08-13 13:54:44 -0400
commit6f9976df27dccb2dcaedeb9106166f62a435b050 (patch)
tree245c214931884f002d31821d987660be49fdc7e2 /controlloop/common/policy-yaml/src/main/java
parent03ba72ecb25b619a23b42705a976629e1bcd9568 (diff)
Resolve checkstyle formatting
This submission is mostly focused on 120 spacing, missing spaces, rearranged imports, newlines before package and a few other items. Will have to submit further reviews to finish this. Issue-ID: POLICY-883 Change-Id: I772a2077ac97a0cb929810d8afadd2f415fae17b Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'controlloop/common/policy-yaml/src/main/java')
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/CompilerException.java30
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java155
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerCallback.java12
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java21
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java7
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java63
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/BuilderException.java13
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Message.java10
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Results.java14
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/MessageImpl.java38
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ResultsImpl.java54
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java13
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java35
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java17
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java7
15 files changed, 280 insertions, 209 deletions
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/CompilerException.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/CompilerException.java
index 8a1fc3edd..d2b8d2b8d 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/CompilerException.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/CompilerException.java
@@ -22,25 +22,25 @@ package org.onap.policy.controlloop.compiler;
public class CompilerException extends Exception {
- private static final long serialVersionUID = -7262217239867898601L;
+ private static final long serialVersionUID = -7262217239867898601L;
- public CompilerException() {
- }
+ public CompilerException() {
+ }
- public CompilerException(String message) {
- super(message);
- }
+ public CompilerException(String message) {
+ super(message);
+ }
- public CompilerException(Throwable cause) {
- super(cause);
- }
+ public CompilerException(Throwable cause) {
+ super(cause);
+ }
- public CompilerException(String message, Throwable cause) {
- super(message, cause);
- }
+ public CompilerException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public CompilerException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
+ public CompilerException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
index 0aa6f2a79..b088af78a 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
@@ -20,6 +20,9 @@
package org.onap.policy.controlloop.compiler;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
import java.io.InputStream;
import java.io.Serializable;
import java.util.Collections;
@@ -43,15 +46,14 @@ import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-public class ControlLoopCompiler implements Serializable{
+public class ControlLoopCompiler implements Serializable {
private static final String OPERATION_POLICY = "Operation Policy ";
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopCompiler.class.getName());
- public static ControlLoopPolicy compile(ControlLoopPolicy policy, ControlLoopCompilerCallback callback) throws CompilerException {
+ public static ControlLoopPolicy compile(ControlLoopPolicy policy,
+ ControlLoopCompilerCallback callback) throws CompilerException {
//
// Ensure the control loop is sane
//
@@ -64,7 +66,8 @@ public class ControlLoopCompiler implements Serializable{
return policy;
}
- public static ControlLoopPolicy compile(InputStream yamlSpecification, ControlLoopCompilerCallback callback) throws CompilerException {
+ public static ControlLoopPolicy compile(InputStream yamlSpecification,
+ ControlLoopCompilerCallback callback) throws CompilerException {
Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class));
Object obj = yaml.load(yamlSpecification);
if (obj == null) {
@@ -76,12 +79,14 @@ public class ControlLoopCompiler implements Serializable{
return ControlLoopCompiler.compile((ControlLoopPolicy) obj, callback);
}
- private static void validateControlLoop(ControlLoop controlLoop, ControlLoopCompilerCallback callback) throws CompilerException {
+ private static void validateControlLoop(ControlLoop controlLoop,
+ ControlLoopCompilerCallback callback) throws CompilerException {
if (controlLoop == null && callback != null) {
callback.onError("controlLoop cannot be null");
}
if (controlLoop!=null){
- if ((controlLoop.getControlLoopName() == null || controlLoop.getControlLoopName().length() < 1) && callback != null) {
+ if ((controlLoop.getControlLoopName() == null || controlLoop.getControlLoopName().length() < 1)
+ && callback != null) {
callback.onError("Missing controlLoopName");
}
if ((!controlLoop.getVersion().contentEquals(ControlLoop.getVERSION())) && callback != null) {
@@ -93,18 +98,20 @@ public class ControlLoopCompiler implements Serializable{
}
}
- private static void validatePolicies(ControlLoopPolicy policy, ControlLoopCompilerCallback callback) throws CompilerException {
+ private static void validatePolicies(ControlLoopPolicy policy,
+ ControlLoopCompilerCallback callback) throws CompilerException {
if (policy == null) {
throw new CompilerException("policy cannot be null");
}
if (policy.getPolicies() == null) {
callback.onWarning("controlLoop is an open loop.");
- }
- else{
+ } else {
//
// For this version we can use a directed multigraph, in the future we may not be able to
//
- DirectedGraph<NodeWrapper, LabeledEdge> graph = new DirectedMultigraph<>(new ClassBasedEdgeFactory<NodeWrapper, LabeledEdge>(LabeledEdge.class));
+ DirectedGraph<NodeWrapper, LabeledEdge> graph =
+ new DirectedMultigraph<>(new ClassBasedEdgeFactory<NodeWrapper,
+ LabeledEdge>(LabeledEdge.class));
//
// Check to see if the trigger Event is for OpenLoop, we do so by
// attempting to create a FinalResult object from it. If its a policy id, this should
@@ -134,7 +141,8 @@ public class ControlLoopCompiler implements Serializable{
FinalResultNodeWrapper finalFailure = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE);
FinalResultNodeWrapper finalFailureTimeout = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_TIMEOUT);
FinalResultNodeWrapper finalFailureRetries = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_RETRIES);
- FinalResultNodeWrapper finalFailureException = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_EXCEPTION);
+ FinalResultNodeWrapper finalFailureException =
+ new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_EXCEPTION);
FinalResultNodeWrapper finalFailureGuard = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_GUARD);
graph.addVertex(finalSuccess);
graph.addVertex(finalFailure);
@@ -157,38 +165,47 @@ public class ControlLoopCompiler implements Serializable{
if (node == null) {
continue;
}
- addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getSuccess(), finalSuccess, PolicyResult.SUCCESS, node);
- addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure(), finalFailure, PolicyResult.FAILURE, node);
- addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_timeout(), finalFailureTimeout, PolicyResult.FAILURE_TIMEOUT, node);
- addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_retries(), finalFailureRetries, PolicyResult.FAILURE_RETRIES, node);
- addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_exception(), finalFailureException, PolicyResult.FAILURE_EXCEPTION, node);
- addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_guard(), finalFailureGuard, PolicyResult.FAILURE_GUARD, node);
+ addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getSuccess(), finalSuccess,
+ PolicyResult.SUCCESS, node);
+ addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure(), finalFailure,
+ PolicyResult.FAILURE, node);
+ addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_timeout(), finalFailureTimeout,
+ PolicyResult.FAILURE_TIMEOUT, node);
+ addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_retries(), finalFailureRetries,
+ PolicyResult.FAILURE_RETRIES, node);
+ addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_exception(), finalFailureException,
+ PolicyResult.FAILURE_EXCEPTION, node);
+ addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_guard(), finalFailureGuard,
+ PolicyResult.FAILURE_GUARD, node);
}
validateNodesAndEdges(graph, callback);
}
}
- private static void validateOpenLoopPolicy(ControlLoopPolicy policy, FinalResult triggerResult, ControlLoopCompilerCallback callback) throws CompilerException{
+ private static void validateOpenLoopPolicy(ControlLoopPolicy policy, FinalResult triggerResult,
+ ControlLoopCompilerCallback callback) throws CompilerException {
//
// Ensure they didn't use some other FinalResult code
//
if (triggerResult != FinalResult.FINAL_OPENLOOP) {
- throw new CompilerException("Unexpected Final Result for trigger_policy, should only be " + FinalResult.FINAL_OPENLOOP.toString() + " or a valid Policy ID");
+ throw new CompilerException("Unexpected Final Result for trigger_policy, should only be "
+ + FinalResult.FINAL_OPENLOOP.toString() + " or a valid Policy ID");
}
//
// They really shouldn't have any policies attached.
//
- if ((policy.getPolicies() != null || policy.getPolicies().isEmpty())&& callback != null ) {
+ if ((policy.getPolicies() != null || policy.getPolicies().isEmpty()) && callback != null ) {
callback.onWarning("Open Loop policy contains policies. The policies will never be invoked.");
}
}
- private static void validatePoliciesContainTriggerPolicyAndCombinedTimeoutIsOk(ControlLoopPolicy policy, ControlLoopCompilerCallback callback) throws CompilerException{
+ private static void validatePoliciesContainTriggerPolicyAndCombinedTimeoutIsOk(ControlLoopPolicy policy,
+ ControlLoopCompilerCallback callback) throws CompilerException {
int sum = 0;
boolean triggerPolicyFound = false;
for (Policy operPolicy : policy.getPolicies()) {
sum += operPolicy.getTimeout().intValue();
- if (policy.getControlLoop().getTrigger_policy().equals(operPolicy.getId())){
+ if (policy.getControlLoop().getTrigger_policy().equals(operPolicy.getId())) {
triggerPolicyFound = true;
}
}
@@ -196,13 +213,15 @@ public class ControlLoopCompiler implements Serializable{
callback.onError("controlLoop overall timeout is less than the sum of operational policy timeouts.");
}
- if (!triggerPolicyFound){
- throw new CompilerException("Unexpected value for trigger_policy, should only be " + FinalResult.FINAL_OPENLOOP.toString() + " or a valid Policy ID");
+ if (!triggerPolicyFound) {
+ throw new CompilerException("Unexpected value for trigger_policy, should only be "
+ + FinalResult.FINAL_OPENLOOP.toString() + " or a valid Policy ID");
}
}
private static Map<Policy, PolicyNodeWrapper> addPoliciesAsNodes(ControlLoopPolicy policy,
- DirectedGraph<NodeWrapper, LabeledEdge> graph, TriggerNodeWrapper triggerNode, ControlLoopCompilerCallback callback){
+ DirectedGraph<NodeWrapper, LabeledEdge> graph, TriggerNodeWrapper triggerNode,
+ ControlLoopCompilerCallback callback) {
Map<Policy, PolicyNodeWrapper> mapNodes = new HashMap<>();
for (Policy operPolicy : policy.getPolicies()) {
//
@@ -234,22 +253,27 @@ public class ControlLoopCompiler implements Serializable{
return mapNodes;
}
- private static void addEdge(DirectedGraph<NodeWrapper, LabeledEdge> graph, Map<Policy, PolicyNodeWrapper> mapNodes, String policyId, String connectedPolicy,
- FinalResultNodeWrapper finalResultNodeWrapper, PolicyResult policyResult, NodeWrapper node) throws CompilerException{
+ private static void addEdge(DirectedGraph<NodeWrapper, LabeledEdge> graph, Map<Policy, PolicyNodeWrapper> mapNodes,
+ String policyId, String connectedPolicy,
+ FinalResultNodeWrapper finalResultNodeWrapper,
+ PolicyResult policyResult, NodeWrapper node) throws CompilerException {
FinalResult finalResult = FinalResult.toResult(finalResultNodeWrapper.getID());
if (FinalResult.isResult(connectedPolicy, finalResult)) {
- graph.addEdge(node, finalResultNodeWrapper, new LabeledEdge(node, finalResultNodeWrapper, new FinalResultEdgeWrapper(finalResult)));
+ graph.addEdge(node, finalResultNodeWrapper, new LabeledEdge(node, finalResultNodeWrapper,
+ new FinalResultEdgeWrapper(finalResult)));
} else {
PolicyNodeWrapper toNode = findPolicyNode(mapNodes, connectedPolicy);
if (toNode == null) {
- throw new CompilerException(OPERATION_POLICY + policyId + " is connected to unknown policy " + connectedPolicy);
+ throw new CompilerException(OPERATION_POLICY + policyId + " is connected to unknown policy "
+ + connectedPolicy);
} else {
graph.addEdge(node, toNode, new LabeledEdge(node, toNode, new PolicyResultEdgeWrapper(policyResult)));
}
}
}
- private static void validateNodesAndEdges(DirectedGraph<NodeWrapper, LabeledEdge> graph, ControlLoopCompilerCallback callback) throws CompilerException{
+ private static void validateNodesAndEdges(DirectedGraph<NodeWrapper, LabeledEdge> graph,
+ ControlLoopCompilerCallback callback) throws CompilerException {
for (NodeWrapper node : graph.vertexSet()) {
if (node instanceof TriggerNodeWrapper) {
validateTriggerNodeWrapper(graph, node);
@@ -258,13 +282,14 @@ public class ControlLoopCompiler implements Serializable{
} else if (node instanceof PolicyNodeWrapper) {
validatePolicyNodeWrapper(graph, node, callback);
}
- for (LabeledEdge edge : graph.outgoingEdgesOf(node)){
+ for (LabeledEdge edge : graph.outgoingEdgesOf(node)) {
LOGGER.info(edge.from.getID() + " invokes " + edge.to.getID() + " upon " + edge.edge.getID());
}
}
}
- private static void validateTriggerNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph, NodeWrapper node) throws CompilerException{
+ private static void validateTriggerNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph,
+ NodeWrapper node) throws CompilerException {
if (LOGGER.isDebugEnabled()) {
LOGGER.info("Trigger Node {}", node.toString());
}
@@ -282,7 +307,8 @@ public class ControlLoopCompiler implements Serializable{
}
}
- private static void validateFinalResultNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph, NodeWrapper node) throws CompilerException{
+ private static void validateFinalResultNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph,
+ NodeWrapper node) throws CompilerException {
if (LOGGER.isDebugEnabled()) {
LOGGER.info("FinalResult Node {}", node.toString());
}
@@ -294,7 +320,8 @@ public class ControlLoopCompiler implements Serializable{
}
}
- private static void validatePolicyNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph, NodeWrapper node, ControlLoopCompilerCallback callback) throws CompilerException{
+ private static void validatePolicyNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph,
+ NodeWrapper node, ControlLoopCompilerCallback callback) throws CompilerException {
if (LOGGER.isDebugEnabled()) {
LOGGER.info("Policy Node {}", node.toString());
}
@@ -383,13 +410,23 @@ public class ControlLoopCompiler implements Serializable{
//
ImmutableMap<String, List<String>> recipes = new ImmutableMap.Builder<String, List<String>>()
.put("APPC", ImmutableList.of("Restart", "Rebuild", "Migrate", "ModifyConfig"))
- .put("AOTS", ImmutableList.of("checkMaintenanceWindow", "checkENodeBTicketHours", "checkEquipmentStatus", "checkEimStatus", "checkEquipmentMaintenance"))
+ .put("AOTS", ImmutableList.of("checkMaintenanceWindow",
+ "checkENodeBTicketHours",
+ "checkEquipmentStatus",
+ "checkEimStatus",
+ "checkEquipmentMaintenance"))
.put("MSO", ImmutableList.of("VF Module Create"))
- .put("SDNO", ImmutableList.of("health-diagnostic-type", "health-diagnostic", "health-diagnostic-history", "health-diagnostic-commands", "health-diagnostic-aes"))
+ .put("SDNO", ImmutableList.of("health-diagnostic-type",
+ "health-diagnostic",
+ "health-diagnostic-history",
+ "health-diagnostic-commands",
+ "health-diagnostic-aes"))
.put("SDNR", ImmutableList.of("Restart", "Reboot"))
.build();
//
- if (operPolicy.getRecipe() != null && (!recipes.getOrDefault(operPolicy.getActor(), Collections.emptyList()).contains(operPolicy.getRecipe()))) {
+ if (operPolicy.getRecipe() != null
+ && (!recipes.getOrDefault(operPolicy.getActor(),
+ Collections.emptyList()).contains(operPolicy.getRecipe()))) {
if (callback != null) {
callback.onError("Policy recipe is invalid");
}
@@ -406,7 +443,10 @@ public class ControlLoopCompiler implements Serializable{
}
isOk = false;
}
- if (operPolicy.getTarget() != null && operPolicy.getTarget().getType() != TargetType.VM && operPolicy.getTarget().getType() != TargetType.VFC && operPolicy.getTarget().getType() != TargetType.PNF) {
+ if (operPolicy.getTarget() != null
+ && operPolicy.getTarget().getType() != TargetType.VM
+ && operPolicy.getTarget().getType() != TargetType.VFC
+ && operPolicy.getTarget().getType() != TargetType.PNF) {
if (callback != null) {
callback.onError("Policy target is invalid");
}
@@ -428,9 +468,10 @@ public class ControlLoopCompiler implements Serializable{
return isOk;
}
- private static boolean isSuccessPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback){
+ private static boolean isSuccessPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) {
boolean isOk = true;
- if (FinalResult.toResult(operPolicy.getSuccess()) != null && !operPolicy.getSuccess().equals(FinalResult.FINAL_SUCCESS.toString())) {
+ if (FinalResult.toResult(operPolicy.getSuccess()) != null
+ && !operPolicy.getSuccess().equals(FinalResult.FINAL_SUCCESS.toString())) {
if (callback != null) {
callback.onError("Policy success is neither another policy nor FINAL_SUCCESS");
}
@@ -439,9 +480,10 @@ public class ControlLoopCompiler implements Serializable{
return isOk;
}
- private static boolean isFailurePolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback){
+ private static boolean isFailurePolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) {
boolean isOk = true;
- if (FinalResult.toResult(operPolicy.getFailure()) != null && !operPolicy.getFailure().equals(FinalResult.FINAL_FAILURE.toString())) {
+ if (FinalResult.toResult(operPolicy.getFailure()) != null
+ && !operPolicy.getFailure().equals(FinalResult.FINAL_FAILURE.toString())) {
if (callback != null) {
callback.onError("Policy failure is neither another policy nor FINAL_FAILURE");
}
@@ -450,9 +492,10 @@ public class ControlLoopCompiler implements Serializable{
return isOk;
}
- private static boolean isFailureRetriesPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback){
+ private static boolean isFailureRetriesPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) {
boolean isOk = true;
- if (FinalResult.toResult(operPolicy.getFailure_retries()) != null && !operPolicy.getFailure_retries().equals(FinalResult.FINAL_FAILURE_RETRIES.toString())) {
+ if (FinalResult.toResult(operPolicy.getFailure_retries()) != null
+ && !operPolicy.getFailure_retries().equals(FinalResult.FINAL_FAILURE_RETRIES.toString())) {
if (callback != null) {
callback.onError("Policy failure retries is neither another policy nor FINAL_FAILURE_RETRIES");
}
@@ -461,9 +504,10 @@ public class ControlLoopCompiler implements Serializable{
return isOk;
}
- private static boolean isFailureTimeoutPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback){
+ private static boolean isFailureTimeoutPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) {
boolean isOk = true;
- if (FinalResult.toResult(operPolicy.getFailure_timeout()) != null && !operPolicy.getFailure_timeout().equals(FinalResult.FINAL_FAILURE_TIMEOUT.toString())) {
+ if (FinalResult.toResult(operPolicy.getFailure_timeout()) != null
+ && !operPolicy.getFailure_timeout().equals(FinalResult.FINAL_FAILURE_TIMEOUT.toString())) {
if (callback != null) {
callback.onError("Policy failure timeout is neither another policy nor FINAL_FAILURE_TIMEOUT");
}
@@ -472,9 +516,10 @@ public class ControlLoopCompiler implements Serializable{
return isOk;
}
- private static boolean isFailureExceptionPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback){
+ private static boolean isFailureExceptionPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) {
boolean isOk = true;
- if (FinalResult.toResult(operPolicy.getFailure_exception()) != null && !operPolicy.getFailure_exception().equals(FinalResult.FINAL_FAILURE_EXCEPTION.toString())) {
+ if (FinalResult.toResult(operPolicy.getFailure_exception()) != null
+ && !operPolicy.getFailure_exception().equals(FinalResult.FINAL_FAILURE_EXCEPTION.toString())) {
if (callback != null) {
callback.onError("Policy failure exception is neither another policy nor FINAL_FAILURE_EXCEPTION");
}
@@ -483,9 +528,10 @@ public class ControlLoopCompiler implements Serializable{
return isOk;
}
- private static boolean isFailureGuardPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback){
+ private static boolean isFailureGuardPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) {
boolean isOk = true;
- if (FinalResult.toResult(operPolicy.getFailure_guard()) != null && !operPolicy.getFailure_guard().equals(FinalResult.FINAL_FAILURE_GUARD.toString())) {
+ if (FinalResult.toResult(operPolicy.getFailure_guard()) != null
+ && !operPolicy.getFailure_guard().equals(FinalResult.FINAL_FAILURE_GUARD.toString())) {
if (callback != null) {
callback.onError("Policy failure guard is neither another policy nor FINAL_FAILURE_GUARD");
}
@@ -504,7 +550,7 @@ public class ControlLoopCompiler implements Serializable{
}
@FunctionalInterface
- private interface NodeWrapper extends Serializable{
+ private interface NodeWrapper extends Serializable {
public String getID();
}
@@ -567,7 +613,7 @@ public class ControlLoopCompiler implements Serializable{
}
@FunctionalInterface
- private interface EdgeWrapper extends Serializable{
+ private interface EdgeWrapper extends Serializable {
public String getID();
}
@@ -617,6 +663,7 @@ public class ControlLoopCompiler implements Serializable{
private static class FinalResultEdgeWrapper implements EdgeWrapper {
private static final long serialVersionUID = -1486381946896779840L;
private FinalResult finalResult;
+
public FinalResultEdgeWrapper(FinalResult result) {
this.finalResult = result;
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerCallback.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerCallback.java
index e07b77640..bdbc68167 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerCallback.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerCallback.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@
package org.onap.policy.controlloop.compiler;
public interface ControlLoopCompilerCallback {
-
- public boolean onWarning(String message);
-
- public boolean onError(String message);
-
+
+ public boolean onWarning(String message);
+
+ public boolean onError(String message);
+
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java
index 34c97e350..2897fde26 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -37,13 +37,14 @@ import org.yaml.snakeyaml.constructor.Constructor;
public class ControlLoopGuardCompiler {
private static final String GUARD_POLICIES_SHOULD_NOT_BE_NULL = "Guard policies should not be null";
- private static final String GUARD_POLICY = "Guard policy ";
+ private static final String GUARD_POLICY = "Guard policy ";
- private ControlLoopGuardCompiler(){
+ private ControlLoopGuardCompiler(){
// Private Constructor
}
- public static ControlLoopGuard compile(ControlLoopGuard cLGuard, ControlLoopCompilerCallback callback) throws CompilerException {
+ public static ControlLoopGuard compile(ControlLoopGuard cLGuard,
+ ControlLoopCompilerCallback callback) throws CompilerException {
//
// Ensure ControlLoopGuard has at least one guard policies
//
@@ -60,7 +61,8 @@ public class ControlLoopGuardCompiler {
return cLGuard;
}
- public static ControlLoopGuard compile(InputStream yamlSpecification, ControlLoopCompilerCallback callback) throws CompilerException {
+ public static ControlLoopGuard compile(InputStream yamlSpecification,
+ ControlLoopCompilerCallback callback) throws CompilerException {
Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class));
Object obj = yaml.load(yamlSpecification);
if (obj == null) {
@@ -72,7 +74,8 @@ public class ControlLoopGuardCompiler {
return ControlLoopGuardCompiler.compile((ControlLoopGuard) obj, callback);
}
- private static void validateControlLoopGuard(ControlLoopGuard cLGuard, ControlLoopCompilerCallback callback) throws CompilerException {
+ private static void validateControlLoopGuard(ControlLoopGuard cLGuard,
+ ControlLoopCompilerCallback callback) throws CompilerException {
if (cLGuard == null) {
if (callback != null) {
callback.onError("ControlLoop Guard cannot be null");
@@ -91,7 +94,8 @@ public class ControlLoopGuardCompiler {
}
}
- private static void validateGuardPolicies(List<GuardPolicy> policies, ControlLoopCompilerCallback callback) throws CompilerException {
+ private static void validateGuardPolicies(List<GuardPolicy> policies,
+ ControlLoopCompilerCallback callback) throws CompilerException {
if (policies == null) {
if (callback != null) {
callback.onError(GUARD_POLICIES_SHOULD_NOT_BE_NULL);
@@ -118,7 +122,8 @@ public class ControlLoopGuardCompiler {
}
}
- private static void validateConstraints(List<GuardPolicy> policies, ControlLoopCompilerCallback callback) throws CompilerException {
+ private static void validateConstraints(List<GuardPolicy> policies,
+ ControlLoopCompilerCallback callback) throws CompilerException {
if (policies == null) {
if (callback != null) {
callback.onError(GUARD_POLICIES_SHOULD_NOT_BE_NULL);
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java
index 1b312ea5a..b9fdc2e6d 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -30,7 +30,8 @@ public enum FinalResult {
*/
FINAL_OPENLOOP("Final_OpenLoop"),
/**
- * The Control Loop Policy failed in its last Operation Policy. NOTE: Previous Operation Policies may have been successful.
+ * The Control Loop Policy failed in its last Operation Policy.
+ * NOTE: Previous Operation Policies may have been successful.
*/
FINAL_FAILURE("Final_Failure"),
/**
@@ -46,7 +47,7 @@ public enum FinalResult {
*/
FINAL_FAILURE_EXCEPTION("Final_Failure_Exception"),
/**
- * The Control Loop Policy failed due to guard denied
+ * The Control Loop Policy failed due to guard denied.
*/
FINAL_FAILURE_GUARD("Final_Failure_Guard")
;
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java
index eed6c7c39..4e0a0c99b 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -190,13 +190,15 @@ public class Policy {
}
}
- public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target, Integer retries, Integer timeout) {
+ public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target,
+ Integer retries, Integer timeout) {
this(name, actor, recipe, payload, target);
this.retry = retries;
this.timeout = timeout;
}
- public Policy(String id, String name, String description, String actor, Map<String, String> payload, Target target, String recipe, Integer retries, Integer timeout) {
+ public Policy(String id, String name, String description, String actor, Map<String, String> payload,
+ Target target, String recipe, Integer retries, Integer timeout) {
this(name, actor, recipe, payload, target, retries, timeout);
this.id = id;
this.description = description;
@@ -224,15 +226,17 @@ public class Policy {
}
public boolean isValid() {
- return id==null || name==null || actor==null|| recipe==null || target==null;
+ return id == null || name == null || actor == null || recipe == null || target == null;
}
@Override
public String toString() {
return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", actor=" + actor + ", recipe="
- + recipe + ", payload=" + payload + ", target=" + target + ", operationsAccumulateParams=" + operationsAccumulateParams + ", retry=" + retry + ", timeout=" + timeout
+ + recipe + ", payload=" + payload + ", target=" + target + ", operationsAccumulateParams="
+ + operationsAccumulateParams + ", retry=" + retry + ", timeout=" + timeout
+ ", success=" + success + ", failure=" + failure + ", failure_retries=" + failureRetries
- + ", failure_timeout=" + failureTimeout + ", failure_exception=" + failureException + ", failure_guard=" + failureGuard + "]";
+ + ", failure_timeout=" + failureTimeout + ", failure_exception=" + failureException
+ + ", failure_guard=" + failureGuard + "]";
}
@Override
@@ -257,42 +261,45 @@ public class Policy {
return result;
}
- private int addHashCodeForField(int hashCode, Object field){
+ private int addHashCodeForField(int hashCode, Object field) {
final int prime = 31;
- return prime * hashCode + ((field == null) ? 0 : field.hashCode());
+ return prime * hashCode + ((field == null) ? 0 : field.hashCode());
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Policy other = (Policy) obj;
return equalsMayBeNull(actor, other.actor)
- && equalsMayBeNull(description, other.description)
- && equalsMayBeNull(failure, other.failure)
- && equalsMayBeNull(failureException, other.failureException)
- && equalsMayBeNull(failureGuard, other.failureGuard)
- && equalsMayBeNull(failureRetries, other.failureRetries)
- && equalsMayBeNull(id, other.id)
- && equalsMayBeNull(name, other.name)
- && equalsMayBeNull(payload, other.payload)
- && equalsMayBeNull(recipe, other.recipe)
- && equalsMayBeNull(retry, other.retry)
- && equalsMayBeNull(success, other.success)
- && equalsMayBeNull(operationsAccumulateParams, other.operationsAccumulateParams)
- && equalsMayBeNull(target, other.target)
- && equalsMayBeNull(timeout, other.timeout);
+ && equalsMayBeNull(description, other.description)
+ && equalsMayBeNull(failure, other.failure)
+ && equalsMayBeNull(failureException, other.failureException)
+ && equalsMayBeNull(failureGuard, other.failureGuard)
+ && equalsMayBeNull(failureRetries, other.failureRetries)
+ && equalsMayBeNull(id, other.id)
+ && equalsMayBeNull(name, other.name)
+ && equalsMayBeNull(payload, other.payload)
+ && equalsMayBeNull(recipe, other.recipe)
+ && equalsMayBeNull(retry, other.retry)
+ && equalsMayBeNull(success, other.success)
+ && equalsMayBeNull(operationsAccumulateParams, other.operationsAccumulateParams)
+ && equalsMayBeNull(target, other.target)
+ && equalsMayBeNull(timeout, other.timeout);
}
- private boolean equalsMayBeNull(final Object obj1, final Object obj2){
- if ( obj1 == null ) {
+ private boolean equalsMayBeNull(final Object obj1, final Object obj2) {
+ if ( obj1 == null ) {
return obj2 == null;
}
- return obj1.equals(obj2);
+ return obj1.equals(obj2);
}
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/BuilderException.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/BuilderException.java
index 5fc8ffb6e..618678e9c 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/BuilderException.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/BuilderException.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -22,13 +22,10 @@ package org.onap.policy.controlloop.policy.builder;
public class BuilderException extends Exception {
- public BuilderException(String string) {
- super(string);
- }
+ public BuilderException(String string) {
+ super(string);
+ }
- /**
- *
- */
- private static final long serialVersionUID = 610064813684337895L;
+ private static final long serialVersionUID = 610064813684337895L;
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Message.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Message.java
index e620276b0..3a71c6d26 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Message.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Message.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@
package org.onap.policy.controlloop.policy.builder;
public interface Message {
-
- public String getMessage();
-
- public MessageLevel getLevel();
+
+ public String getMessage();
+
+ public MessageLevel getLevel();
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Results.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Results.java
index fa309cc1f..9ad89c7cf 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Results.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Results.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -23,11 +23,11 @@ package org.onap.policy.controlloop.policy.builder;
import java.util.List;
public interface Results {
-
- public List<Message> getMessages();
-
- public String getSpecification();
-
- public boolean isValid();
+
+ public List<Message> getMessages();
+
+ public String getSpecification();
+
+ public boolean isValid();
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/MessageImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/MessageImpl.java
index 45de842f9..22244e09b 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/MessageImpl.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/MessageImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,23 +24,23 @@ import org.onap.policy.controlloop.policy.builder.Message;
import org.onap.policy.controlloop.policy.builder.MessageLevel;
public class MessageImpl implements Message {
-
- private String message;
- private MessageLevel level;
-
- public MessageImpl(String message, MessageLevel level) {
- this.message = message;
- this.level = level;
- }
-
- @Override
- public String getMessage() {
- return message;
- }
-
- @Override
- public MessageLevel getLevel() {
- return level;
- }
+
+ private String message;
+ private MessageLevel level;
+
+ public MessageImpl(String message, MessageLevel level) {
+ this.message = message;
+ this.level = level;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public MessageLevel getLevel() {
+ return level;
+ }
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ResultsImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ResultsImpl.java
index 78d28ef38..f9a9a474f 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ResultsImpl.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ResultsImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -27,30 +27,30 @@ import org.onap.policy.controlloop.policy.builder.Message;
import org.onap.policy.controlloop.policy.builder.Results;
public class ResultsImpl implements Results {
-
- private String specification;
- private List<Message> messages = new LinkedList<>();
-
- @Override
- public List<Message> getMessages() {
- return messages;
- }
-
- @Override
- public String getSpecification() {
- return specification;
- }
-
- @Override
- public boolean isValid() {
- return (this.specification != null);
- }
-
- public void addMessage(Message message) {
- this.messages.add(message);
- }
-
- public void setSpecification(String spec) {
- this.specification = spec;
- }
+
+ private String specification;
+ private List<Message> messages = new LinkedList<>();
+
+ @Override
+ public List<Message> getMessages() {
+ return messages;
+ }
+
+ @Override
+ public String getSpecification() {
+ return specification;
+ }
+
+ @Override
+ public boolean isValid() {
+ return (this.specification != null);
+ }
+
+ public void addMessage(Message message) {
+ this.messages.add(message);
+ }
+
+ public void setSpecification(String spec) {
+ this.specification = spec;
+ }
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java
index 3ebf7013e..e53f3e40f 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -99,12 +99,13 @@ public class Constraint {
}
}
- public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow, Map<String, String> activeTimeRange, List<String> blacklist) {
+ public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow, Map<String, String> activeTimeRange,
+ List<String> blacklist) {
this(freqLimitPerTarget, timeWindow);
if (activeTimeRange != null) {
this.activeTimeRange = Collections.unmodifiableMap(activeTimeRange);
}
- if(blacklist!=null){
+ if(blacklist != null){
this.blacklist = new LinkedList<>(blacklist);
}
}
@@ -119,12 +120,14 @@ public class Constraint {
}
public boolean isValid() {
- return ((freqLimitPerTarget == null && timeWindow != null)|| (timeWindow == null && freqLimitPerTarget != null))? false : true;
+ return ((freqLimitPerTarget == null && timeWindow != null)
+ || (timeWindow == null && freqLimitPerTarget != null)) ? false : true;
}
@Override
public String toString() {
- return "Constraint [freq_limit_per_target=" + freqLimitPerTarget + ", time_window=" + timeWindow + ", active_time_range=" + activeTimeRange + ", blacklist=" + blacklist + "]";
+ return "Constraint [freq_limit_per_target=" + freqLimitPerTarget + ", time_window="
+ + timeWindow + ", active_time_range=" + activeTimeRange + ", blacklist=" + blacklist + "]";
}
@Override
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java
index c45014c3c..759a0533d 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -98,12 +98,14 @@ public class GuardPolicy {
}
}
- public GuardPolicy(String name, String description, MatchParameters matchParameters, List<Constraint> limitConstraints) {
+ public GuardPolicy(String name, String description, MatchParameters matchParameters,
+ List<Constraint> limitConstraints) {
this(name, matchParameters, limitConstraints);
this.description = description;
}
- public GuardPolicy(String id, String name, String description, MatchParameters matchParameters, List<Constraint> limitConstraints) {
+ public GuardPolicy(String id, String name, String description, MatchParameters matchParameters,
+ List<Constraint> limitConstraints) {
this(name, description, matchParameters, limitConstraints);
this.id = id;
}
@@ -119,13 +121,13 @@ public class GuardPolicy {
}
public boolean isValid() {
- return (id==null || name ==null)? false : true;
+ return (id == null || name == null) ? false : true;
}
@Override
public String toString() {
return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", match_parameters="
- +matchParameters + ", limitConstraints=" + limitConstraints + "]";
+ + matchParameters + ", limitConstraints=" + limitConstraints + "]";
}
@Override
@@ -142,24 +144,27 @@ public class GuardPolicy {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
GuardPolicy other = (GuardPolicy) obj;
return equalsMayBeNull(description, other.description)
- && equalsMayBeNull(id, other.id)
- && equalsMayBeNull(name, other.name)
- && equalsMayBeNull(limitConstraints, other.limitConstraints)
- && equalsMayBeNull(matchParameters, other.matchParameters);
+ && equalsMayBeNull(id, other.id)
+ && equalsMayBeNull(name, other.name)
+ && equalsMayBeNull(limitConstraints, other.limitConstraints)
+ && equalsMayBeNull(matchParameters, other.matchParameters);
}
- private boolean equalsMayBeNull(final Object obj1, final Object obj2){
- if ( obj1 == null ) {
+ private boolean equalsMayBeNull(final Object obj1, final Object obj2) {
+ if ( obj1 == null ) {
return obj2 == null;
}
- return obj1.equals(obj2);
+ return obj1.equals(obj2);
}
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java
index d521624fd..77651dcbf 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -93,15 +93,17 @@ public interface ControlLoopGuardBuilder {
public ControlLoopGuardBuilder removeAllLimitConstraints(String id) throws BuilderException;
/**
- * Simply return a copy of control loop guard
+ * Simply return a copy of control loop guard.
*
* @return ControlLoopGuard
*/
public ControlLoopGuard getControlLoopGuard();
/**
- * This will compile and build the YAML specification for the Control Loop Guard. Please iterate the Results object for details.
- * The Results object will contains warnings and errors. If the specification compiled successfully, you will be able to retrieve the
+ * This will compile and build the YAML specification for the Control Loop Guard.
+ * Please iterate the Results object for details.
+ * The Results object will contains warnings and errors.
+ * If the specification compiled successfully, you will be able to retrieve the
* YAML.
*
* @return Results
@@ -118,10 +120,13 @@ public interface ControlLoopGuardBuilder {
//Do Nothing Private Constructor.
}
/**
- * @param guard
+ * Build the control loop guard.
+ *
+ * @param guard the guard
* @return ControlLoopGuardBuilder object
*/
- public static ControlLoopGuardBuilder buildControlLoopGuard (Guard guard) {
+
+ public static ControlLoopGuardBuilder buildControlLoopGuard(Guard guard) {
return new ControlLoopGuardBuilderImpl(guard);
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
index a431a0bfe..b4d251e7f 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -43,8 +43,9 @@ import org.yaml.snakeyaml.Yaml;
public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
private static final String NO_EXISTING_GUARD_POLICY_MATCHING_THE_ID = "No existing guard policy matching the id: ";
- private static final String THE_ID_OF_TARGET_GUARD_POLICY_MUST_NOT_BE_NULL = "The id of target guard policy must not be null";
- private static Logger logger = LoggerFactory.getLogger(ControlLoopGuardBuilderImpl.class.getName());
+ private static final String THE_ID_OF_TARGET_GUARD_POLICY_MUST_NOT_BE_NULL =
+ "The id of target guard policy must not be null";
+ private static Logger logger = LoggerFactory.getLogger(ControlLoopGuardBuilderImpl.class.getName());
private ControlLoopGuard cLGuard;
public ControlLoopGuardBuilderImpl(Guard guard) {