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;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
import org.onosproject.net.Annotations;
import org.onosproject.net.DeviceId;
/**
* Service for interacting with the inventory of tunnels.
......@@ -186,6 +187,14 @@ public interface TunnelService {
int tunnelCount();
/**
* Returns the collection of tunnels applied on the specified device.
*
* @param deviceId device identifier
* @return collection of tunnels
*/
Iterable<Tunnel> getTunnels(DeviceId deviceId);
/**
* Adds the specified tunnel listener.
*
* @param listener tunnel listener
......
......@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import org.apache.felix.scr.annotations.Activate;
......@@ -48,6 +49,7 @@ import org.onosproject.incubator.net.tunnel.TunnelStore;
import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate;
import org.onosproject.incubator.net.tunnel.TunnelSubscription;
import org.onosproject.net.Annotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Path;
import org.onosproject.net.provider.AbstractProviderRegistry;
import org.onosproject.net.provider.AbstractProviderService;
......@@ -373,4 +375,9 @@ public class TunnelManager
}
}
@Override
public Iterable<Tunnel> getTunnels(DeviceId deviceId) {
return Collections.emptyList();
}
}
......
......@@ -53,6 +53,10 @@
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
</dependency>
......
......@@ -27,6 +27,9 @@ import org.onosproject.cluster.ControllerNode;
import org.onosproject.cluster.NodeId;
import org.onosproject.core.CoreService;
import org.onosproject.incubator.net.PortStatisticsService;
import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelService;
import org.onosproject.mastership.MastershipService;
import org.onosproject.net.Annotated;
import org.onosproject.net.AnnotationKeys;
......@@ -143,6 +146,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
protected StatisticService flowStatsService;
protected PortStatisticsService portStatsService;
protected TopologyService topologyService;
protected TunnelService tunnelService;
protected enum StatsType {
FLOW, PORT
......@@ -176,6 +180,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
flowStatsService = directory.get(StatisticService.class);
portStatsService = directory.get(PortStatisticsService.class);
topologyService = directory.get(TopologyService.class);
tunnelService = directory.get(TunnelService.class);
String ver = directory.get(CoreService.class).version().toString();
version = ver.replace(".SNAPSHOT", "*").replaceFirst("~.*$", "");
......@@ -446,6 +451,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
new Prop("Topology SCCs", format(topology.clusterCount())),
new Separator(),
new Prop("Intents", format(intentService.getIntentCount())),
new Prop("Tunnels", format(tunnelService.tunnelCount())),
new Prop("Flows", format(flowService.getFlowRuleCount())),
new Prop("Version", version)));
}
......@@ -457,6 +463,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
String name = annot.value(AnnotationKeys.NAME);
int portCount = deviceService.getPorts(deviceId).size();
int flowCount = getFlowCount(deviceId);
int tunnelCount = getTunnelCount(deviceId);
return JsonUtils.envelope("showDetails", sid,
json(isNullOrEmpty(name) ? deviceId.toString() : name,
device.type().toString().toLowerCase(),
......@@ -472,7 +479,9 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
new Prop("Longitude", annot.value(AnnotationKeys.LONGITUDE)),
new Separator(),
new Prop("Ports", Integer.toString(portCount)),
new Prop("Flows", Integer.toString(flowCount))));
new Prop("Flows", Integer.toString(flowCount)),
new Prop("Tunnels", Integer.toString(tunnelCount))
));
}
protected int getFlowCount(DeviceId deviceId) {
......@@ -485,6 +494,22 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
return count;
}
protected int getTunnelCount(DeviceId deviceId) {
int count = 0;
Collection<Tunnel> tunnels = tunnelService.queryAllTunnels();
for (Tunnel tunnel : tunnels) {
OpticalTunnelEndPoint src = (OpticalTunnelEndPoint) tunnel.src();
OpticalTunnelEndPoint dst = (OpticalTunnelEndPoint) tunnel.dst();
DeviceId srcDevice = (DeviceId) src.elementId().get();
DeviceId dstDevice = (DeviceId) dst.elementId().get();
if (srcDevice.toString().equals(deviceId.toString())
|| dstDevice.toString().equals(deviceId.toString())) {
count++;
}
}
return count;
}
// Counts all entries that egress on the given device links.
protected Map<Link, Integer> getFlowCounts(DeviceId deviceId) {
List<FlowEntry> entries = new ArrayList<>();
......