@Test public void testSetRole() throws Exception { doSetUp(HARole.STANDBY); RoleInfo info = controller.getRoleInfo(); assertEquals(HARole.STANDBY, info.getRole()); assertEquals(HARole.STANDBY, controller.getRole()); OFSwitchHandshakeHandler h = createMock(OFSwitchHandshakeHandler.class); reset(h); h.sendRoleRequestIfNotPending(OFControllerRole.ROLE_SLAVE); replay(h); controller.reassertRole(h, HARole.STANDBY); verify(h); reset(h); replay(h); controller.reassertRole(h, HARole.ACTIVE); verify(h); IHAListener listener = createMock(IHAListener.class); expect(listener.getName()).andReturn("foo").anyTimes(); setupListenerOrdering(listener); listener.transitionToActive(); expectLastCall().once(); replay(listener); controller.addHAListener(listener); controller.setRole(HARole.ACTIVE, "FooBar"); controller.processUpdateQueueForTesting(); verify(listener); info = controller.getRoleInfo(); assertEquals(HARole.ACTIVE, info.getRole()); assertEquals("FooBar", info.getRoleChangeDescription()); assertEquals(HARole.ACTIVE, controller.getRole()); }
@Override public void setRole(HARole role, String changeDescription) { roleManager.setRole(role, changeDescription); }
Controller implements IFloodlightProviderService, IStorageSourceListener, IInfoProvider { @Override public void setRole(HARole role, String changeDescription) { roleManager.setRole(role, changeDescription); } }
Controller implements IFloodlightProviderService, IStorageSourceListener, IInfoProvider { @Override public void setRole(HARole role, String changeDescription) { roleManager.setRole(role, changeDescription); }  }
Controller implements IFloodlightProviderService, IStorageSourceListener, IInfoProvider { @Override public void setRole(HARole role, String changeDescription) { roleManager.setRole(role, changeDescription); }  @Override Set<String> getUplinkPortPrefixSet(); void setUplinkPortPrefixSet(Set<String> prefixSet); @Override ModuleLoaderState getModuleLoaderState(); void setDebugEvent(IDebugEventService debugEvent); void setSwitchService(IOFSwitchService switchService); IOFSwitchService getSwitchService(); @Override int getWorkerThreads(); @Override HARole getRole(); @Override RoleInfo getRoleInfo(); @Override void setRole(HARole role, String changeDescription); @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Ignoring PacketIn (Xid = {xid}) because the data" + " field is empty.", explanation="The switch sent an improperly-formatted PacketIn" + " message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="WARN", message="Unhandled OF Message: {} from {}", explanation="The switch sent a message not handled by " + "the controller") }) @SuppressFBWarnings(value="SF_SWITCH_NO_DEFAULT", justification="False positive -- has default") @Override void handleMessage(IOFSwitch sw, OFMessage m,
                                 FloodlightContext bContext); @Override String getControllerId(); @Override String getOFHostname(); @Override int getOFPort(); @Override synchronized void addOFMessageListener(OFType type, IOFMessageListener listener); @Override synchronized void removeOFMessageListener(OFType type, IOFMessageListener listener); void removeOFMessageListeners(OFType type); @Override Map<OFType, List<IOFMessageListener>> getListeners(); @Override void handleOutgoingMessage(IOFSwitch sw, OFMessage m); @Override @LogMessageDocs({ @LogMessageDoc(message="Listening for switch connections on {address}", explanation="The controller is ready and listening for new" + " switch connections"), @LogMessageDoc(message="Storage exception in controller " + "updates loop; terminating process", explanation=ERROR_DATABASE, recommendation=LogMessageDoc.CHECK_CONTROLLER), @LogMessageDoc(level="ERROR", message="Exception in controller updates loop", explanation="Failed to dispatch controller event", recommendation=LogMessageDoc.GENERIC_ACTION) }) void run(); void init(Map<String, String> configParams); @LogMessageDoc(message="Waiting for storage source", explanation="The system database is not yet ready", recommendation="If this message persists, this indicates " + "that the system database has failed to start. " + LogMessageDoc.CHECK_CONTROLLER) void startupComponents(FloodlightModuleLoader floodlightModuleLoader); @Override void addInfoProvider(String type, IInfoProvider provider); @Override void removeInfoProvider(String type, IInfoProvider provider); @Override Map<String, Object> getControllerInfo(String type); @Override void addHAListener(IHAListener listener); @Override void removeHAListener(IHAListener listener); @Override Map<String, String> getControllerNodeIPs(); @LogMessageDoc(level="WARN", message=FLOW_PRIORITY_CHANGED_AFTER_STARTUP, explanation="A user has changed the priority with which access " + "and core flows are installed after controller startup. " + "Changing this setting will only take affect after a " + "controller restart", recommendation="Restart controller") @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); @Override long getSystemStartTime(); @Override Map<String, Long> getMemory(); @Override Long getUptime(); @LogMessageDoc(level="WARN", message="Failure adding update {} to queue", explanation="The controller tried to add an internal notification" + " to its message queue but the add failed.", recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG) @Override void addUpdateToQueue(IUpdate update); @Override Map<String, Object> getInfo(String type); @Override RoleManager getRoleManager(); Optional<ControllerId> getId(); @Override Timer getTimer(); ControllerCounters getCounters(); }
Controller implements IFloodlightProviderService, IStorageSourceListener, IInfoProvider { @Override public void setRole(HARole role, String changeDescription) { roleManager.setRole(role, changeDescription); }  @Override Set<String> getUplinkPortPrefixSet(); void setUplinkPortPrefixSet(Set<String> prefixSet); @Override ModuleLoaderState getModuleLoaderState(); void setDebugEvent(IDebugEventService debugEvent); void setSwitchService(IOFSwitchService switchService); IOFSwitchService getSwitchService(); @Override int getWorkerThreads(); @Override HARole getRole(); @Override RoleInfo getRoleInfo(); @Override void setRole(HARole role, String changeDescription); @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Ignoring PacketIn (Xid = {xid}) because the data" + " field is empty.", explanation="The switch sent an improperly-formatted PacketIn" + " message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="WARN", message="Unhandled OF Message: {} from {}", explanation="The switch sent a message not handled by " + "the controller") }) @SuppressFBWarnings(value="SF_SWITCH_NO_DEFAULT", justification="False positive -- has default") @Override void handleMessage(IOFSwitch sw, OFMessage m,
                                 FloodlightContext bContext); @Override String getControllerId(); @Override String getOFHostname(); @Override int getOFPort(); @Override synchronized void addOFMessageListener(OFType type, IOFMessageListener listener); @Override synchronized void removeOFMessageListener(OFType type, IOFMessageListener listener); void removeOFMessageListeners(OFType type); @Override Map<OFType, List<IOFMessageListener>> getListeners(); @Override void handleOutgoingMessage(IOFSwitch sw, OFMessage m); @Override @LogMessageDocs({ @LogMessageDoc(message="Listening for switch connections on {address}", explanation="The controller is ready and listening for new" + " switch connections"), @LogMessageDoc(message="Storage exception in controller " + "updates loop; terminating process", explanation=ERROR_DATABASE, recommendation=LogMessageDoc.CHECK_CONTROLLER), @LogMessageDoc(level="ERROR", message="Exception in controller updates loop", explanation="Failed to dispatch controller event", recommendation=LogMessageDoc.GENERIC_ACTION) }) void run(); void init(Map<String, String> configParams); @LogMessageDoc(message="Waiting for storage source", explanation="The system database is not yet ready", recommendation="If this message persists, this indicates " + "that the system database has failed to start. " + LogMessageDoc.CHECK_CONTROLLER) void startupComponents(FloodlightModuleLoader floodlightModuleLoader); @Override void addInfoProvider(String type, IInfoProvider provider); @Override void removeInfoProvider(String type, IInfoProvider provider); @Override Map<String, Object> getControllerInfo(String type); @Override void addHAListener(IHAListener listener); @Override void removeHAListener(IHAListener listener); @Override Map<String, String> getControllerNodeIPs(); @LogMessageDoc(level="WARN", message=FLOW_PRIORITY_CHANGED_AFTER_STARTUP, explanation="A user has changed the priority with which access " + "and core flows are installed after controller startup. " + "Changing this setting will only take affect after a " + "controller restart", recommendation="Restart controller") @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); @Override long getSystemStartTime(); @Override Map<String, Long> getMemory(); @Override Long getUptime(); @LogMessageDoc(level="WARN", message="Failure adding update {} to queue", explanation="The controller tried to add an internal notification" + " to its message queue but the add failed.", recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG) @Override void addUpdateToQueue(IUpdate update); @Override Map<String, Object> getInfo(String type); @Override RoleManager getRoleManager(); Optional<ControllerId> getId(); @Override Timer getTimer(); ControllerCounters getCounters(); static final int BATCH_MAX_SIZE; }