blob: 3bef1e2e518322c06f51d03f2d2cd8b60b1031a3 [file] [log] [blame]
Jonathan Hart472062d2014-04-03 10:56:48 -07001package net.onrc.onos.core.topology;
Jonathan Hart062a2e82014-02-03 09:41:57 -08002
Jonathan Hart062a2e82014-02-03 09:41:57 -08003import net.floodlightcontroller.util.MACAddress;
Yuta HIGUCHIa7f1cdd2014-06-09 15:05:20 -07004import net.onrc.onos.core.topology.web.serializers.TopologySerializer;
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -07005import net.onrc.onos.core.util.Dpid;
6import net.onrc.onos.core.util.PortNumber;
7import net.onrc.onos.core.util.SwitchPort;
Yuta HIGUCHIa7f1cdd2014-06-09 15:05:20 -07008
Ray Milkey0fe43852014-06-05 14:41:46 -07009import org.codehaus.jackson.map.annotate.JsonSerialize;
Jonathan Hart062a2e82014-02-03 09:41:57 -080010
11/**
Jonathan Harte37e4e22014-05-13 19:12:02 -070012 * The northbound interface to the topology. This interface
Jonathan Hart062a2e82014-02-03 09:41:57 -080013 * is presented to the rest of ONOS. It is currently read-only, as we want
14 * only the discovery modules to be allowed to modify the topology.
Jonathan Hart062a2e82014-02-03 09:41:57 -080015 */
Ray Milkey0fe43852014-06-05 14:41:46 -070016@JsonSerialize(using = TopologySerializer.class)
Jonathan Harte37e4e22014-05-13 19:12:02 -070017public interface Topology {
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070018
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080019 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070020 * Gets the switch for a given switch DPID.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080021 *
22 * @param dpid the switch dpid.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080023 * @return the switch if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080024 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070025 public Switch getSwitch(Dpid dpid);
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080026
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080027 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070028 * Gets all switches in the network.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080029 *
30 * @return all switches in the network.
31 */
32 public Iterable<Switch> getSwitches();
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080033
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080034 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070035 * Gets the port on a switch.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080036 *
Ray Milkey269ffb92014-04-03 14:43:30 -070037 * @param dpid the switch DPID.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080038 * @param number the switch port number.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080039 * @return the switch port if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080040 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070041 public Port getPort(Dpid dpid, PortNumber number);
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080042
43 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070044 * Gets the port on a switch.
45 *
46 * @param port port identifier
47 * @return the switch port if found, otherwise null.
48 */
49 public Port getPort(SwitchPort port);
50
51 /**
52 * Gets the outgoing link from a switch port.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080053 *
Ray Milkey269ffb92014-04-03 14:43:30 -070054 * @param dpid the switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080055 * @param number the switch port number.
56 * @return the outgoing link if found, otherwise null.
57 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070058 public Link getOutgoingLink(Dpid dpid, PortNumber number);
Jonathan Hart25bd53e2014-04-30 23:44:09 -070059
60 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070061 * Gets the outgoing link from a switch port.
62 *
63 * @param port port identifier
64 * @return the switch port if found, otherwise null.
65 */
66 public Link getOutgoingLink(SwitchPort port);
67
68 /**
69 * Gets the incoming link to a switch port.
Jonathan Hart25bd53e2014-04-30 23:44:09 -070070 *
71 * @param dpid the switch DPID.
72 * @param number the switch port number.
73 * @return the incoming link if found, otherwise null.
74 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070075 public Link getIncomingLink(Dpid dpid, PortNumber number);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080076
77 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070078 * Gets the incoming link to a switch port.
79 *
80 * @param port port identifier
81 * @return the switch port if found, otherwise null.
82 */
83 public Link getIncomingLink(SwitchPort port);
84
85 /**
86 * Gets the outgoing link from a switch and a port to another switch and
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080087 * a port.
88 *
Ray Milkey269ffb92014-04-03 14:43:30 -070089 * @param srcDpid the source switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080090 * @param srcNumber the source switch port number.
Ray Milkey269ffb92014-04-03 14:43:30 -070091 * @param dstDpid the destination switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080092 * @param dstNumber the destination switch port number.
93 * @return the outgoing link if found, otherwise null.
94 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070095 public Link getLink(Dpid srcDpid, PortNumber srcNumber,
96 Dpid dstDpid, PortNumber dstNumber);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080097
98 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070099 * Gets all links in the network.
Ray Milkey269ffb92014-04-03 14:43:30 -0700100 * <p/>
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -0800101 * TODO: Not clear if this method is needed. Remove if not used.
102 *
103 * @return all links in the network.
104 */
105 public Iterable<Link> getLinks();
106
107 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700108 * Gets the network device for a given MAC address.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -0800109 *
110 * @param address the MAC address to use.
111 * @return the network device for the MAC address if found, otherwise null.
112 */
113 public Device getDeviceByMac(MACAddress address);
Ray Milkey269ffb92014-04-03 14:43:30 -0700114
Jonathan Hart26f291b2014-02-18 16:57:24 -0800115 /**
Ray Milkey269ffb92014-04-03 14:43:30 -0700116 * Acquire a read lock on the entire topology. The topology will not
117 * change while readers have the lock. Must be released using
Sho SHIMIZUbfe4a452014-06-09 15:18:11 -0700118 * {@link #releaseReadLock()}. This method will block until a read lock is
Jonathan Hart26f291b2014-02-18 16:57:24 -0800119 * available.
120 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -0800121 public void acquireReadLock();
Ray Milkey269ffb92014-04-03 14:43:30 -0700122
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800123 /**
124 * Release the read lock on the topology.
125 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -0800126 public void releaseReadLock();
TeruU65bc5ff2014-04-23 22:22:32 -0700127
128 public Iterable<Device> getDevices();
Jonathan Hart062a2e82014-02-03 09:41:57 -0800129}