blob: afd9dc61a7aaed32c567a6582c643a4d45f43063 [file] [log] [blame]
Jonathan Hartd82f20d2013-02-21 18:04:24 -08001package net.onrc.onos.registry.controller;
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -08002
Jonathan Hartedd6a442013-02-20 15:22:06 -08003import java.util.Collection;
Jonathan Hart3d7730a2013-02-22 11:51:17 -08004import java.util.List;
Jonathan Hartd82f20d2013-02-21 18:04:24 -08005import java.util.Map;
Jonathan Hartedd6a442013-02-20 15:22:06 -08006
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -08007import net.floodlightcontroller.core.module.IFloodlightService;
8
Jonathan Hartd82f20d2013-02-21 18:04:24 -08009public interface IControllerRegistryService extends IFloodlightService {
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -080010
Jonathan Hart97801ac2013-02-26 14:29:16 -080011 /**
12 * Callback interface for control change events
13 *
14 */
Jonathan Hartd82f20d2013-02-21 18:04:24 -080015 public interface ControlChangeCallback {
Jonathan Hart97801ac2013-02-26 14:29:16 -080016 /**
17 * Called whenever the control changes from the point of view of the
18 * registry. The callee can check whether they have control or not
19 * using the hasControl parameter.
20 * @param dpid The switch that control has changed for
21 * @param hasControl Whether the listener now has control or not
22 */
Jonathan Hartd82f20d2013-02-21 18:04:24 -080023 public void controlChanged(long dpid, boolean hasControl);
Jonathan Hartbd181b62013-02-17 16:05:38 -080024 }
25
Jonathan Hart97801ac2013-02-26 14:29:16 -080026 /**
27 * Request for control of a switch. This method does not block. When
28 * control for a switch changes, the controlChanged method on the
29 * callback object will be called. This happens any time the control
30 * changes while the request is still active (until releaseControl is
31 * called)
32 * @param dpid Switch to request control for
33 * @param cb Callback that will be used to notify caller of control
34 * changes
35 * @throws RegistryException Errors contacting the registry service
36 */
37 public void requestControl(long dpid, ControlChangeCallback cb)
38 throws RegistryException;
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -080039
Jonathan Hart97801ac2013-02-26 14:29:16 -080040 /**
41 * Stop trying to take control of a switch. This removes the entry
42 * for this controller requesting this switch in the registry.
43 * If the controller had control when this is called, another controller
44 * will now gain control of the switch. This call doesn't block.
45 * @param dpid Switch to release control of
46 */
Jonathan Hartd82f20d2013-02-21 18:04:24 -080047 public void releaseControl(long dpid);
Jonathan Hart97801ac2013-02-26 14:29:16 -080048
49 /**
50 * Check whether the controller has control of the switch
51 * This call doesn't block.
52 * @param dpid Switch to check control of
53 * @return
54 */
Jonathan Hartd82f20d2013-02-21 18:04:24 -080055 public boolean hasControl(long dpid);
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -080056
Jonathan Hart97801ac2013-02-26 14:29:16 -080057
58 /**
59 * Superseded by registerController
60 * @param id
61 */
62 @Deprecated
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -080063 public void setMastershipId (String id);
Jonathan Hart97801ac2013-02-26 14:29:16 -080064
65 /**
66 * Get the unique ID used to identify this controller in the cluster
67 * @return
68 */
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -080069 public String getMastershipId ();
70
Jonathan Hartedd6a442013-02-20 15:22:06 -080071 /**
Jonathan Hart97801ac2013-02-26 14:29:16 -080072 * Register a controller to the ONOS cluster. Must be called before
73 * the registry can be used to take control of any switches.
74 * @param controller A unique string ID identifying this controller
75 * in the cluster
76 * @throws errors connecting to registry service,
77 * controllerId already registered
Jonathan Hartedd6a442013-02-20 15:22:06 -080078 */
Jonathan Hart57080fb2013-02-21 10:55:46 -080079 public void registerController(String controllerId) throws RegistryException;
Jonathan Hartedd6a442013-02-20 15:22:06 -080080
81 /**
82 * Get all controllers in the cluster
Jonathan Hart97801ac2013-02-26 14:29:16 -080083 * @return Collection of controller IDs
Jonathan Hartedd6a442013-02-20 15:22:06 -080084 */
Jonathan Hart57080fb2013-02-21 10:55:46 -080085 public Collection<String> getAllControllers() throws RegistryException;
Jonathan Hartedd6a442013-02-20 15:22:06 -080086
Jonathan Hart97801ac2013-02-26 14:29:16 -080087 /**
88 * Get all switches in the cluster, along with which controller is
89 * in control of them (if any) and any other controllers that have
90 * requested control.
91 * @return
92 */
93 public Map<String, List<ControllerRegistryEntry>> getAllSwitches();
Jonathan Hartedd6a442013-02-20 15:22:06 -080094
Jonathan Hart57080fb2013-02-21 10:55:46 -080095 public String getControllerForSwitch(long dpid) throws RegistryException;
Jonathan Hartedd6a442013-02-20 15:22:06 -080096
97 public Collection<Long> getSwitchesControlledByController(String controllerId);
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -080098}