private Numerical computeHopCountECS(LinkNode head) { List<LinkNode> path = computeShortestLinkNodePath(head); if (path == null) return null; else { NumericalBuilder result = new NumericalBuilder(); BigDecimal cost = new BigDecimal(path.size()); return result.setCost(cost).build(); } } private List<LinkNode> computeShortestLinkNodePath(LinkNode head) {
private NumericalImpl(NumericalBuilder base) { this._cost = base.getCost(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.endpointcost.data.endpoint.costmap.data.endpoint.cost.map.endpoint.cost.cost.Numerical>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.endpointcost.data.endpoint.costmap.data.endpoint.cost.map.endpoint.cost.cost.Numerical>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.endpointcost.data.endpoint.costmap.data.endpoint.cost.map.endpoint.cost.cost.Numerical>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.endpointcost.data.endpoint.costmap.data.endpoint.cost.map.endpoint.cost.cost.Numerical>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
public NumericalBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.endpointcost.data.endpoint.costmap.data.endpoint.cost.map.endpoint.cost.cost.Numerical>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.endpointcost.data.endpoint.costmap.data.endpoint.cost.map.endpoint.cost.cost.Numerical> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
@Override protected Cost computeCost(TypedAddressData src, TypedAddressData dst, CostTypeData costType) { NumericalBuilder numericalBuilder = new NumericalBuilder(); if (validSourceAndDest(src, dst)) { if (isAddressEqual(src,dst)) { return numericalBuilder.setCost(new BigDecimal(0)).build(); } MatchFields matchFields = createMatchField(src,dst); LinkNode head = routingService.buildRoutePath(matchFields); if (head != null) { return computeCostBasedOnCostType(head, costType); } } return null; }
private Numerical computeBandwidthECS(LinkNode head) { //// TODO: 16-3-3 Long result = null; LinkedList<LinkNode> queue = new LinkedList<>(); Map<LinkNode, Long> maxBw = new HashMap<LinkNode, Long>(); queue.addLast(head); maxBw.put(head, head.availableBandwidth()); while (!queue.isEmpty()) { LinkNode now = queue.pop(); Long topBw = maxBw.get(now)==null?0L:maxBw.get(now); if (now.isDestHost()) { result = maxBw.get(now); } for (LinkNode child : now.children()) { Long bw = (child.availableBandwidth() > topBw) ? child.availableBandwidth() : topBw; if (maxBw.containsKey(child)) { Long currentBw = maxBw.get(child); if (bw > currentBw) { maxBw.put(child, bw); queue.addLast(child); } } else { maxBw.put(child, bw); queue.addLast(child); } } } NumericalBuilder re = new NumericalBuilder(); return (result == null) ? null : re.setCost(new BigDecimal(-result/500)).build(); }