diff options
23 files changed, 341 insertions, 107 deletions
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManager.java index d82932b..58d3355 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManager.java @@ -33,12 +33,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +/** + * The Class PolicyManager. + */ @Component public class PolicyManager { @Autowired Environment env; + /** + * Gets the time limit and vertical topology by name. + * + * @param name the name + * @return the time limit and vertical topology by name + */ public TimeLimitAndVerticalTopology getTimeLimitAndVerticalTopologyByName(String name) { Policy policy = getPolicyForName(name); TimeLimitAndVerticalTopology returnPolicy = null; @@ -54,6 +63,12 @@ public class PolicyManager { } + /** + * Gets the policy for name. + * + * @param name the name + * @return the policy for name + */ public Policy getPolicyForName(String name) { Policy policy = null; try { @@ -64,6 +79,12 @@ public class PolicyManager { return policy; } + /** + * Gets the local policy for name. + * + * @param name the name + * @return the local policy for name + */ public Policy getLocalPolicyForName(String name) { String policyFolder = env.getProperty("cmso.local.policy.folder", "data/policies"); Policy policy = null; @@ -80,6 +101,11 @@ public class PolicyManager { return policy; } + /** + * Gets the supported policies. + * + * @return the supported policies + */ public List<Policy> getSupportedPolicies() { List<Policy> policies = new ArrayList<>(); try { @@ -90,6 +116,11 @@ public class PolicyManager { return policies; } + /** + * Gets the local supported policies. + * + * @return the local supported policies + */ public List<Policy> getLocalSupportedPolicies() { String policyFolder = env.getProperty("cmso.local.policy.folder", "data/policies"); List<Policy> policies = new ArrayList<>(); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/PolicyScope.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/PolicyScope.java index d569274..3e07748 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/PolicyScope.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/PolicyScope.java @@ -34,6 +34,7 @@ public class PolicyScope { public enum ServiceType { networkOnDemand } + public enum EntityType { vnf } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeLimitAndVerticalTopology.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeLimitAndVerticalTopology.java index 7af22e3..b883a86 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeLimitAndVerticalTopology.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeLimitAndVerticalTopology.java @@ -56,6 +56,7 @@ public class TimeLimitAndVerticalTopology { public enum ConflictScope { timeLimitAndVerticalTopology, } + public enum Type { vnf_pserver, } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeRange.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeRange.java index 0f8f851..cd23301 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeRange.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeRange.java @@ -19,6 +19,9 @@ package org.onap.optf.cmso.optimizer.availability.policies.model; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonSetter; + /* { @@ -28,23 +31,28 @@ package org.onap.optf.cmso.optimizer.availability.policies.model; */ public class TimeRange { - private String start_time; - private String end_time; + private String startTime; + private String endTime; - public String getStart_time() { - return start_time; + @JsonGetter("start_time") + public String getStartTime() { + return startTime; } - public void setStart_time(String start_time) { - this.start_time = start_time; + @JsonSetter("start_time") + public void setStartTime(String startTime) { + this.startTime = startTime; } - public String getEnd_time() { - return end_time; + @JsonGetter("end_time") + public String getEndTime() { + return endTime; } - public void setEnd_time(String end_time) { - this.end_time = end_time; + @JsonSetter("end_time") + public void setEndTime(String endTime) { + this.endTime = endTime; } + } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/timewindows/RecurringWindows.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/timewindows/RecurringWindows.java index c3536b7..81a848e 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/timewindows/RecurringWindows.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/timewindows/RecurringWindows.java @@ -127,8 +127,8 @@ public class RecurringWindows { List<TimeRange> ranges = available.getTimeRange(); if (ranges.size() == 0) { TimeRange range = new TimeRange(); - range.setStart_time("00:00:00+00:00"); - range.setStart_time("23:59:59+00:00"); + range.setStartTime("00:00:00+00:00"); + range.setEndTime("23:59:59+00:00"); ranges.add(range); } StringBuilder rdata = new StringBuilder(); @@ -148,8 +148,9 @@ public class RecurringWindows { Instant cwStartInstant = changeWindow.getStartTime().toInstant(); Instant cwEndInstant = changeWindow.getEndTime().toInstant(); - List<DateTime> startList = getRecurringList(range.getStart_time(), cwStartInstant, rdata, cwEndInstant, -1); - List<DateTime> endList = getRecurringList(range.getEnd_time(), cwStartInstant, rdata, cwEndInstant, startList.size()); + List<DateTime> startList = getRecurringList(range.getStartTime(), cwStartInstant, rdata, cwEndInstant, -1); + List<DateTime> endList = getRecurringList(range.getEndTime(), cwStartInstant, + rdata, cwEndInstant, startList.size()); // Pair them up to make change windows // Everything should be UTC time for (int i = 0; i < startList.size(); i++) { @@ -181,8 +182,8 @@ public class RecurringWindows { DateTime next = recur.next(); // System.out.println(next.toString()); if (endingSize == -1) { - if (next.isAfter(cwEndInstant.toEpochMilli())) { - break; + if (next.isAfter(cwEndInstant.toEpochMilli())) { + break; } } else { @@ -218,10 +219,18 @@ public class RecurringWindows { return instant.plus(date.toEpochMilli(), ChronoUnit.MILLIS); } + /** + * Gets the recurring list for change window. + * + * @param window the window + * @param durationInSeconds the duration in seconds + * @return the recurring list for change window + * @throws ParseException the parse exception + */ public static DateTimeIterator getRecurringListForChangeWindow(ChangeWindow window, Long durationInSeconds) throws ParseException { - String rdata = "RRULE:FREQ=MINUTELY;INTERVAL=" + durationInSeconds/60; + String rdata = "RRULE:FREQ=MINUTELY;INTERVAL=" + durationInSeconds / 60; DateTime start = new DateTime(window.getStartTime().toInstant().toEpochMilli()); DateTimeIterator recur = DateTimeIteratorFactory.createDateTimeIterator(rdata, start, DateTimeZone.UTC, true); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementAvailability.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementAvailability.java index ffaeeb9..ac5d2e7 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementAvailability.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementAvailability.java @@ -37,7 +37,10 @@ import org.onap.optf.cmso.optimizer.clients.topology.models.TopologyResponse; import org.onap.optf.cmso.optimizer.service.rs.models.ChangeWindow; import org.onap.optf.cmso.optimizer.service.rs.models.OptimizerRequest; -public class ElementAvailability extends ElementWindowMapping{ +/** + * The Class ElementAvailability. + */ +public class ElementAvailability extends ElementWindowMapping { private List<TimeLimitAndVerticalTopology> policies; private ActiveTicketsResponse ticketResponse; @@ -48,6 +51,15 @@ public class ElementAvailability extends ElementWindowMapping{ private Map<String, List<TicketData>> nodeUnAvailability = new TreeMap<>(); + /** + * Instantiates a new element availability. + * + * @param policies the policies + * @param optimizerRequest the optimizer request + * @param topologyResponse the topology response + * @param ticketResponse the ticket response + * @throws ParseException the parse exception + */ public ElementAvailability(List<TimeLimitAndVerticalTopology> policies, OptimizerRequest optimizerRequest, TopologyResponse topologyResponse, ActiveTicketsResponse ticketResponse) throws ParseException { super(optimizerRequest, topologyResponse); @@ -55,6 +67,12 @@ public class ElementAvailability extends ElementWindowMapping{ this.ticketResponse = ticketResponse; } + /** + * Populate. + * + * @param parameters the parameters + * @throws ParseException the parse exception + */ public void populate(OptimizerParameters parameters) throws ParseException { this.parameters = parameters; for (ChangeWindow changeWindow : optimizerRequest.getChangeWindows()) { @@ -78,7 +96,7 @@ public class ElementAvailability extends ElementWindowMapping{ parameters.setNumLoaders(1L); Long loaderCapacity = parameters.getNumElements(); List<Long> capacity = new ArrayList<>(); - for (Long slot =0L ; slot < parameters.getMaxTime() ; slot++) { + for (Long slot = 0L ; slot < parameters.getMaxTime() ; slot++) { capacity.add(loaderCapacity); } parameters.getLoaderCapacity().add(capacity); @@ -90,7 +108,7 @@ public class ElementAvailability extends ElementWindowMapping{ limit = parameters.getNumElements(); } - for (Long slot =0L ; slot < parameters.getMaxTime() ; slot++) { + for (Long slot = 0L ; slot < parameters.getMaxTime() ; slot++) { capacity.add(limit); } parameters.setElementSlotCapacity(capacity); @@ -137,10 +155,9 @@ public class ElementAvailability extends ElementWindowMapping{ } - private long calculateNumberOfSlotsInWindow(ChangeWindow window, Long duration) - { + private long calculateNumberOfSlotsInWindow(ChangeWindow window, Long duration) { long windowSize = window.getEndTime().getTime() - window.getStartTime().getTime(); - long numberOfSlots = windowSize /duration; + long numberOfSlots = windowSize / duration; return numberOfSlots; } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementWindowMapping.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementWindowMapping.java index 246a725..d2565f0 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementWindowMapping.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementWindowMapping.java @@ -41,6 +41,9 @@ import org.onap.optf.cmso.optimizer.service.rs.models.UnScheduledElement; import org.onap.optf.cmso.optimizer.service.rs.models.UnScheduledElement.NotScheduledReason; // This class ensures that the node indices nodes and the time slots are the +/** + * The Class ElementWindowMapping. + */ // same when processing the optimizer engine response as when initiating. public class ElementWindowMapping { @@ -50,6 +53,13 @@ public class ElementWindowMapping { protected Map<String, TopologyElementInfo> nodeInfo = new TreeMap<>(); private List<TopologyElementInfo> nodeArray = null; + /** + * Instantiates a new element window mapping. + * + * @param optimizerRequest the optimizer request + * @param topologyResponse the topology response + * @throws ParseException the parse exception + */ public ElementWindowMapping(OptimizerRequest optimizerRequest, TopologyResponse topologyResponse) throws ParseException { this.optimizerRequest = optimizerRequest; @@ -76,14 +86,24 @@ public class ElementWindowMapping { return recur; } + /** + * Initialize for process result. + */ public void initializeForProcessResult() { - // we need nodeInfo to be an array to speed up the result processing. - // but we need it sorted by elementId as when we created it.... - nodeArray = nodeInfo.values().stream().collect(Collectors.toList()); - nodeInfo.clear(); + // we need nodeInfo to be an array to speed up the result processing. + // but we need it sorted by elementId as when we created it.... + nodeArray = nodeInfo.values().stream().collect(Collectors.toList()); + nodeInfo.clear(); } + /** + * Process result. + * + * @param result the result + * @return the optimizer schedule info + * @throws ParseException the parse exception + */ public OptimizerScheduleInfo processResult(OptimizerSchedule result) throws ParseException { // When considering the memory vs performance // 5 minute duration for a month long change window is 8928 slots @@ -98,8 +118,9 @@ public class ElementWindowMapping { Integer slotIndex = 1; while (iter.hasNext()) { DateTime dateTime = iter.next(); - if (dateTime.isAfter(endWindow)) + if (dateTime.isAfter(endWindow)) { break; + } List<ElementSlot> list = mapSlotToElement.get(slotIndex); if (list != null) { list.stream().forEach(x -> x.setTime(dateTime.getMillis())); @@ -117,7 +138,7 @@ public class ElementWindowMapping { } private void updateInfo(ElementSlot slot, OptimizerScheduleInfo info) { - TopologyElementInfo element = nodeArray.get(slot.getElementIndex()-1); + TopologyElementInfo element = nodeArray.get(slot.getElementIndex() - 1); if (slot.getSlot() > 0) { ScheduledElement scheduled = new ScheduledElement(); Integer durationInSeconds = optimizerRequest.getNormalDuration(); @@ -127,7 +148,7 @@ public class ElementWindowMapping { scheduled.setDurationSeconds(durationInSeconds.longValue()); scheduled.setElementId(element.getElementId()); scheduled.setStartTime(new Date(slot.getTime())); - scheduled.setEndTime(new Date(slot.getTime() + (durationInSeconds*1000))); + scheduled.setEndTime(new Date(slot.getTime() + (durationInSeconds * 1000))); scheduled.setScheduleType(ScheduleType.INDIVIDUAL); scheduled.setGroupId(getGroupId(scheduled.getElementId())); info.getScheduledElements().add(scheduled); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java index b382278..7c6db2a 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java @@ -243,8 +243,6 @@ public class OptimizerClient { private ProcessBuilder buildCommand(Path inputFileName, Path outputFileName, String timeLimit) { ProcessBuilder processBuilder = new ProcessBuilder(); List<String> command = new ArrayList<>(); - String commandline = - env.getProperty("cmso.minizinc.command.commandline", "/bin/bash -x scripts/minizinc/run.sh"); String minizinc = env.getProperty("cmso.minizinc.command.exe", "minizinc"); String solver = env.getProperty("cmso.minizinc.command.solver", "OSICBC"); String script = env.getProperty("cmso.minizinc.command.mzn", "scripts/minizinc/generic_attributes.mzn"); @@ -255,6 +253,8 @@ public class OptimizerClient { environment.put("MINIZINC_OUTPUT", outputFileName.toString()); environment.put("MINIZINC_MZN", script); environment.put("MINIZINC_DZN", inputFileName.toString()); + String commandline = + env.getProperty("cmso.minizinc.command.commandline", "/bin/bash -x scripts/minizinc/run.sh"); for (String arg : commandline.split(" ")) { command.add(arg); } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java index c911804..6724551 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java @@ -105,19 +105,15 @@ public class OptimizerRequestManager { private void buildFinalResponse(Request requestRow, OptimizerEngineResponse apiResponse) { Optional<Response> opt = responseDao.findById(requestRow.getUuid()); Response responseRow = null; - if (opt.isPresent()) - { + if (opt.isPresent()) { responseRow = opt.get(); } - if (responseRow == null) - { + if (responseRow == null) { responseRow = new Response(); responseRow.setUuid(requestRow.getUuid()); } - try - { - OptimizerResults results = apiResponse.getOptimizerResults(); + try { OptimizerResponse response = new OptimizerResponse(); response.setRequestId(requestRow.getUuid().toString()); response.setStatus(OptimizeScheduleStatus.COMPLETED); @@ -127,6 +123,7 @@ public class OptimizerRequestManager { TopologyResponse topologyResponse = topologyRequestManager.getTopologyResponse(requestRow.getUuid()); ElementWindowMapping ewm = new ElementWindowMapping(optimizerResquest, topologyResponse); ewm.initializeForProcessResult(); + OptimizerResults results = apiResponse.getOptimizerResults(); for (OptimizerSchedule result : results.getSchedules()) { OptimizerScheduleInfo info = ewm.processResult(result); if (info != null) { @@ -137,9 +134,7 @@ public class OptimizerRequestManager { requestRow.setStatus(OptimizeScheduleStatus.COMPLETED.toString()); responseDao.save(responseRow); requestDao.save(requestRow); - } - catch (Exception e) - { + } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); requestRow.setStatus(OptimizeScheduleStatus.FAILED.toString()); requestRow.setMessage(e.getMessage()); @@ -175,5 +170,4 @@ public class OptimizerRequestManager { - } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerEngineResponse.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerEngineResponse.java index 7315b31..c353221 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerEngineResponse.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerEngineResponse.java @@ -18,8 +18,7 @@ package org.onap.optf.cmso.optimizer.clients.optimizer.models; -public class OptimizerEngineResponse -{ +public class OptimizerEngineResponse { public enum OptimizerEngineResponseStatus { IN_PROGRESS, COMPLETED, FAILED, IN_QUEUE, @@ -30,33 +29,43 @@ public class OptimizerEngineResponse private OptimizerEngineResponseStatus status; private Integer pollingSeconds; private String errorMessage; + public String getRequestId() { return requestId; } + public void setRequestId(String requestId) { this.requestId = requestId; } + public OptimizerResults getOptimizerResults() { return optimizerResults; } + public void setOptimizerResults(OptimizerResults oprimizerResults) { this.optimizerResults = oprimizerResults; } + public OptimizerEngineResponseStatus getStatus() { return status; } + public void setStatus(OptimizerEngineResponseStatus status) { this.status = status; } + public Integer getPollingSeconds() { return pollingSeconds; } + public void setPollingSeconds(Integer pollingSeconds) { this.pollingSeconds = pollingSeconds; } + public String getErrorMessage() { return errorMessage; } + public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerOutResults.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerOutResults.java index 2c1c777..db880c3 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerOutResults.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerOutResults.java @@ -31,8 +31,8 @@ public class OptimizerOutResults { return elapsedMillis; } - public void setElapsedMillis(Long elapsed_millis) { - this.elapsedMillis = elapsed_millis; + public void setElapsedMillis(Long elapsedMillis) { + this.elapsedMillis = elapsedMillis; } public List<OptimizerOutSchedule> getResults() { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerParameters.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerParameters.java index be74e37..6af307c 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerParameters.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerParameters.java @@ -22,6 +22,9 @@ import java.util.ArrayList; import java.util.List; +/** + * The Class OptimizerParameters. + */ /* * numElements = 5; maxTime = 5; @@ -56,88 +59,193 @@ public class OptimizerParameters { private List<List<Long>> attributes = new ArrayList<>(); private List<List<Long>> attributeConcurrencyLimit = new ArrayList<>(); + /** + * Gets the num elements. + * + * @return the num elements + */ public Long getNumElements() { return numElements; } + /** + * Sets the num elements. + * + * @param numElements the new num elements + */ public void setNumElements(Long numElements) { this.numElements = numElements; } + /** + * Gets the max time. + * + * @return the max time + */ public Long getMaxTime() { return maxTime; } + /** + * Sets the max time. + * + * @param maxTime the new max time + */ public void setMaxTime(Long maxTime) { this.maxTime = maxTime; } + /** + * Gets the num loaders. + * + * @return the num loaders + */ public Long getNumLoaders() { return numLoaders; } + /** + * Sets the num loaders. + * + * @param numLoaders the new num loaders + */ public void setNumLoaders(Long numLoaders) { this.numLoaders = numLoaders; } + /** + * Gets the no conflict. + * + * @return the no conflict + */ public List<List<Boolean>> getNoConflict() { return noConflict; } + /** + * Sets the no conflict. + * + * @param noConflict the new no conflict + */ public void setNoConflict(List<List<Boolean>> noConflict) { this.noConflict = noConflict; } + /** + * Gets the element slot capacity. + * + * @return the element slot capacity + */ public List<Long> getElementSlotCapacity() { return elementSlotCapacity; } + /** + * Sets the element slot capacity. + * + * @param slotCapacity the new element slot capacity + */ public void setElementSlotCapacity(List<Long> slotCapacity) { this.elementSlotCapacity = slotCapacity; } + /** + * Gets the loader capacity. + * + * @return the loader capacity + */ public List<List<Long>> getLoaderCapacity() { return loaderCapacity; } + /** + * Sets the loader capacity. + * + * @param loaderCapacity the new loader capacity + */ public void setLoaderCapacity(List<List<Long>> loaderCapacity) { this.loaderCapacity = loaderCapacity; } + /** + * Gets the num attributes. + * + * @return the num attributes + */ public Long getNumAttributes() { return numAttributes; } + /** + * Sets the num attributes. + * + * @param numAttributes the new num attributes + */ public void setNumAttributes(Long numAttributes) { this.numAttributes = numAttributes; } + /** + * Gets the attributes range. + * + * @return the attributes range + */ public List<Long> getAttributesRange() { return attributesRange; } + /** + * Sets the attributes range. + * + * @param attributesRange the new attributes range + */ public void setAttributesRange(List<Long> attributesRange) { this.attributesRange = attributesRange; } + /** + * Gets the attributes. + * + * @return the attributes + */ public List<List<Long>> getAttributes() { return attributes; } + /** + * Sets the attributes. + * + * @param attributes the new attributes + */ public void setAttributes(List<List<Long>> attributes) { this.attributes = attributes; } + /** + * Gets the attribute concurrency limit. + * + * @return the attribute concurrency limit + */ public List<List<Long>> getAttributeConcurrencyLimit() { return attributeConcurrencyLimit; } + /** + * Sets the attribute concurrency limit. + * + * @param attributeConcurrencyLimit the new attribute concurrency limit + */ public void setAttributeConcurrencyLimit(List<List<Long>> attributeConcurrencyLimit) { this.attributeConcurrencyLimit = attributeConcurrencyLimit; } + /** + * To mini zinc. + * + * @return the string + */ public String toMiniZinc() { StringBuilder sb = new StringBuilder(); appendAttribute(sb, "numElements", numElements.toString()); @@ -152,21 +260,17 @@ public class OptimizerParameters { if (attributesRange.size() > 0) { appendAttribute(sb, "attributesRange", "[" + formatLongList(attributesRange) + "]"); - } - else { + } else { appendAttribute(sb, "attributesRange", "[]"); } if (attributes.size() > 0) { appendAttribute(sb, "attributes", "[|\n" + formatLongRows(attributes) + "|]"); - } - else { + } else { appendAttribute(sb, "attributes", "array2d(1..numElements, 1..numAttributes, [])"); } if (attributeConcurrencyLimit.size() > 0) { appendAttribute(sb, "attributeConcurrencyLimit", "[|\n" + formatLongRows(attributeConcurrencyLimit) + "|]"); - } - else - { + } else { appendAttribute(sb, "attributeConcurrencyLimit", "array2d(1..numAttributes, 1..maxTime, [])"); } return sb.toString(); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResponseUtility.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResponseUtility.java index 89208b2..595bc0d 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResponseUtility.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResponseUtility.java @@ -31,8 +31,17 @@ import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.introspector.Property; import org.yaml.snakeyaml.introspector.PropertyUtils; +/** + * The Class OptimizerResponseUtility. + */ public class OptimizerResponseUtility extends PropertyUtils { + /** + * Parses the optimizer result. + * + * @param resultsFile the results file + * @return the optimizer results + */ public OptimizerResults parseOptimizerResult(File resultsFile) { OptimizerResults results = null; try (InputStream input = new FileInputStream(resultsFile)) { @@ -73,6 +82,13 @@ public class OptimizerResponseUtility extends PropertyUtils { return optimizerSchedule; } + /** + * Gets the property. + * + * @param type the type + * @param name the name + * @return the property + */ @Override public Property getProperty(Class<? extends Object> type, String name) { name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResults.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResults.java index 9c31a9f..ca8a78b 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResults.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResults.java @@ -31,8 +31,8 @@ public class OptimizerResults { return elapsedMillis; } - public void setElapsedMillis(Long elapsed_millis) { - this.elapsedMillis = elapsed_millis; + public void setElapsedMillis(Long elapsedMillis) { + this.elapsedMillis = elapsedMillis; } public List<OptimizerSchedule> getSchedules() { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/Results.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/Results.java index 402bdf2..57698f6 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/Results.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/Results.java @@ -31,8 +31,8 @@ public class Results { return elapsedMillis; } - public void setElapsedMillis(Long elapsed_millis) { - this.elapsedMillis = elapsed_millis; + public void setElapsedMillis(Long elapsedMillis) { + this.elapsedMillis = elapsedMillis; } public List<OptimizerSchedule> getSchedules() { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/TicketMgtRequestManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/TicketMgtRequestManager.java index 8520809..85ff950 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/TicketMgtRequestManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/TicketMgtRequestManager.java @@ -61,21 +61,22 @@ public class TicketMgtRequestManager { * @return the active tickets response */ public ActiveTicketsResponse createTicketsRequest(Request requestRow) { - Ticket row = null; - Optional<Ticket> rowOpt = ticketDao.findById(requestRow.getUuid()); - if (rowOpt.isPresent()) { - row = rowOpt.get(); + Ticket row = null; + Optional<Ticket> rowOpt = ticketDao.findById(requestRow.getUuid()); + if (rowOpt.isPresent()) { + row = rowOpt.get(); + + } + if (row == null) { + row = new Ticket(); + row.setUuid(requestRow.getUuid()); + row.setTicketsRetries(0); + } + ActiveTicketsResponse apiResponse = ticketmgtClient.makeRequest(requestRow, row); + ticketDao.save(row); + return apiResponse; + } - } - if (row == null) { - row = new Ticket(); - row.setUuid(requestRow.getUuid()); - row.setTicketsRetries(0); - } - ActiveTicketsResponse apiResponse = ticketmgtClient.makeRequest(requestRow, row); - ticketDao.save(row); - return apiResponse; - } /** * Gets the existing tickets. * diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/ActiveTicketsRequest.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/ActiveTicketsRequest.java index f03c6f3..b83212a 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/ActiveTicketsRequest.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/ActiveTicketsRequest.java @@ -51,7 +51,8 @@ public class ActiveTicketsRequest implements Serializable { private String requestId; @ApiModelProperty( - value = "Implementation specific name value pairs provided to be passed to Ticket Management query .") + value = "Implementation specific name value pairs provided" + + " to be passed to Ticket Management query .") private List<NameValue> commonData; @ApiModelProperty(value = "Lists of desired change windows for which TicketData will be returned.") diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/Availability.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/Availability.java index 37995bb..e5f1929 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/Availability.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/Availability.java @@ -1,33 +1,34 @@ /******************************************************************************* - * + * * Copyright © 2019 AT&T Intellectual Property. - * + * * 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. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * 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. ******************************************************************************/ + package org.onap.optf.cmso.optimizer.clients.ticketmgt.models; public enum Availability { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/TicketData.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/TicketData.java index 07b9f94..7ab7a0c 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/TicketData.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/TicketData.java @@ -28,6 +28,7 @@ * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ + package org.onap.optf.cmso.optimizer.clients.ticketmgt.models; import com.att.eelf.configuration.EELFLogger; diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyRequestManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyRequestManager.java index a1cb51d..f62a851 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyRequestManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyRequestManager.java @@ -87,10 +87,19 @@ public class TopologyRequestManager { } - public TopologyResponse getTopologyResponse(UUID uuid) throws JsonParseException, JsonMappingException, IOException { + /** + * Gets the topology response. + * + * @param uuid the uuid + * @return the topology response + * @throws JsonParseException the json parse exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + public TopologyResponse getTopologyResponse(UUID uuid) + throws JsonParseException, JsonMappingException, IOException { Topology row = getExistingTopology(uuid); - if (row != null) - { + if (row != null) { String responseString = row.getTopology(); return new ObjectMapper().readValue(responseString, TopologyResponse.class); } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/core/OptimizerManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/core/OptimizerManager.java index d2e3153..b61ec08 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/core/OptimizerManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/core/OptimizerManager.java @@ -163,13 +163,10 @@ public class OptimizerManager { initiateDataGathering(requestRow); requestDao.save(requestRow); OptimizeScheduleStatus status = OptimizeScheduleStatus.valueOf(requestRow.getStatus()); - if (status == OptimizeScheduleStatus.COMPLETED) - { + if (status == OptimizeScheduleStatus.COMPLETED) { // COmpletely synchronous optimization optimizerResponse = getCompletedOptimizerResponse(uuid); - } - else - { + } else { // One or more steps are asynchronous optimizerResponse.setStatus(status); optimizerResponse.setErrorMessage(""); @@ -195,7 +192,7 @@ public class OptimizerManager { case IN_PROGRESS: requestRow.setRequestStart(System.currentTimeMillis()); requestRow.setStatus(OptimizeScheduleStatus.TOPOLOGY_IN_PROGRESS.toString()); - return; + return; default: break; } @@ -259,17 +256,19 @@ public class OptimizerManager { requestRow.getUuid().toString()); } - public OptimizerResponse getCompletedOptimizerResponse(UUID uuid) - { + /** + * Gets the completed optimizer response. + * + * @param uuid the uuid + * @return the completed optimizer response + */ + public OptimizerResponse getCompletedOptimizerResponse(UUID uuid) { OptimizerResponse response = null; - Response responseRow = getResponseRow(uuid); - try - { + Response responseRow = getResponseRow(uuid); + try { String responseStr = responseRow.getRepsonse(); response = new ObjectMapper().readValue(responseStr, OptimizerResponse.class); - } - catch (Exception e) - { + } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); response = new OptimizerResponse(); response.setRequestId(uuid.toString()); @@ -279,11 +278,15 @@ public class OptimizerManager { return response; } - public Response getResponseRow(UUID uuid) - { + /** + * Gets the response row. + * + * @param uuid the uuid + * @return the response row + */ + public Response getResponseRow(UUID uuid) { Optional<Response> opt = responseDao.findById(uuid); - if (opt.isPresent()) - { + if (opt.isPresent()) { return opt.get(); } return null; @@ -296,8 +299,8 @@ public class OptimizerManager { if (requestOptional.isPresent()) { return requestOptional.get(); } - throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.EXPECTED_DATA_NOT_FOUND, - uuid.toString(), "Request table"); + throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.EXPECTED_DATA_NOT_FOUND, uuid.toString(), + "Request table"); } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterfaceImpl.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterfaceImpl.java index a2a018a..b475861 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterfaceImpl.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterfaceImpl.java @@ -76,8 +76,7 @@ public class OptimizerInterfaceImpl implements OptimizerInterface { try { optimizerManager.validate(request); // Throws CmsException if invalid message OptimizerResponse optimizerResponse = optimizerManager.processOptimizerRequest(request); - if (optimizerResponse != null) - { + if (optimizerResponse != null) { response = Response.ok(optimizerResponse).build(); } else { // Request will be processed asynchronously diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java index e9218b2..0e8b758 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java @@ -132,7 +132,8 @@ public class ChangeWindow implements Serializable { * absolute UTC times provided in tickets which should already be adjusted for time zone. * * @param test the test - * @param timeZoneOffset the time zone offset + * @param startTimeZoneOffset the starting time zone offset + * @param endTimeZoneOffset the ending time zone offset * @return true, if successful */ public boolean containsInTimeZone(ChangeWindow test, Integer startTimeZoneOffset, Integer endTimeZoneOffset) { @@ -147,6 +148,13 @@ public class ChangeWindow implements Serializable { return false; } + /** + * Contains in time zone. + * + * @param test the test + * @param timeZone the time zone + * @return true, if successful + */ public boolean containsInTimeZone(ChangeWindow test, String timeZone) { TimeZone tz = TimeZone.getTimeZone(timeZone); Integer startTimeZoneOffset = tz.getOffset(startTime.toInstant().truncatedTo(ChronoUnit.DAYS).toEpochMilli()); |