Commit 8cb763e5 authored by Michele Santuari's avatar Michele Santuari
Browse files

Get Topology and listener setup

parent 38a7af64
......@@ -18,7 +18,13 @@ package org.geant;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyEvent;
import org.onosproject.net.topology.TopologyListener;
import org.onosproject.net.topology.TopologyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -30,9 +36,16 @@ public class AppComponent {
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected TopologyService topologyService;
private TopologyProccess processor = new TopologyProccess();
@Activate
protected void activate() {
log.info("Started");
topologyService.addListener(processor);
}
@Deactivate
......@@ -40,4 +53,18 @@ public class AppComponent {
log.info("Stopped");
}
private class TopologyProccess implements TopologyListener {
private void printTopology() {
Topology topo = topologyService.currentTopology();
log.info("Number of devices {}", topo.deviceCount());
log.info("Number of links {}", topo.linkCount());
}
@Override
public void event(TopologyEvent event) {
printTopology();
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment