blob: fdcb5c05e19613515804c7d8d8c53bbdf83e95d6 [file] [log] [blame]
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -08001package net.floodlightcontroller.mastership;
2
Jonathan Hartedd6a442013-02-20 15:22:06 -08003import java.util.Collection;
4
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -08005import net.floodlightcontroller.core.module.IFloodlightService;
6
Jonathan Hartedd6a442013-02-20 15:22:06 -08007//Will change to something like IRegistryService
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -08008public interface IMastershipService extends IFloodlightService {
9
Jonathan Hartbd181b62013-02-17 16:05:38 -080010 // 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 Krishnaswamyb56bb292013-02-12 20:28:27 -080016 // Acquire mastership for a switch.
Jonathan Hartc6eee9e2013-02-18 14:58:27 -080017 public void acquireMastership(long dpid, MastershipCallback cb) throws Exception;
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -080018
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 Hartedd6a442013-02-20 15:22:06 -080030 /**
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 */
35 public void registerController(String controllerId);
36
37 /**
38 * Get all controllers in the cluster
39 * @return
40 */
41 public Collection<String> getAllControllers();
42
43
44 public String getControllerForSwitch(long dpid);
45
46 public Collection<Long> getSwitchesControlledByController(String controllerId);
Umesh Krishnaswamyb56bb292013-02-12 20:28:27 -080047}