Updates to support Optimizer API 96/83596/3
authorJerry Flood <jflood@att.com>
Thu, 28 Mar 2019 10:56:01 +0000 (06:56 -0400)
committerJerry Flood <jflood@att.com>
Thu, 28 Mar 2019 13:54:53 +0000 (09:54 -0400)
Issue-ID: OPTFRA-437

Change-Id: I0c74fd3a740d657af51ca115c0fdd7e96777561c
Signed-off-by: Jerry Flood <jflood@att.com>
cmso-service/etc/config/optimizer.properties
cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java
cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java
cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java
cmso-service/src/main/java/org/onap/optf/cmso/filters/CmsoClientFilters.java
cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java
cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerElementInfo.java [new file with mode: 0644]
cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerRequest.java
cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java

index 13021ed..541946e 100644 (file)
 # limitations under the License.\r
 #-------------------------------------------------------------------------------\r
 \r
+## Loopback \r
 cmso.optimizer.request.url=http://localhost:8080/cmso/v1/loopbacktest/optimize/schedule\r
 cmso.optimizer.status.url=http://localhost:8080/cmso/v1/loopbacktest/optimize/schedule\r
 cmso.optimizer.health.url=http://localhost:8080/cmso/v1/loopbacktest/optimize/schedule/health\r
+\r
+## Local optimizer service\r
+#cmso.optimizer.request.url=http://127.0.0.1:7997/optimizer/v1/optimize/schedule\r
+#cmso.optimizer.status.url=http://127.0.0.1:7997/optimizer/v1/optimize/schedule\r
+#cmso.optimizer.health.url=http://127.0.0.1:7997/optimizer/v1/health?checkInterfaces=true\r
index 92bb3f3..e612734 100644 (file)
@@ -48,7 +48,6 @@ import org.springframework.transaction.annotation.Transactional;
 \r
 @Controller\r
 public class DispatcherServiceImpl implements DispacherService {\r
-    private static EELFLogger log = EELFManager.getInstance().getLogger(DispatcherServiceImpl.class);\r
     private static EELFLogger audit = EELFManager.getInstance().getAuditLogger();\r
     private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();\r
     private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
index 0987f8b..86fa038 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
  * Modifications Copyright © 2018 IBM.\r
- * \r
+ *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * \r
+ *\r
+ *\r
  * Unless otherwise specified, all documentation contained herein is licensed\r
  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
  * you may not use this documentation except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, documentation\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
@@ -61,7 +61,6 @@ import com.att.eelf.configuration.EELFManager;
  */\r
 @Component\r
 public class CMSQueueJob {\r
-    private static EELFLogger log = EELFManager.getInstance().getLogger(CMSQueueJob.class);\r
     private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
 \r
     @Autowired\r
index f3d98b3..9e1159a 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
  * Modifications Copyright © 2018 IBM.\r
- * \r
+ *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * \r
+ *\r
+ *\r
  * Unless otherwise specified, all documentation contained herein is licensed\r
  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
  * you may not use this documentation except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, documentation\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
@@ -52,7 +52,6 @@ import com.att.eelf.configuration.EELFManager;
 @Component\r
 @DisallowConcurrentExecution\r
 public class CmQuartzJob extends QuartzJobBean {\r
-    private static EELFLogger log = EELFManager.getInstance().getLogger(CmQuartzJob.class);\r
     private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
 \r
     @Autowired\r
index 00b8fe5..3f040ae 100644 (file)
@@ -32,8 +32,6 @@
 package org.onap.optf.cmso.filters;
 
 import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
 import java.io.IOException;
 import javax.ws.rs.client.ClientRequestContext;
 import javax.ws.rs.client.ClientRequestFilter;
@@ -51,7 +49,6 @@ import org.springframework.stereotype.Component;
 @Component
 public class CmsoClientFilters implements ClientRequestFilter, ClientResponseFilter {
 
-    private static EELFLogger log = EELFManager.getInstance().getLogger(CmsoClientFilters.class);
     private static String appId = "cmso";
 
     @Override
index d81c293..4db44f6 100644 (file)
@@ -52,9 +52,11 @@ import org.onap.optf.cmso.filters.CmsoClientFilters;
 import org.onap.optf.cmso.model.DomainData;
 import org.onap.optf.cmso.model.Schedule;
 import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.optimizer.model.OptimizerElementInfo;
 import org.onap.optf.cmso.optimizer.model.OptimizerRequest;
 import org.onap.optf.cmso.optimizer.model.OptimizerResponse;
 import org.onap.optf.cmso.service.rs.models.HealthCheckComponent;
+import org.onap.optf.cmso.service.rs.models.v2.ElementInfo;
 import org.onap.optf.cmso.service.rs.models.v2.NameValue;
 import org.onap.optf.cmso.service.rs.models.v2.SchedulingData;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -315,7 +317,7 @@ public class CmsoOptimizerClient {
             orequest.setPolicies(info.getPolicies());
             orequest.setRequestId(schedule.getScheduleId());
             orequest.setCommonData(marshallCommonData(schedule));
-            orequest.setElements(info.getElements());
+            orequest.setElements(marshallElements(info));
             orequest.setAdditionalDuration(info.getAdditionalDurationInSeconds());
             orequest.setNormalDuration(info.getNormalDurationInSeconds());
             orequest.setConcurrencyLimit(info.getConcurrencyLimit());
@@ -334,6 +336,20 @@ public class CmsoOptimizerClient {
         return null;
     }
 
+    private List<OptimizerElementInfo> marshallElements(SchedulingData info)
+    {
+        List<OptimizerElementInfo> list = new ArrayList<>();
+        List<ElementInfo> elementList = info.getElements();
+        for (ElementInfo element : elementList) {
+            OptimizerElementInfo optElement = new OptimizerElementInfo();
+            optElement.setElementData(element.getElementData());
+            optElement.setElementId(element.getElementId());
+            optElement.setGroupId(element.getGroupId());
+            list.add(optElement );
+        }
+        return list;
+    }
+
     private List<NameValue> marshallCommonData(Schedule schedule) {
         List<NameValue> nvList = new ArrayList<>();
         List<DomainData> ddList = schedule.getDomainData();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerElementInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerElementInfo.java
new file mode 100644 (file)
index 0000000..50c5621
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ *
+ * 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.model;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.optf.cmso.service.rs.models.v2.NameValue;
+
+@ApiModel(value = "Optimizer Element", description = "Element to be scheduled.")
+public class OptimizerElementInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerElementInfo.class);
+
+    @ApiModelProperty(value = "Element identifier")
+    private String elementId;
+
+    @ApiModelProperty(value = "Implementation specific element data.")
+    public List<NameValue> elementData = new ArrayList<>();
+
+    @ApiModelProperty(value = "VNF group identifier.")
+    public String groupId;
+
+
+    public String getElementId() {
+        return elementId;
+    }
+
+    public void setElementId(String elementId) {
+        this.elementId = elementId;
+    }
+
+
+    public List<NameValue> getElementData() {
+        return elementData;
+    }
+
+    public void setElementData(List<NameValue> elementData) {
+        this.elementData = elementData;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Override
+    public String toString() {
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            return mapper.writeValueAsString(this);
+        } catch (JsonProcessingException e) {
+            log.debug("Error in toString()", e);
+        }
+        return "";
+    }
+}
index 058d8c1..144f9db 100644 (file)
@@ -65,7 +65,7 @@ public class OptimizerRequest implements Serializable {
     private List<ChangeWindow> changeWindows = new ArrayList<>();
 
     @ApiModelProperty(value = "List of the elements to schedule.")
-    private List<ElementInfo> elements = new ArrayList<>();
+    private List<OptimizerElementInfo> elements = new ArrayList<>();
 
     @ApiModelProperty(value = "List of the policies to control optimization.")
     private List<PolicyInfo> policies = new ArrayList<>();
@@ -100,12 +100,12 @@ public class OptimizerRequest implements Serializable {
     }
 
 
-    public List<ElementInfo> getElements() {
+    public List<OptimizerElementInfo> getElements() {
         return elements;
     }
 
 
-    public void setElements(List<ElementInfo> elements) {
+    public void setElements(List<OptimizerElementInfo> elements) {
         this.elements = elements;
     }
 
index b179719..9be348a 100644 (file)
@@ -42,6 +42,7 @@ import org.joda.time.DateTime;
 import org.onap.observations.Observation;\r
 import org.onap.optf.cmso.common.LogMessages;\r
 import org.onap.optf.cmso.common.PropertiesManagement;\r
+import org.onap.optf.cmso.optimizer.model.OptimizerElementInfo;\r
 import org.onap.optf.cmso.optimizer.model.OptimizerRequest;\r
 import org.onap.optf.cmso.optimizer.model.OptimizerResponse;\r
 import org.onap.optf.cmso.optimizer.model.OptimizerScheduleInfo;\r
@@ -50,7 +51,6 @@ import org.onap.optf.cmso.optimizer.model.ScheduledElement.ScheduleType;
 import org.onap.optf.cmso.optimizer.model.UnScheduledElement;\r
 import org.onap.optf.cmso.service.rs.CmsoOptimizerCallbackImpl;\r
 import org.onap.optf.cmso.service.rs.models.v2.ChangeWindow;\r
-import org.onap.optf.cmso.service.rs.models.v2.ElementInfo;\r
 import org.onap.optf.cmso.wf.bean.WfCmResponse200;\r
 import org.onap.optf.cmso.wf.bean.WfMsoRequestReferences;\r
 import org.onap.optf.cmso.wf.bean.WfMsoResponse;\r
@@ -111,7 +111,7 @@ public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackSe
         Map<String, String> nodes = new HashMap<>();\r
         List<String> nodeList = new ArrayList<>();\r
         // get total number of nodes across all groups.\r
-        for (ElementInfo sr : request.getElements()) {\r
+        for (OptimizerElementInfo sr : request.getElements()) {\r
             nodes.put(sr.getElementId(), sr.getGroupId());\r
             nodeList.add(sr.getElementId());\r
         }\r