Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 1 | package net.onrc.onos.graph; |
| 2 | |
mininet | 73e7fb7 | 2013-12-03 14:25:53 -0800 | [diff] [blame] | 3 | import java.util.Map; |
| 4 | |
Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 5 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject; |
| 6 | |
| 7 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; |
| 9 | |
| 10 | import com.thinkaurelius.titan.core.TitanEdge; |
| 11 | import com.tinkerpop.blueprints.Direction; |
| 12 | import com.tinkerpop.blueprints.Edge; |
| 13 | import com.tinkerpop.blueprints.Vertex; |
| 14 | |
| 15 | public class LocalTopologyEventListener implements LocalGraphChangedListener { |
| 16 | |
Yuta HIGUCHI | 6ac8d18 | 2013-10-22 15:24:56 -0700 | [diff] [blame] | 17 | protected final static Logger log = LoggerFactory.getLogger(LocalTopologyEventListener.class); |
Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 18 | protected static GraphDBConnection conn; |
| 19 | |
| 20 | public LocalTopologyEventListener(GraphDBConnection conn) { |
| 21 | LocalTopologyEventListener.conn = conn; |
| 22 | } |
| 23 | |
| 24 | @Override |
| 25 | public void edgeAdded(Edge arg0) { |
| 26 | // TODO Auto-generated method stub |
| 27 | // Convert this Event into NetMapEvent (LinkAdded, FlowEntryEnabled, HostAttached, PortEnabled) |
| 28 | } |
| 29 | |
| 30 | |
| 31 | @Override |
| 32 | public void edgePropertyRemoved(Edge arg0, String arg1, Object arg2) { |
| 33 | // TODO Auto-generated method stub |
| 34 | // Currently not needed |
| 35 | |
| 36 | } |
| 37 | |
| 38 | @Override |
Pankaj Berde | 0ecc392 | 2013-12-09 17:16:42 -0800 | [diff] [blame] | 39 | public void edgeRemoved(Edge e) { |
Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 40 | // TODO Auto-generated method stub |
| 41 | // Fire NetMapEvents (LinkRemoved, FlowEntryRemoved, HostRemoved, PortRemoved) |
| 42 | TitanEdge edge = (TitanEdge) e; |
| 43 | log.debug("TopologyEvents: Received edge removed event: {}",edge.toString()); |
| 44 | String label = edge.getLabel(); |
| 45 | if (label.equals("link")) { |
| 46 | Vertex v = edge.getVertex(Direction.IN); |
| 47 | IPortObject src_port = conn.getFramedGraph().frame(v, IPortObject.class); |
| 48 | v = edge.getVertex(Direction.OUT); |
| 49 | IPortObject dest_port = conn.getFramedGraph().frame(v, IPortObject.class); |
| 50 | |
| 51 | log.debug("TopologyEvents: link broken {}", new Object []{src_port.getSwitch().getDPID(), |
| 52 | src_port.getNumber(), |
| 53 | dest_port.getSwitch().getDPID(), |
| 54 | dest_port.getNumber()}); |
Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 55 | // TODO: Find the flows and add to reconcile queue |
Pavlin Radoslavov | fcf4222 | 2013-12-02 16:57:24 -0800 | [diff] [blame] | 56 | // |
| 57 | // NOTE: Old code/logic. |
| 58 | // |
| 59 | // IFlowService flowManager = ... |
| 60 | // flowManager.reconcileFlows(src_port); |
Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 61 | } |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public void vertexAdded(Vertex arg0) { |
| 66 | // TODO Auto-generated method stub |
| 67 | |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public void vertexPropertyRemoved(Vertex arg0, String arg1, Object arg2) { |
| 72 | // TODO Auto-generated method stub |
| 73 | |
| 74 | } |
| 75 | |
| 76 | @Override |
Pankaj Berde | 0ecc392 | 2013-12-09 17:16:42 -0800 | [diff] [blame] | 77 | public void vertexRemoved(Vertex vertex) { |
Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 78 | // TODO Auto-generated method stub |
| 79 | // Generate NetMapEvents |
| 80 | String type = (String) vertex.getProperty("type"); |
| 81 | log.debug("TopologyEvents: Received vertex removed event: {}",vertex.toString()); |
| 82 | if (type.equals("port")) { |
| 83 | // port is removed...lets fire reconcile here directly for now |
| 84 | |
| 85 | IPortObject src_port = conn.getFramedGraph().frame(vertex, IPortObject.class); |
| 86 | log.debug("TopologyEvents: Port removed: {}:{}",src_port.getSwitch().getDPID(),src_port.getNumber()); |
Pavlin Radoslavov | fcf4222 | 2013-12-02 16:57:24 -0800 | [diff] [blame] | 87 | |
| 88 | // NOTE: Old code/logic. |
| 89 | // |
| 90 | // IFlowService flowManager = ... |
| 91 | // flowManager.reconcileFlows(src_port); |
Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 92 | } |
| 93 | } |
| 94 | |
| 95 | |
| 96 | @Override |
| 97 | public void edgePropertyChanged(Edge arg0, String arg1, Object arg2, |
| 98 | Object arg3) { |
| 99 | // TODO Auto-generated method stub |
| 100 | |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public void vertexPropertyChanged(Vertex arg0, String arg1, Object arg2, |
| 105 | Object arg3) { |
| 106 | // TODO Auto-generated method stub |
| 107 | |
| 108 | } |
| 109 | |
Pankaj Berde | 85016ab | 2013-06-21 11:34:53 -0700 | [diff] [blame] | 110 | } |