Naoki Shiota
Committed by Yuta HIGUCHI

Removed IntentId which is used only for allocating resources. (ONOS-4406)

Change-Id: I9a4ee5fbb5c0e569c058f34c1271ca573c8eb2f1
...@@ -23,7 +23,6 @@ import org.onosproject.newoptical.api.OpticalConnectivityId; ...@@ -23,7 +23,6 @@ import org.onosproject.newoptical.api.OpticalConnectivityId;
23 import org.onosproject.net.ConnectPoint; 23 import org.onosproject.net.ConnectPoint;
24 import org.onosproject.net.Link; 24 import org.onosproject.net.Link;
25 import org.onosproject.net.Path; 25 import org.onosproject.net.Path;
26 -import org.onosproject.net.intent.IntentId;
27 26
28 import java.time.Duration; 27 import java.time.Duration;
29 import java.util.HashSet; 28 import java.util.HashSet;
...@@ -48,11 +47,6 @@ public class OpticalConnectivity { ...@@ -48,11 +47,6 @@ public class OpticalConnectivity {
48 47
49 private final Set<PacketLinkRealizedByOptical> realizingLinks = new HashSet<>(); 48 private final Set<PacketLinkRealizedByOptical> realizingLinks = new HashSet<>();
50 49
51 - // TODO: This IntentId is used only to reserve bandwidth resource.
52 - // After ResourceManager is made to accept app-defined ResourceConsumer,
53 - // this Intent should be replaced with OpticalConnectivityId.
54 - private IntentId intentId;
55 -
56 private State state = State.CREATED; 50 private State state = State.CREATED;
57 51
58 public enum State { 52 public enum State {
...@@ -163,12 +157,4 @@ public class OpticalConnectivity { ...@@ -163,12 +157,4 @@ public class OpticalConnectivity {
163 public Set<PacketLinkRealizedByOptical> getRealizingLinks() { 157 public Set<PacketLinkRealizedByOptical> getRealizingLinks() {
164 return ImmutableSet.copyOf(realizingLinks); 158 return ImmutableSet.copyOf(realizingLinks);
165 } 159 }
166 -
167 - public IntentId getIntentId() {
168 - return intentId;
169 - }
170 -
171 - public void setIntentId(IntentId intentId) {
172 - this.intentId = intentId;
173 - }
174 } 160 }
......
...@@ -52,13 +52,10 @@ import org.onosproject.net.config.NetworkConfigService; ...@@ -52,13 +52,10 @@ import org.onosproject.net.config.NetworkConfigService;
52 import org.onosproject.net.device.DeviceService; 52 import org.onosproject.net.device.DeviceService;
53 import org.onosproject.net.intent.Intent; 53 import org.onosproject.net.intent.Intent;
54 import org.onosproject.net.intent.IntentEvent; 54 import org.onosproject.net.intent.IntentEvent;
55 -import org.onosproject.net.intent.IntentId;
56 import org.onosproject.net.intent.IntentListener; 55 import org.onosproject.net.intent.IntentListener;
57 import org.onosproject.net.intent.IntentService; 56 import org.onosproject.net.intent.IntentService;
58 -import org.onosproject.net.intent.Key;
59 import org.onosproject.net.intent.OpticalCircuitIntent; 57 import org.onosproject.net.intent.OpticalCircuitIntent;
60 import org.onosproject.net.intent.OpticalConnectivityIntent; 58 import org.onosproject.net.intent.OpticalConnectivityIntent;
61 -import org.onosproject.net.intent.PointToPointIntent;
62 import org.onosproject.net.link.LinkEvent; 59 import org.onosproject.net.link.LinkEvent;
63 import org.onosproject.net.link.LinkListener; 60 import org.onosproject.net.link.LinkListener;
64 import org.onosproject.net.link.LinkService; 61 import org.onosproject.net.link.LinkService;
...@@ -242,18 +239,6 @@ public class OpticalPathProvisioner ...@@ -242,18 +239,6 @@ public class OpticalPathProvisioner
242 OpticalConnectivityId id = OpticalConnectivityId.of(idCounter.getAndIncrement()); 239 OpticalConnectivityId id = OpticalConnectivityId.of(idCounter.getAndIncrement());
243 OpticalConnectivity connectivity = new OpticalConnectivity(id, path, bandwidth, latency); 240 OpticalConnectivity connectivity = new OpticalConnectivity(id, path, bandwidth, latency);
244 241
245 - ConnectPoint ingress = path.src();
246 - ConnectPoint egress = path.dst();
247 -
248 - Intent pktIntent = PointToPointIntent.builder()
249 - .appId(appId)
250 - .ingressPoint(ingress)
251 - .egressPoint(egress)
252 - .key(Key.of(id.id(), appId))
253 - .build();
254 -
255 - connectivity.setIntentId(pktIntent.id());
256 -
257 // store connectivity information 242 // store connectivity information
258 connectivities.put(connectivity.id(), connectivity); 243 connectivities.put(connectivity.id(), connectivity);
259 244
...@@ -470,10 +455,7 @@ public class OpticalPathProvisioner ...@@ -470,10 +455,7 @@ public class OpticalPathProvisioner
470 * @param connectivity Optical connectivity 455 * @param connectivity Optical connectivity
471 */ 456 */
472 private void updateBandwidthUsage(OpticalConnectivity connectivity) { 457 private void updateBandwidthUsage(OpticalConnectivity connectivity) {
473 - IntentId intentId = connectivity.getIntentId(); 458 + OpticalConnectivityId connectivityId = connectivity.id();
474 - if (intentId == null) {
475 - return;
476 - }
477 459
478 List<Link> links = connectivity.links(); 460 List<Link> links = connectivity.links();
479 461
...@@ -483,14 +465,14 @@ public class OpticalPathProvisioner ...@@ -483,14 +465,14 @@ public class OpticalPathProvisioner
483 Bandwidth.class).resource(connectivity.bandwidth().bps())) 465 Bandwidth.class).resource(connectivity.bandwidth().bps()))
484 .collect(Collectors.toList()); 466 .collect(Collectors.toList());
485 467
486 - log.debug("allocating bandwidth for {} : {}", connectivity.getIntentId(), resources); 468 + log.debug("allocating bandwidth for {} : {}", connectivityId, resources);
487 - List<ResourceAllocation> allocations = resourceService.allocate(intentId, resources); 469 + List<ResourceAllocation> allocations = resourceService.allocate(connectivityId, resources);
488 if (allocations.isEmpty()) { 470 if (allocations.isEmpty()) {
489 log.warn("Failed to allocate bandwidth {} to {}", 471 log.warn("Failed to allocate bandwidth {} to {}",
490 connectivity.bandwidth().bps(), resources); 472 connectivity.bandwidth().bps(), resources);
491 // TODO any recovery? 473 // TODO any recovery?
492 } 474 }
493 - log.debug("Done allocating bandwidth for {}", connectivity.getIntentId()); 475 + log.debug("Done allocating bandwidth for {}", connectivityId);
494 } 476 }
495 477
496 /** 478 /**
...@@ -498,18 +480,15 @@ public class OpticalPathProvisioner ...@@ -498,18 +480,15 @@ public class OpticalPathProvisioner
498 * @param connectivity Optical connectivity 480 * @param connectivity Optical connectivity
499 */ 481 */
500 private void releaseBandwidthUsage(OpticalConnectivity connectivity) { 482 private void releaseBandwidthUsage(OpticalConnectivity connectivity) {
501 - IntentId intentId = connectivity.getIntentId(); 483 + OpticalConnectivityId connectivityId = connectivity.id();
502 - if (intentId == null) {
503 - return;
504 - }
505 484
506 - log.debug("releasing bandwidth allocated to {}", connectivity.getIntentId()); 485 + log.debug("releasing bandwidth allocated to {}", connectivityId);
507 - if (!resourceService.release(connectivity.getIntentId())) { 486 + if (!resourceService.release(connectivityId)) {
508 log.warn("Failed to release bandwidth allocated to {}", 487 log.warn("Failed to release bandwidth allocated to {}",
509 - connectivity.getIntentId()); 488 + connectivityId);
510 // TODO any recovery? 489 // TODO any recovery?
511 } 490 }
512 - log.debug("DONE releasing bandwidth for {}", connectivity.getIntentId()); 491 + log.debug("DONE releasing bandwidth for {}", connectivityId);
513 } 492 }
514 493
515 private class BandwidthLinkWeight implements LinkWeight { 494 private class BandwidthLinkWeight implements LinkWeight {
......
...@@ -18,6 +18,8 @@ package org.onosproject.newoptical.api; ...@@ -18,6 +18,8 @@ package org.onosproject.newoptical.api;
18 import com.google.common.annotations.Beta; 18 import com.google.common.annotations.Beta;
19 import com.google.common.base.MoreObjects; 19 import com.google.common.base.MoreObjects;
20 import org.onlab.util.Identifier; 20 import org.onlab.util.Identifier;
21 +import org.onosproject.net.resource.ResourceConsumer;
22 +import org.onosproject.net.resource.ResourceConsumerId;
21 23
22 // TODO: After ResourceManager is made to accept app-defined ResourceConsumer, 24 // TODO: After ResourceManager is made to accept app-defined ResourceConsumer,
23 // this class should be implemented as ResourceConsumer. 25 // this class should be implemented as ResourceConsumer.
...@@ -25,7 +27,7 @@ import org.onlab.util.Identifier; ...@@ -25,7 +27,7 @@ import org.onlab.util.Identifier;
25 * ID for optical connectivity. 27 * ID for optical connectivity.
26 */ 28 */
27 @Beta 29 @Beta
28 -public final class OpticalConnectivityId extends Identifier<Long> { 30 +public final class OpticalConnectivityId extends Identifier<Long> implements ResourceConsumer {
29 31
30 public static OpticalConnectivityId of(long value) { 32 public static OpticalConnectivityId of(long value) {
31 return new OpticalConnectivityId(value); 33 return new OpticalConnectivityId(value);
...@@ -36,6 +38,11 @@ public final class OpticalConnectivityId extends Identifier<Long> { ...@@ -36,6 +38,11 @@ public final class OpticalConnectivityId extends Identifier<Long> {
36 } 38 }
37 39
38 @Override 40 @Override
41 + public ResourceConsumerId consumerId() {
42 + return ResourceConsumerId.of(this);
43 + }
44 +
45 + @Override
39 public String toString() { 46 public String toString() {
40 return MoreObjects.toStringHelper(this) 47 return MoreObjects.toStringHelper(this)
41 .add("value", id()) 48 .add("value", id())
......