Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame^] | 1 | package net.onrc.onos.util; |
| 2 | |
| 3 | import net.floodlightcontroller.core.INetMapTopologyObjects.IFlowEntry; |
| 4 | import net.floodlightcontroller.core.INetMapTopologyObjects.IFlowPath; |
| 5 | import net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject; |
| 6 | import net.floodlightcontroller.linkdiscovery.internal.TopoLinkServiceImpl; |
| 7 | import net.floodlightcontroller.util.FlowPath; |
| 8 | import net.onrc.onos.flow.FlowManagerImpl; |
| 9 | import net.onrc.onos.flow.IFlowManager; |
| 10 | |
| 11 | import org.slf4j.Logger; |
| 12 | import org.slf4j.LoggerFactory; |
| 13 | |
| 14 | import com.thinkaurelius.titan.core.TitanEdge; |
| 15 | import com.tinkerpop.blueprints.Direction; |
| 16 | import com.tinkerpop.blueprints.Edge; |
| 17 | import com.tinkerpop.blueprints.Vertex; |
| 18 | import com.tinkerpop.blueprints.util.wrappers.event.listener.GraphChangedListener; |
| 19 | |
| 20 | public class LocalTopologyEventListener implements GraphChangedListener { |
| 21 | |
| 22 | protected static Logger log = LoggerFactory.getLogger(LocalTopologyEventListener.class); |
| 23 | protected static GraphDBConnection conn = GraphDBConnection.getInstance(""); |
| 24 | |
| 25 | @Override |
| 26 | public void edgeAdded(Edge arg0) { |
| 27 | // TODO Auto-generated method stub |
| 28 | // Convert this Event into NetMapEvent (LinkAdded, FlowEntryEnabled, HostAttached, PortEnabled) |
| 29 | } |
| 30 | |
| 31 | @Override |
| 32 | public void edgePropertyChanged(Edge arg0, String arg1, Object arg2) { |
| 33 | // TODO Auto-generated method stub |
| 34 | // Generate State change events on edges too |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public void edgePropertyRemoved(Edge arg0, String arg1, Object arg2) { |
| 39 | // TODO Auto-generated method stub |
| 40 | // Currently not needed |
| 41 | |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public void edgeRemoved(Edge e) { |
| 46 | // TODO Auto-generated method stub |
| 47 | // Fire NetMapEvents (LinkRemoved, FlowEntryRemoved, HostRemoved, PortRemoved) |
| 48 | TitanEdge edge = (TitanEdge) e; |
| 49 | log.debug("TopologyEvents: Received edge removed event: {}",edge.toString()); |
| 50 | String label = edge.getLabel(); |
| 51 | if (label.equals("link")) { |
| 52 | Vertex v = edge.getVertex(Direction.IN); |
| 53 | IPortObject src_port = conn.getFramedGraph().frame(v, IPortObject.class); |
| 54 | v = edge.getVertex(Direction.OUT); |
| 55 | IPortObject dest_port = conn.getFramedGraph().frame(v, IPortObject.class); |
| 56 | |
| 57 | log.debug("TopologyEvents: link broken {}", new Object []{src_port.getSwitch().getDPID(), |
| 58 | src_port.getNumber(), |
| 59 | dest_port.getSwitch().getDPID(), |
| 60 | dest_port.getNumber()}); |
| 61 | IFlowManager manager = new FlowManagerImpl(); |
| 62 | // TODO: Find the flows and add to reconcile queue |
| 63 | manager.reconcileFlows(src_port); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void vertexAdded(Vertex arg0) { |
| 69 | // TODO Auto-generated method stub |
| 70 | |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public void vertexPropertyChanged(Vertex arg0, String arg1, Object arg2) { |
| 75 | // TODO Auto-generated method stub |
| 76 | |
| 77 | |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public void vertexPropertyRemoved(Vertex arg0, String arg1, Object arg2) { |
| 82 | // TODO Auto-generated method stub |
| 83 | |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public void vertexRemoved(Vertex arg0) { |
| 88 | // TODO Auto-generated method stub |
| 89 | |
| 90 | } |
| 91 | |
| 92 | } |