From 806052bf4df8bd023cfb391794bc5937f2624716 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 2 Aug 2017 15:09:24 -0700 Subject: Convert tabs to spaces Per Java Code Style Guide: https://wiki.onap.org/display/DW/Java+code+style Converting tabs to 4 spaces. Issue-Id: SDNC-25 Change-Id: I99ce6c244df72f805b52d0d66403d8b76d9929ae Signed-off-by: Marcus G K Williams --- .../org/openecomp/sdnc/ra/comp/AllocationRule.java | 18 +- .../sdnc/ra/comp/EndPointAllocationDefinition.java | 50 +-- .../openecomp/sdnc/ra/comp/EndPointAllocator.java | 14 +- .../sdnc/ra/comp/EndPointAllocatorImpl.java | 336 ++++++++++----------- .../org/openecomp/sdnc/ra/comp/EndPointData.java | 12 +- .../org/openecomp/sdnc/ra/comp/EquipmentCheck.java | 12 +- .../org/openecomp/sdnc/ra/comp/PreferenceRule.java | 6 +- .../org/openecomp/sdnc/ra/comp/ServiceData.java | 18 +- 8 files changed, 233 insertions(+), 233 deletions(-) (limited to 'resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp') diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/AllocationRule.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/AllocationRule.java index 0877933b..260d9d01 100644 --- a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/AllocationRule.java +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/AllocationRule.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,12 +26,12 @@ import org.openecomp.sdnc.rm.data.AllocationRequest; public interface AllocationRule { - AllocationRequest buildAllocationRequest( - String resourceUnionId, - String resourceSetId, - String endPointPosition, - ServiceData serviceData, - EquipmentData equipmentData, - boolean checkOnly, - boolean change); + AllocationRequest buildAllocationRequest( + String resourceUnionId, + String resourceSetId, + String endPointPosition, + ServiceData serviceData, + EquipmentData equipmentData, + boolean checkOnly, + boolean change); } diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocationDefinition.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocationDefinition.java index 21e49c3a..5a5623c1 100644 --- a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocationDefinition.java +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocationDefinition.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,34 +27,34 @@ import org.openecomp.sdnc.ra.equip.comp.EquipmentReader; public class EndPointAllocationDefinition { - public String serviceModel; - public String endPointPosition; - public EquipmentReader equipmentReader; - public List equipmentCheckList; - public List preferenceRuleList; - public List allocationRuleList; + public String serviceModel; + public String endPointPosition; + public EquipmentReader equipmentReader; + public List equipmentCheckList; + public List preferenceRuleList; + public List allocationRuleList; - public void setServiceModel(String serviceModel) { - this.serviceModel = serviceModel; - } + public void setServiceModel(String serviceModel) { + this.serviceModel = serviceModel; + } - public void setEndPointPosition(String endPointPosition) { - this.endPointPosition = endPointPosition; - } + public void setEndPointPosition(String endPointPosition) { + this.endPointPosition = endPointPosition; + } - public void setEquipmentReader(EquipmentReader equipmentReader) { - this.equipmentReader = equipmentReader; - } + public void setEquipmentReader(EquipmentReader equipmentReader) { + this.equipmentReader = equipmentReader; + } - public void setEquipmentCheckList(List equipmentCheckList) { - this.equipmentCheckList = equipmentCheckList; - } + public void setEquipmentCheckList(List equipmentCheckList) { + this.equipmentCheckList = equipmentCheckList; + } - public void setPreferenceRuleList(List preferenceRuleList) { - this.preferenceRuleList = preferenceRuleList; - } + public void setPreferenceRuleList(List preferenceRuleList) { + this.preferenceRuleList = preferenceRuleList; + } - public void setAllocationRuleList(List allocationRuleList) { - this.allocationRuleList = allocationRuleList; - } + public void setAllocationRuleList(List allocationRuleList) { + this.allocationRuleList = allocationRuleList; + } } diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocator.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocator.java index 645c953c..e817d587 100644 --- a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocator.java +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocator.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,10 @@ import java.util.Map; public interface EndPointAllocator { - List allocateEndPoints( - ServiceData serviceData, - Map equipmentConstraints, - boolean checkOnly, - boolean change, - int changeNumber); + List allocateEndPoints( + ServiceData serviceData, + Map equipmentConstraints, + boolean checkOnly, + boolean change, + int changeNumber); } diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocatorImpl.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocatorImpl.java index 1af81434..3d11f8e0 100644 --- a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocatorImpl.java +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointAllocatorImpl.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,171 +44,171 @@ import org.slf4j.LoggerFactory; public class EndPointAllocatorImpl implements EndPointAllocator { - private static final Logger log = LoggerFactory.getLogger(EndPointAllocatorImpl.class); - - private Map> endPointAllocationDefinitionMap; - - private ResourceManager resourceManager; - - @Override - public List allocateEndPoints( - ServiceData serviceData, - Map equipmentConstraints, - boolean checkOnly, - boolean change, - int changeNumber) { - List defList = endPointAllocationDefinitionMap.get(serviceData.serviceModel); - if (defList == null) - throw new NotImplementedException("Service model: " + serviceData.serviceModel + " not supported"); - - List epList = new ArrayList<>(); - for (EndPointAllocationDefinition def : defList) { - if (serviceData.endPointPosition != null && !serviceData.endPointPosition.equals(def.endPointPosition)) - continue; - - log.info( - "Starting allocation of end point: " + def.endPointPosition + ": " + serviceData.serviceInstanceId); - - String resourceUnionId = serviceData.serviceInstanceId + '/' + def.endPointPosition; - String resourceSetId = resourceUnionId + '/' + changeNumber; - - String equipmentId = (String) equipmentConstraints.get("equipment-id"); - if (equipmentId == null) { - EndPointData epExisting = readEndPoint(resourceUnionId, resourceSetId); - if (epExisting != null && epExisting.equipmentId != null) { - equipmentConstraints.put("equipment-id", epExisting.equipmentId); - - log.info("Trying assignment on the current equipment: " + epExisting.equipmentId); - } - } - - List equipList = def.equipmentReader.readEquipment(equipmentConstraints); - if (equipList == null || equipList.isEmpty()) { - log.info("Equipment not found for " + def.endPointPosition); - break; - } - - if (def.equipmentCheckList != null) { - for (EquipmentCheck filter : def.equipmentCheckList) { - List newEquipList = new ArrayList<>(); - for (EquipmentData equipData : equipList) - if (filter.checkEquipment(def.endPointPosition, serviceData, equipData, equipmentConstraints)) - newEquipList.add(equipData); - equipList = newEquipList; - } - if (equipList.isEmpty()) { - log.info("No equipment meets the requiremets for the service for: " + def.endPointPosition); - break; - } - } - - if (equipList.size() > 1 && def.preferenceRuleList != null && !def.preferenceRuleList.isEmpty()) { - - List prefEquipList = new ArrayList<>(); - for (EquipmentData equipData : equipList) { - PrefEquipment prefEquip = new PrefEquipment(); - prefEquip.equipData = equipData; - prefEquip.prefNumbers = new long[def.preferenceRuleList.size()]; - prefEquipList.add(prefEquip); - - int i = 0; - for (PreferenceRule prefRule : def.preferenceRuleList) - prefEquip.prefNumbers[i++] = - prefRule.assignOrderNumber(def.endPointPosition, serviceData, equipData); - } - - Collections.sort(prefEquipList); - - equipList = new ArrayList<>(); - for (PrefEquipment prefEquip : prefEquipList) - equipList.add(prefEquip.equipData); - } - - for (EquipmentData equipData : equipList) { - boolean allgood = true; - if (def.allocationRuleList != null) - for (AllocationRule allocationRule : def.allocationRuleList) { - AllocationRequest ar = allocationRule.buildAllocationRequest(resourceUnionId, resourceSetId, - def.endPointPosition, serviceData, equipData, checkOnly, change); - if (ar != null) { - AllocationOutcome ao = resourceManager.allocateResources(ar); - if (ao.status != AllocationStatus.Success) { - allgood = false; - break; - } - } - } - if (allgood) { - EndPointData ep = readEndPoint(resourceUnionId, resourceSetId); - epList.add(ep); - break; - } - } - } - - return epList; - } - - private EndPointData readEndPoint(String resourceUnionId, String resourceSetId) { - EndPointData ep = new EndPointData(); - ep.resourceUnionId = resourceUnionId; - ep.resourceSetId = resourceSetId; - - int i1 = resourceUnionId.indexOf('/'); - if (i1 > 0) - ep.endPointPosition = resourceUnionId.substring(i1 + 1); - - ep.data = new HashMap<>(); - - List rlist = resourceManager.getResourceUnion(resourceUnionId); - for (Resource r : rlist) { - if (r instanceof RangeResource) { - RangeResource rr = (RangeResource) r; - for (AllocationItem ai : r.allocationItems) - if (ai.resourceUnionId.equals(resourceUnionId)) { - RangeAllocationItem rai = (RangeAllocationItem) ai; - ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName, rai.used.first()); - } - } - if (r instanceof LimitResource) { - LimitResource rr = (LimitResource) r; - for (AllocationItem ai : r.allocationItems) - if (ai.resourceUnionId.equals(resourceUnionId)) { - LimitAllocationItem rai = (LimitAllocationItem) ai; - ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".allocated", rai.used); - ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".used", rr.used); - ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".assetId", - r.resourceKey.assetId); - } - } - } - - return ep; - } - - private static class PrefEquipment implements Comparable { - - public long[] prefNumbers; - public EquipmentData equipData; - - @Override - public int compareTo(PrefEquipment o) { - for (int i = 0; i < prefNumbers.length; i++) { - if (prefNumbers[i] < o.prefNumbers[i]) - return -1; - if (prefNumbers[i] > o.prefNumbers[i]) - return 1; - } - return 0; - } - } - - public void setEndPointAllocationDefinitionMap( - Map> endPointAllocationDefinitionMap) { - this.endPointAllocationDefinitionMap = endPointAllocationDefinitionMap; - } - - public void setResourceManager(ResourceManager resourceManager) { - this.resourceManager = resourceManager; - } + private static final Logger log = LoggerFactory.getLogger(EndPointAllocatorImpl.class); + + private Map> endPointAllocationDefinitionMap; + + private ResourceManager resourceManager; + + @Override + public List allocateEndPoints( + ServiceData serviceData, + Map equipmentConstraints, + boolean checkOnly, + boolean change, + int changeNumber) { + List defList = endPointAllocationDefinitionMap.get(serviceData.serviceModel); + if (defList == null) + throw new NotImplementedException("Service model: " + serviceData.serviceModel + " not supported"); + + List epList = new ArrayList<>(); + for (EndPointAllocationDefinition def : defList) { + if (serviceData.endPointPosition != null && !serviceData.endPointPosition.equals(def.endPointPosition)) + continue; + + log.info( + "Starting allocation of end point: " + def.endPointPosition + ": " + serviceData.serviceInstanceId); + + String resourceUnionId = serviceData.serviceInstanceId + '/' + def.endPointPosition; + String resourceSetId = resourceUnionId + '/' + changeNumber; + + String equipmentId = (String) equipmentConstraints.get("equipment-id"); + if (equipmentId == null) { + EndPointData epExisting = readEndPoint(resourceUnionId, resourceSetId); + if (epExisting != null && epExisting.equipmentId != null) { + equipmentConstraints.put("equipment-id", epExisting.equipmentId); + + log.info("Trying assignment on the current equipment: " + epExisting.equipmentId); + } + } + + List equipList = def.equipmentReader.readEquipment(equipmentConstraints); + if (equipList == null || equipList.isEmpty()) { + log.info("Equipment not found for " + def.endPointPosition); + break; + } + + if (def.equipmentCheckList != null) { + for (EquipmentCheck filter : def.equipmentCheckList) { + List newEquipList = new ArrayList<>(); + for (EquipmentData equipData : equipList) + if (filter.checkEquipment(def.endPointPosition, serviceData, equipData, equipmentConstraints)) + newEquipList.add(equipData); + equipList = newEquipList; + } + if (equipList.isEmpty()) { + log.info("No equipment meets the requiremets for the service for: " + def.endPointPosition); + break; + } + } + + if (equipList.size() > 1 && def.preferenceRuleList != null && !def.preferenceRuleList.isEmpty()) { + + List prefEquipList = new ArrayList<>(); + for (EquipmentData equipData : equipList) { + PrefEquipment prefEquip = new PrefEquipment(); + prefEquip.equipData = equipData; + prefEquip.prefNumbers = new long[def.preferenceRuleList.size()]; + prefEquipList.add(prefEquip); + + int i = 0; + for (PreferenceRule prefRule : def.preferenceRuleList) + prefEquip.prefNumbers[i++] = + prefRule.assignOrderNumber(def.endPointPosition, serviceData, equipData); + } + + Collections.sort(prefEquipList); + + equipList = new ArrayList<>(); + for (PrefEquipment prefEquip : prefEquipList) + equipList.add(prefEquip.equipData); + } + + for (EquipmentData equipData : equipList) { + boolean allgood = true; + if (def.allocationRuleList != null) + for (AllocationRule allocationRule : def.allocationRuleList) { + AllocationRequest ar = allocationRule.buildAllocationRequest(resourceUnionId, resourceSetId, + def.endPointPosition, serviceData, equipData, checkOnly, change); + if (ar != null) { + AllocationOutcome ao = resourceManager.allocateResources(ar); + if (ao.status != AllocationStatus.Success) { + allgood = false; + break; + } + } + } + if (allgood) { + EndPointData ep = readEndPoint(resourceUnionId, resourceSetId); + epList.add(ep); + break; + } + } + } + + return epList; + } + + private EndPointData readEndPoint(String resourceUnionId, String resourceSetId) { + EndPointData ep = new EndPointData(); + ep.resourceUnionId = resourceUnionId; + ep.resourceSetId = resourceSetId; + + int i1 = resourceUnionId.indexOf('/'); + if (i1 > 0) + ep.endPointPosition = resourceUnionId.substring(i1 + 1); + + ep.data = new HashMap<>(); + + List rlist = resourceManager.getResourceUnion(resourceUnionId); + for (Resource r : rlist) { + if (r instanceof RangeResource) { + RangeResource rr = (RangeResource) r; + for (AllocationItem ai : r.allocationItems) + if (ai.resourceUnionId.equals(resourceUnionId)) { + RangeAllocationItem rai = (RangeAllocationItem) ai; + ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName, rai.used.first()); + } + } + if (r instanceof LimitResource) { + LimitResource rr = (LimitResource) r; + for (AllocationItem ai : r.allocationItems) + if (ai.resourceUnionId.equals(resourceUnionId)) { + LimitAllocationItem rai = (LimitAllocationItem) ai; + ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".allocated", rai.used); + ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".used", rr.used); + ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".assetId", + r.resourceKey.assetId); + } + } + } + + return ep; + } + + private static class PrefEquipment implements Comparable { + + public long[] prefNumbers; + public EquipmentData equipData; + + @Override + public int compareTo(PrefEquipment o) { + for (int i = 0; i < prefNumbers.length; i++) { + if (prefNumbers[i] < o.prefNumbers[i]) + return -1; + if (prefNumbers[i] > o.prefNumbers[i]) + return 1; + } + return 0; + } + } + + public void setEndPointAllocationDefinitionMap( + Map> endPointAllocationDefinitionMap) { + this.endPointAllocationDefinitionMap = endPointAllocationDefinitionMap; + } + + public void setResourceManager(ResourceManager resourceManager) { + this.resourceManager = resourceManager; + } } diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointData.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointData.java index e425e373..eb030f3e 100644 --- a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointData.java +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EndPointData.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,9 @@ import java.util.Map; public class EndPointData { - public String resourceSetId; - public String resourceUnionId; - public String endPointPosition; - public String equipmentId; - public Map data; + public String resourceSetId; + public String resourceUnionId; + public String endPointPosition; + public String equipmentId; + public Map data; } diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EquipmentCheck.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EquipmentCheck.java index fcca4f7c..ab65b31e 100644 --- a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EquipmentCheck.java +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/EquipmentCheck.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,9 +27,9 @@ import org.openecomp.sdnc.ra.equip.data.EquipmentData; public interface EquipmentCheck { - boolean checkEquipment( - String endPointPosition, - ServiceData serviceData, - EquipmentData equipData, - Map equipmentConstraints); + boolean checkEquipment( + String endPointPosition, + ServiceData serviceData, + EquipmentData equipData, + Map equipmentConstraints); } diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/PreferenceRule.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/PreferenceRule.java index acaf10d9..d1287633 100644 --- a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/PreferenceRule.java +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/PreferenceRule.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,6 @@ import org.openecomp.sdnc.ra.equip.data.EquipmentData; public interface PreferenceRule { - // Smaller order number is preferred - int assignOrderNumber(String endPointPosition, ServiceData serviceData, EquipmentData equipData); + // Smaller order number is preferred + int assignOrderNumber(String endPointPosition, ServiceData serviceData, EquipmentData equipData); } diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/ServiceData.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/ServiceData.java index 0d29e54f..685f0988 100644 --- a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/ServiceData.java +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/comp/ServiceData.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,12 +25,12 @@ import java.util.Map; public class ServiceData { - public String serviceModel; - public String serviceInstanceId; - public String resourceSetId; - public String resourceUnionId; - public String resourceShareGroup; - public String endPointPosition; - public String resourceName; - public Map data; + public String serviceModel; + public String serviceInstanceId; + public String resourceSetId; + public String resourceUnionId; + public String resourceShareGroup; + public String endPointPosition; + public String resourceName; + public Map data; } -- cgit 1.2.3-korg