Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 1 | package net.onrc.onos.registry.controller; |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 2 | |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 3 | import java.util.Collection; |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 4 | import java.util.List; |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 5 | import java.util.Map; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 6 | |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 7 | import net.floodlightcontroller.core.module.IFloodlightService; |
| 8 | |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 9 | public interface IControllerRegistryService extends IFloodlightService { |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 10 | |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 11 | /** |
| 12 | * Callback interface for control change events |
| 13 | * |
| 14 | */ |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 15 | public interface ControlChangeCallback { |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 16 | /** |
| 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 Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 23 | public void controlChanged(long dpid, boolean hasControl); |
Jonathan Hart | bd181b6 | 2013-02-17 16:05:38 -0800 | [diff] [blame] | 24 | } |
| 25 | |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 26 | /** |
| 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 Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 39 | |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 40 | /** |
| 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 Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 47 | public void releaseControl(long dpid); |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 48 | |
| 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 Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame] | 55 | public boolean hasControl(long dpid); |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 56 | |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 57 | |
| 58 | /** |
| 59 | * Superseded by registerController |
| 60 | * @param id |
| 61 | */ |
| 62 | @Deprecated |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 63 | public void setMastershipId (String id); |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 64 | |
| 65 | /** |
| 66 | * Get the unique ID used to identify this controller in the cluster |
| 67 | * @return |
| 68 | */ |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 69 | public String getMastershipId (); |
| 70 | |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 71 | /** |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 72 | * 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 Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 78 | */ |
Jonathan Hart | 57080fb | 2013-02-21 10:55:46 -0800 | [diff] [blame] | 79 | public void registerController(String controllerId) throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Get all controllers in the cluster |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 83 | * @return Collection of controller IDs |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 84 | */ |
Jonathan Hart | 57080fb | 2013-02-21 10:55:46 -0800 | [diff] [blame] | 85 | public Collection<String> getAllControllers() throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 86 | |
Jonathan Hart | 97801ac | 2013-02-26 14:29:16 -0800 | [diff] [blame^] | 87 | /** |
| 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 Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 94 | |
Jonathan Hart | 57080fb | 2013-02-21 10:55:46 -0800 | [diff] [blame] | 95 | public String getControllerForSwitch(long dpid) throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 96 | |
| 97 | public Collection<Long> getSwitchesControlledByController(String controllerId); |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 98 | } |