Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.mastership; |
| 2 | |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 3 | import java.util.Collection; |
| 4 | |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 5 | import net.floodlightcontroller.core.module.IFloodlightService; |
| 6 | |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 7 | //Will change to something like IRegistryService |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 8 | public interface IMastershipService extends IFloodlightService { |
| 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 |
| 12 | public interface MastershipCallback { |
| 13 | public void changeCallback(long dpid, boolean isMaster); |
| 14 | } |
| 15 | |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 16 | // Acquire mastership for a switch. |
Jonathan Hart | c6eee9e | 2013-02-18 14:58:27 -0800 | [diff] [blame] | 17 | public void acquireMastership(long dpid, MastershipCallback cb) throws Exception; |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 18 | |
| 19 | // Release mastership for a switch |
| 20 | public void releaseMastership(long dpid); |
| 21 | |
| 22 | // Check if I am the master of a switch. This is a nonblocking call that checks if the caller is a |
| 23 | public boolean amMaster(long dpid); |
| 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 |
| 32 | * @param controller A string identifying the controller and (possibly) how to talk to it. |
| 33 | * (We will have to develop a convention for this - most likely hostname:port) |
| 34 | */ |
Jonathan Hart | 1be4626 | 2013-02-20 16:43:51 -0800 | [diff] [blame^] | 35 | public void registerController(String controllerId) throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Get all controllers in the cluster |
| 39 | * @return |
| 40 | */ |
Jonathan Hart | 1be4626 | 2013-02-20 16:43:51 -0800 | [diff] [blame^] | 41 | public Collection<String> getAllControllers() throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 42 | |
| 43 | |
Jonathan Hart | 1be4626 | 2013-02-20 16:43:51 -0800 | [diff] [blame^] | 44 | public String getControllerForSwitch(long dpid) throws RegistryException; |
Jonathan Hart | edd6a44 | 2013-02-20 15:22:06 -0800 | [diff] [blame] | 45 | |
| 46 | public Collection<Long> getSwitchesControlledByController(String controllerId); |
Umesh Krishnaswamy | b56bb29 | 2013-02-12 20:28:27 -0800 | [diff] [blame] | 47 | } |