cheng fan
Committed by Gerrit Code Review

[ONOS-2096]Revert useless modifies

Change-Id: I5d6df8690a95ffb36b656a39a45a07d2955a9693

[ONOS-2096]Revert useless modifies

Change-Id: I5d6df8690a95ffb36b656a39a45a07d2955a9693
...@@ -20,6 +20,7 @@ import java.util.Collection; ...@@ -20,6 +20,7 @@ import java.util.Collection;
20 import org.onosproject.core.ApplicationId; 20 import org.onosproject.core.ApplicationId;
21 import org.onosproject.incubator.net.tunnel.Tunnel.Type; 21 import org.onosproject.incubator.net.tunnel.Tunnel.Type;
22 import org.onosproject.net.Annotations; 22 import org.onosproject.net.Annotations;
23 +import org.onosproject.net.DeviceId;
23 24
24 /** 25 /**
25 * Service for interacting with the inventory of tunnels. 26 * Service for interacting with the inventory of tunnels.
...@@ -186,6 +187,14 @@ public interface TunnelService { ...@@ -186,6 +187,14 @@ public interface TunnelService {
186 int tunnelCount(); 187 int tunnelCount();
187 188
188 /** 189 /**
190 + * Returns the collection of tunnels applied on the specified device.
191 + *
192 + * @param deviceId device identifier
193 + * @return collection of tunnels
194 + */
195 + Iterable<Tunnel> getTunnels(DeviceId deviceId);
196 +
197 + /**
189 * Adds the specified tunnel listener. 198 * Adds the specified tunnel listener.
190 * 199 *
191 * @param listener tunnel listener 200 * @param listener tunnel listener
......
...@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
19 import static org.slf4j.LoggerFactory.getLogger; 19 import static org.slf4j.LoggerFactory.getLogger;
20 20
21 import java.util.Collection; 21 import java.util.Collection;
22 +import java.util.Collections;
22 import java.util.Set; 23 import java.util.Set;
23 24
24 import org.apache.felix.scr.annotations.Activate; 25 import org.apache.felix.scr.annotations.Activate;
...@@ -48,6 +49,7 @@ import org.onosproject.incubator.net.tunnel.TunnelStore; ...@@ -48,6 +49,7 @@ import org.onosproject.incubator.net.tunnel.TunnelStore;
48 import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate; 49 import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate;
49 import org.onosproject.incubator.net.tunnel.TunnelSubscription; 50 import org.onosproject.incubator.net.tunnel.TunnelSubscription;
50 import org.onosproject.net.Annotations; 51 import org.onosproject.net.Annotations;
52 +import org.onosproject.net.DeviceId;
51 import org.onosproject.net.Path; 53 import org.onosproject.net.Path;
52 import org.onosproject.net.provider.AbstractProviderRegistry; 54 import org.onosproject.net.provider.AbstractProviderRegistry;
53 import org.onosproject.net.provider.AbstractProviderService; 55 import org.onosproject.net.provider.AbstractProviderService;
...@@ -373,4 +375,9 @@ public class TunnelManager ...@@ -373,4 +375,9 @@ public class TunnelManager
373 } 375 }
374 } 376 }
375 377
378 + @Override
379 + public Iterable<Tunnel> getTunnels(DeviceId deviceId) {
380 + return Collections.emptyList();
381 + }
382 +
376 } 383 }
......
...@@ -53,6 +53,10 @@ ...@@ -53,6 +53,10 @@
53 <classifier>tests</classifier> 53 <classifier>tests</classifier>
54 </dependency> 54 </dependency>
55 <dependency> 55 <dependency>
56 + <groupId>org.onosproject</groupId>
57 + <artifactId>onos-incubator-api</artifactId>
58 + </dependency>
59 + <dependency>
56 <groupId>com.sun.jersey.contribs</groupId> 60 <groupId>com.sun.jersey.contribs</groupId>
57 <artifactId>jersey-multipart</artifactId> 61 <artifactId>jersey-multipart</artifactId>
58 </dependency> 62 </dependency>
......
...@@ -27,6 +27,9 @@ import org.onosproject.cluster.ControllerNode; ...@@ -27,6 +27,9 @@ import org.onosproject.cluster.ControllerNode;
27 import org.onosproject.cluster.NodeId; 27 import org.onosproject.cluster.NodeId;
28 import org.onosproject.core.CoreService; 28 import org.onosproject.core.CoreService;
29 import org.onosproject.incubator.net.PortStatisticsService; 29 import org.onosproject.incubator.net.PortStatisticsService;
30 +import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
31 +import org.onosproject.incubator.net.tunnel.Tunnel;
32 +import org.onosproject.incubator.net.tunnel.TunnelService;
30 import org.onosproject.mastership.MastershipService; 33 import org.onosproject.mastership.MastershipService;
31 import org.onosproject.net.Annotated; 34 import org.onosproject.net.Annotated;
32 import org.onosproject.net.AnnotationKeys; 35 import org.onosproject.net.AnnotationKeys;
...@@ -143,6 +146,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -143,6 +146,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
143 protected StatisticService flowStatsService; 146 protected StatisticService flowStatsService;
144 protected PortStatisticsService portStatsService; 147 protected PortStatisticsService portStatsService;
145 protected TopologyService topologyService; 148 protected TopologyService topologyService;
149 + protected TunnelService tunnelService;
146 150
147 protected enum StatsType { 151 protected enum StatsType {
148 FLOW, PORT 152 FLOW, PORT
...@@ -176,6 +180,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -176,6 +180,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
176 flowStatsService = directory.get(StatisticService.class); 180 flowStatsService = directory.get(StatisticService.class);
177 portStatsService = directory.get(PortStatisticsService.class); 181 portStatsService = directory.get(PortStatisticsService.class);
178 topologyService = directory.get(TopologyService.class); 182 topologyService = directory.get(TopologyService.class);
183 + tunnelService = directory.get(TunnelService.class);
179 184
180 String ver = directory.get(CoreService.class).version().toString(); 185 String ver = directory.get(CoreService.class).version().toString();
181 version = ver.replace(".SNAPSHOT", "*").replaceFirst("~.*$", ""); 186 version = ver.replace(".SNAPSHOT", "*").replaceFirst("~.*$", "");
...@@ -446,6 +451,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -446,6 +451,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
446 new Prop("Topology SCCs", format(topology.clusterCount())), 451 new Prop("Topology SCCs", format(topology.clusterCount())),
447 new Separator(), 452 new Separator(),
448 new Prop("Intents", format(intentService.getIntentCount())), 453 new Prop("Intents", format(intentService.getIntentCount())),
454 + new Prop("Tunnels", format(tunnelService.tunnelCount())),
449 new Prop("Flows", format(flowService.getFlowRuleCount())), 455 new Prop("Flows", format(flowService.getFlowRuleCount())),
450 new Prop("Version", version))); 456 new Prop("Version", version)));
451 } 457 }
...@@ -457,6 +463,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -457,6 +463,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
457 String name = annot.value(AnnotationKeys.NAME); 463 String name = annot.value(AnnotationKeys.NAME);
458 int portCount = deviceService.getPorts(deviceId).size(); 464 int portCount = deviceService.getPorts(deviceId).size();
459 int flowCount = getFlowCount(deviceId); 465 int flowCount = getFlowCount(deviceId);
466 + int tunnelCount = getTunnelCount(deviceId);
460 return JsonUtils.envelope("showDetails", sid, 467 return JsonUtils.envelope("showDetails", sid,
461 json(isNullOrEmpty(name) ? deviceId.toString() : name, 468 json(isNullOrEmpty(name) ? deviceId.toString() : name,
462 device.type().toString().toLowerCase(), 469 device.type().toString().toLowerCase(),
...@@ -472,7 +479,9 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -472,7 +479,9 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
472 new Prop("Longitude", annot.value(AnnotationKeys.LONGITUDE)), 479 new Prop("Longitude", annot.value(AnnotationKeys.LONGITUDE)),
473 new Separator(), 480 new Separator(),
474 new Prop("Ports", Integer.toString(portCount)), 481 new Prop("Ports", Integer.toString(portCount)),
475 - new Prop("Flows", Integer.toString(flowCount)))); 482 + new Prop("Flows", Integer.toString(flowCount)),
483 + new Prop("Tunnels", Integer.toString(tunnelCount))
484 + ));
476 } 485 }
477 486
478 protected int getFlowCount(DeviceId deviceId) { 487 protected int getFlowCount(DeviceId deviceId) {
...@@ -485,6 +494,22 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -485,6 +494,22 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
485 return count; 494 return count;
486 } 495 }
487 496
497 + protected int getTunnelCount(DeviceId deviceId) {
498 + int count = 0;
499 + Collection<Tunnel> tunnels = tunnelService.queryAllTunnels();
500 + for (Tunnel tunnel : tunnels) {
501 + OpticalTunnelEndPoint src = (OpticalTunnelEndPoint) tunnel.src();
502 + OpticalTunnelEndPoint dst = (OpticalTunnelEndPoint) tunnel.dst();
503 + DeviceId srcDevice = (DeviceId) src.elementId().get();
504 + DeviceId dstDevice = (DeviceId) dst.elementId().get();
505 + if (srcDevice.toString().equals(deviceId.toString())
506 + || dstDevice.toString().equals(deviceId.toString())) {
507 + count++;
508 + }
509 + }
510 + return count;
511 + }
512 +
488 // Counts all entries that egress on the given device links. 513 // Counts all entries that egress on the given device links.
489 protected Map<Link, Integer> getFlowCounts(DeviceId deviceId) { 514 protected Map<Link, Integer> getFlowCounts(DeviceId deviceId) {
490 List<FlowEntry> entries = new ArrayList<>(); 515 List<FlowEntry> entries = new ArrayList<>();
......