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 | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame^] | 4 | import java.util.Map; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 5 | |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 6 | import net.floodlightcontroller.core.module.IFloodlightService; |
| 7 | |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame^] | 8 | public interface IControllerRegistryService extends IFloodlightService { |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 9 | |
Jonathan Hart | bd181b6 | 2013-02-17 16:05:38 -0800 | [diff] [blame] | 10 | // Callback for all mastership changes. |
| 11 | // Change callback is called when mastership is acquired or released |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame^] | 12 | public interface ControlChangeCallback { |
| 13 | public void controlChanged(long dpid, boolean hasControl); |
Jonathan Hart | bd181b6 | 2013-02-17 16:05:38 -0800 | [diff] [blame] | 14 | } |
| 15 | |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 16 | // Acquire mastership for a switch. |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame^] | 17 | public void requestControl(long dpid, ControlChangeCallback cb) throws Exception; |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 18 | |
| 19 | // Release mastership for a switch |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame^] | 20 | public void releaseControl(long dpid); |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 21 | |
| 22 | // Check if I am the master of a switch. This is a nonblocking call that checks if the caller is a |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame^] | 23 | public boolean hasControl(long dpid); |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 24 | |
| 25 | // Set/Get mastership identifier. |
| 26 | // This is typically a unique identifier of the controller that does not change across restarts |
| 27 | public void setMastershipId (String id); |
| 28 | public String getMastershipId (); |
| 29 | |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 30 | /** |
| 31 | * Register a controller to the ONOS cluster |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame^] | 32 | * @param controller A string identifying the controller |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 33 | */ |
Jonathan Hart | 57080fb | 2013-02-21 10:55:46 -0800 | [diff] [blame] | 34 | public void registerController(String controllerId) throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Get all controllers in the cluster |
| 38 | * @return |
| 39 | */ |
Jonathan Hart | 57080fb | 2013-02-21 10:55:46 -0800 | [diff] [blame] | 40 | public Collection<String> getAllControllers() throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 41 | |
| 42 | |
Jonathan Hart | 57080fb | 2013-02-21 10:55:46 -0800 | [diff] [blame] | 43 | public String getControllerForSwitch(long dpid) throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 44 | |
Jonathan Hart | d82f20d | 2013-02-21 18:04:24 -0800 | [diff] [blame^] | 45 | public Collection<Map<String, String>> getAllSwitches(); |
| 46 | |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 47 | public Collection<Long> getSwitchesControlledByController(String controllerId); |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 48 | } |