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;
}
+ /**
+ * Gets the policy for name.
+ *
+ * @param name the name
+ * @return the policy for name
+ */
public Policy getPolicyForName(String name) {
Policy policy = null;
try {
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;
return policy;
}
+ /**
+ * Gets the supported policies.
+ *
+ * @return the supported policies
+ */
public List<Policy> getSupportedPolicies() {
List<Policy> policies = new ArrayList<>();
try {
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<>();
public enum ServiceType {
networkOnDemand
}
+
public enum EntityType {
vnf
}
public enum ConflictScope {
timeLimitAndVerticalTopology,
}
+
public enum Type {
vnf_pserver,
}
package org.onap.optf.cmso.optimizer.availability.policies.model;
+import com.fasterxml.jackson.annotation.JsonGetter;
+import com.fasterxml.jackson.annotation.JsonSetter;
+
/*
{
*/
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;
}
+
}
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();
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++) {
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 {
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);
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;
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);
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()) {
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);
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);
}
- 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;
}
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 {
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;
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
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()));
}
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();
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);
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");
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);
}
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);
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) {
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());
-
}
package org.onap.optf.cmso.optimizer.clients.optimizer.models;
-public class OptimizerEngineResponse
-{
+public class OptimizerEngineResponse {
public enum OptimizerEngineResponseStatus {
IN_PROGRESS, COMPLETED, FAILED, IN_QUEUE,
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;
}
return elapsedMillis;
}
- public void setElapsedMillis(Long elapsed_millis) {
- this.elapsedMillis = elapsed_millis;
+ public void setElapsedMillis(Long elapsedMillis) {
+ this.elapsedMillis = elapsedMillis;
}
public List<OptimizerOutSchedule> getResults() {
import java.util.List;
+/**
+ * The Class OptimizerParameters.
+ */
/*
* numElements = 5;
maxTime = 5;
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());
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();
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)) {
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);
return elapsedMillis;
}
- public void setElapsedMillis(Long elapsed_millis) {
- this.elapsedMillis = elapsed_millis;
+ public void setElapsedMillis(Long elapsedMillis) {
+ this.elapsedMillis = elapsedMillis;
}
public List<OptimizerSchedule> getSchedules() {
return elapsedMillis;
}
- public void setElapsedMillis(Long elapsed_millis) {
- this.elapsedMillis = elapsed_millis;
+ public void setElapsedMillis(Long elapsedMillis) {
+ this.elapsedMillis = elapsedMillis;
}
public List<OptimizerSchedule> getSchedules() {
* @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.
*
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.")
/*******************************************************************************
- *
+ *
* 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 {
* 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;
}
- 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);
}
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("");
case IN_PROGRESS:
requestRow.setRequestStart(System.currentTimeMillis());
requestRow.setStatus(OptimizeScheduleStatus.TOPOLOGY_IN_PROGRESS.toString());
- return;
+ return;
default:
break;
}
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());
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;
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");
}
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
* 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) {
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());