diff options
Diffstat (limited to 'ECOMP-ControlloopPolicy/src/main/java')
4 files changed, 314 insertions, 101 deletions
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java index 42a04e7b7..89526c5fd 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java @@ -26,40 +26,46 @@ import java.util.Map; public class Constraint { - private Integer num; - private String duration; - private Map<String, String> time_in_range; + private Integer freq_limit_per_target; + private Map<String,String> time_window; + private Map<String, String> active_time_range; private List<String> blacklist; public Constraint() { // Do Nothing empty constructor. } - - public Integer getNum() { - return num; + + public Integer getFreq_limit_per_target() { + return freq_limit_per_target; } - public void setNum(Integer num) { - this.num = num; + + public void setFreq_limit_per_target(Integer freq_limit_per_target) { + this.freq_limit_per_target = freq_limit_per_target; } - public String getDuration() { - return duration; + + public Map<String, String> getTime_window() { + return time_window; } - public void setDuration(String duration) { - this.duration = duration; + + public void setTime_window(Map<String, String> time_window) { + this.time_window = time_window; } - public Map<String, String> getTime_in_range() { - return time_in_range; + + public Map<String, String> getActive_time_range() { + return active_time_range; } - public void setTime_in_range(Map<String, String> time_in_range) { - this.time_in_range = time_in_range; + + public void setActive_time_range(Map<String, String> active_time_range) { + this.active_time_range = active_time_range; } + public List<String> getBlacklist() { return blacklist; } @@ -68,69 +74,65 @@ public class Constraint { this.blacklist = blacklist; } - public Constraint(Integer num, String duration) { - this.num = num; - this.duration = duration; + public Constraint(Integer freq_limit_per_target, Map<String, String> time_window) { + this.freq_limit_per_target = freq_limit_per_target; + if(time_window!=null){ + this.time_window = Collections.unmodifiableMap(time_window); + } } public Constraint(List<String> blacklist) { this.blacklist = new LinkedList<>(blacklist); - - } - - public Constraint(Map<String, String> time_in_range, List<String> blacklist) { - if (time_in_range != null) { - this.time_in_range = Collections.unmodifiableMap(time_in_range); - } - this.blacklist = new LinkedList<>(blacklist); } - public Constraint(Integer num, String duration, List<String> blacklist) { - this.num = num; - this.duration = duration; + public Constraint(Integer freq_limit_per_target, Map<String, String> time_window, List<String> blacklist) { + this.freq_limit_per_target = freq_limit_per_target; + this.time_window = Collections.unmodifiableMap(time_window); this.blacklist = new LinkedList<>(blacklist); } - public Constraint(Integer num, String duration, Map<String, String> time_in_range) { - this(num, duration); - if (time_in_range != null) { - this.time_in_range = Collections.unmodifiableMap(time_in_range); + public Constraint(Integer freq_limit_per_target, Map<String, String> time_window, Map<String, String> active_time_range) { + this(freq_limit_per_target, time_window); + if (active_time_range != null) { + this.active_time_range = Collections.unmodifiableMap(active_time_range); } } - public Constraint(Integer num, String duration, Map<String, String> time_in_range, List<String> blacklist) { - this(num, duration); - if (time_in_range != null) { - this.time_in_range = Collections.unmodifiableMap(time_in_range); + public Constraint(Integer freq_limit_per_target, Map<String, String> time_window, Map<String, String> active_time_range, List<String> blacklist) { + this(freq_limit_per_target, time_window); + if (active_time_range != null) { + this.active_time_range = Collections.unmodifiableMap(active_time_range); + } + if(blacklist!=null){ + this.blacklist = new LinkedList<>(blacklist); } - this.blacklist = new LinkedList<>(blacklist); } public Constraint(Constraint constraint) { - this.num = constraint.num; - this.duration = constraint.duration; - if (constraint.time_in_range != null) { - this.time_in_range = Collections.unmodifiableMap(constraint.time_in_range); + this.freq_limit_per_target = constraint.freq_limit_per_target; + this.time_window = constraint.time_window; + if (constraint.active_time_range != null) { + this.active_time_range = Collections.unmodifiableMap(constraint.active_time_range); } this.blacklist = new LinkedList<>(constraint.blacklist); } public boolean isValid() { - return ((num == null && duration != null)|| (duration == null && num != null))? false : true; + return ((freq_limit_per_target == null && time_window != null)|| (time_window == null && freq_limit_per_target != null))? false : true; } @Override public String toString() { - return "Constraint [num=" + num + ", duration=" + duration + ", time_in_range=" + time_in_range + ", blacklist=" + blacklist + "]"; + return "Constraint [freq_limit_per_target=" + freq_limit_per_target + ", time_window=" + time_window + ", active_time_range=" + active_time_range + ", blacklist=" + blacklist + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((num == null) ? 0 : num.hashCode()); - result = prime * result + ((duration == null) ? 0 : duration.hashCode()); - result = prime * result + ((time_in_range == null) ? 0 : time_in_range.hashCode()); + result = prime * result + ((freq_limit_per_target == null) ? 0 : freq_limit_per_target.hashCode()); + result = prime * result + ((time_window == null) ? 0 : time_window.hashCode()); + result = prime * result + ((active_time_range == null) ? 0 : active_time_range.hashCode()); result = prime * result + ((blacklist == null) ? 0 : blacklist.hashCode()); return result; } @@ -144,20 +146,20 @@ public class Constraint { if (getClass() != obj.getClass()) return false; Constraint other = (Constraint) obj; - if (num == null) { - if (other.num != null) + if (freq_limit_per_target == null) { + if (other.freq_limit_per_target != null) return false; - } else if (!num.equals(other.num)) + } else if (!freq_limit_per_target.equals(other.freq_limit_per_target)) return false; - if (duration == null) { - if (other.duration != null) + if (time_window == null) { + if (other.time_window != null) return false; - } else if (!duration.equals(other.duration)) + } else if (!time_window.equals(other.time_window)) return false; - if (time_in_range == null) { - if (other.time_in_range != null) + if (active_time_range == null) { + if (other.active_time_range != null) return false; - } else if (!time_in_range.equals(other.time_in_range)) + } else if (!active_time_range.equals(other.active_time_range)) return false; if (blacklist == null) { if (other.blacklist != null) diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopParameter.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopParameter.java new file mode 100644 index 000000000..e65b9810f --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopParameter.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.openecomp.policy.controlloop.policy.guard; + +public class ControlLoopParameter { + private String controlLoopName; + private String version; + + public String getControlLoopName() { + return controlLoopName; + } + + public void setControlLoopName(String controlLoopName) { + this.controlLoopName = controlLoopName; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public ControlLoopParameter(String controlLoopName, String version) { + super(); + this.controlLoopName = controlLoopName; + this.version = version; + } + + public ControlLoopParameter(ControlLoopParameter cl) { + + this.controlLoopName = cl.controlLoopName; + this.version = cl.version; + } + + @Override + public String toString() { + return "ControlLoopParameter [controlLoopName=" + controlLoopName + ", version=" + version + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode()); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ControlLoopParameter other = (ControlLoopParameter) obj; + if (controlLoopName == null) { + if (other.controlLoopName != null) + return false; + } else if (!controlLoopName.equals(other.controlLoopName)) + return false; + if (version == null) { + if (other.version != null) + return false; + } else if (!version.equals(other.version)) + return false; + return true; + } +} diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java index a4d56ff07..830736b42 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java @@ -29,8 +29,7 @@ public class GuardPolicy { private String id = UUID.randomUUID().toString(); private String name; private String description; - private String actor; - private String recipe; + private MatchParameters match_parameters; private LinkedList<Constraint> limit_constraints; public GuardPolicy() { @@ -61,20 +60,12 @@ public class GuardPolicy { this.description = description; } - public String getActor() { - return actor; + public MatchParameters getMatch_parameters() { + return match_parameters; } - public void setActor(String actor) { - this.actor = actor; - } - - public String getRecipe() { - return recipe; - } - - public void setRecipe(String recipe) { - this.recipe = recipe; + public void setMatch_parameters(MatchParameters match_parameters) { + this.match_parameters = match_parameters; } public LinkedList<Constraint> getLimit_constraints() { @@ -89,32 +80,31 @@ public class GuardPolicy { this.id = id; } - public GuardPolicy(String name, String actor, String recipe) { + public GuardPolicy(String name, MatchParameters matchParameters) { this.name = name; - this.actor = actor; - this.recipe = recipe; + this.match_parameters = matchParameters; } - public GuardPolicy(String id, String name, String description, String actor, String recipe) { - this(name, actor, recipe); + public GuardPolicy(String id, String name, String description, MatchParameters matchParameters) { + this(name, matchParameters); this.id = id; this.description = description; } - public GuardPolicy(String name, String actor, String recipe, List<Constraint> limit_constraints) { - this(name, actor, recipe); + public GuardPolicy(String name, MatchParameters matchParameters, List<Constraint> limitConstraints) { + this(name, matchParameters); if (limit_constraints != null) { - this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(limit_constraints); + this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(limitConstraints); } } - public GuardPolicy(String name, String description, String actor, String recipe, List<Constraint> limit_constraints) { - this(name, actor, recipe, limit_constraints); + 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, String actor, String recipe, List<Constraint> limit_constraints) { - this(name, description, actor, recipe, limit_constraints); + public GuardPolicy(String id, String name, String description, MatchParameters matchParameters, List<Constraint> limitConstraints) { + this(name, description, matchParameters, limitConstraints); this.id = id; } @@ -122,36 +112,31 @@ public class GuardPolicy { this.id = policy.id; this.name = policy.name; this.description = policy.description; - this.actor = policy.actor; - this.recipe = policy.recipe; + this.match_parameters = new MatchParameters(policy.match_parameters); if (policy.limit_constraints != null) { this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(policy.limit_constraints); } } public boolean isValid() { - if(id==null || name ==null|| actor==null|| recipe==null){ - return false; - } - return true; + return (id==null || name ==null)? false : true; } @Override public String toString() { - return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", actor=" + actor + ", recipe=" - + recipe + ", limitConstraints=" + limit_constraints + "]"; + return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", match_parameters=" + +match_parameters + ", limitConstraints=" + limit_constraints + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((actor == null) ? 0 : actor.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((limit_constraints == null) ? 0 : limit_constraints.hashCode()); - result = prime * result + ((recipe == null) ? 0 : recipe.hashCode()); + result = prime * result + ((match_parameters == null) ? 0 : match_parameters.hashCode()); return result; } @@ -164,11 +149,6 @@ public class GuardPolicy { if (getClass() != obj.getClass()) return false; GuardPolicy other = (GuardPolicy) obj; - if (actor == null) { - if (other.actor != null) - return false; - } else if (!actor.equals(other.actor)) - return false; if (description == null) { if (other.description != null) return false; @@ -189,10 +169,10 @@ public class GuardPolicy { return false; } else if (!limit_constraints.equals(other.limit_constraints)) return false; - if (recipe == null) { - if (other.recipe != null) + if (match_parameters==null){ + if(other.match_parameters !=null) return false; - } else if (!recipe.equals(other.recipe)) + } else if(!match_parameters.equals(other.match_parameters)) return false; return true; } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/MatchParameters.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/MatchParameters.java new file mode 100644 index 000000000..3696ab438 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/MatchParameters.java @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.openecomp.policy.controlloop.policy.guard; + +import java.util.LinkedList; +import java.util.List; + +public class MatchParameters { + private String controlLoopName; + private String actor; + private String recipe; + private List<String> targets; + + public MatchParameters() { + // Do Nothing Empty Constructor. + } + + public String getControlLoopName() { + return controlLoopName; + } + + public void setControlLoopName(String controlLoopName) { + this.controlLoopName = controlLoopName; + } + + public String getActor() { + return actor; + } + + public void setActor(String actor) { + this.actor = actor; + } + + public String getRecipe() { + return recipe; + } + + public void setRecipe(String recipe) { + this.recipe = recipe; + } + + public List<String> getTargets() { + return targets; + } + + public void setTargets(List<String> targets) { + this.targets = targets; + } + + public MatchParameters(String actor, String recipe) { + this.actor = actor; + this.recipe = recipe; + } + + public MatchParameters(String actor, String recipe, List<String> targets) { + this(actor, recipe); + if (targets != null) { + this.targets = new LinkedList<>(targets); + } + } + + public MatchParameters(String controlLoopName, String actor, String recipe, List<String> targets) { + this(actor, recipe, targets); + this.controlLoopName = controlLoopName; + } + + public MatchParameters(MatchParameters matchParameters) { + + this.controlLoopName = matchParameters.controlLoopName; + this.actor = matchParameters.actor; + this.recipe = matchParameters.recipe; + if (matchParameters.targets != null) { + this.targets = new LinkedList<>(matchParameters.targets); + } + } + + @Override + public String toString() { + return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe + + ", targets=" + targets + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((actor == null) ? 0 : actor.hashCode()); + result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode()); + result = prime * result + ((recipe == null) ? 0 : recipe.hashCode()); + result = prime * result + ((targets == null) ? 0 : targets.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MatchParameters other = (MatchParameters) obj; + if (actor == null) { + if (other.actor != null) + return false; + } else if (!actor.equals(other.actor)) + return false; + if (controlLoopName == null) { + if (other.controlLoopName != null) + return false; + } else if (!controlLoopName.equals(other.controlLoopName)) + return false; + if (recipe == null) { + if (other.recipe != null) + return false; + } else if (!recipe.equals(other.recipe)) + return false; + if (targets == null) { + if (other.targets != null) + return false; + } else if (!targets.equals(other.targets)) + return false; + return true; + } +}
\ No newline at end of file |