本文整理汇总了Java中net.floodlightcontroller.core.IHAListener.transitionToMaster方法的典型用法代码示例。如果您正苦于以下问题:Java IHAListener.transitionToMaster方法的具体用法?Java IHAListener.transitionToMaster怎么用?Java IHAListener.transitionToMaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.core.IHAListener
的用法示例。
在下文中一共展示了IHAListener.transitionToMaster方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatch
import net.floodlightcontroller.core.IHAListener; //导入方法依赖的package包/类
@Override
public void dispatch() {
if (log.isDebugEnabled()) {
log.debug("Dispatching HA Role update newRole = {}",
newRole);
}
for (IHAListener listener : haListeners.getOrderedListeners()) {
if (log.isTraceEnabled()) {
log.trace("Calling HAListener {} with transitionToMaster",
listener.getName());
}
listener.transitionToMaster();
}
if (newRole != Role.SLAVE) {
Controller.this.notifiedRole = newRole;
}
}
示例2: testSetRole
import net.floodlightcontroller.core.IHAListener; //导入方法依赖的package包/类
/**
* Start as SLAVE then set role to MASTER
* Tests normal role change transition. Check that connected channels
* receive a setRole request
*/
@Test
public void testSetRole() throws Exception {
doSetUp(Role.SLAVE);
RoleInfo info = controller.getRoleInfo();
assertEquals(Role.SLAVE.toString(), info.getRole());
assertEquals(Role.SLAVE, controller.getRole());
OFChannelHandler h = createMock(OFChannelHandler.class);
// Add the channel handler. The controller should call sendRoleRequest
h.sendRoleRequest(Role.SLAVE);
expectLastCall().once();
replay(h);
controller.addSwitchChannelAndSendInitialRole(h);
verify(h);
// Reassert the role.
reset(h);
h.sendRoleRequestIfNotPending(Role.SLAVE);
replay(h);
controller.reassertRole(h, Role.SLAVE);
verify(h);
// reassert a different role: no-op
reset(h);
replay(h);
controller.reassertRole(h, Role.MASTER);
verify(h);
// Change role to MASTER
reset(h);
h.sendRoleRequest(Role.MASTER);
expectLastCall().once();
IHAListener listener = createMock(IHAListener.class);
expect(listener.getName()).andReturn("foo").anyTimes();
setupListenerOrdering(listener);
listener.transitionToMaster();
expectLastCall().once();
replay(listener);
replay(h);
controller.addHAListener(listener);
controller.setRole(Role.MASTER, "FooBar");
controller.processUpdateQueueForTesting();
verify(h);
verify(listener);
info = controller.getRoleInfo();
assertEquals(Role.MASTER.toString(), info.getRole());
assertEquals("FooBar", info.getRoleChangeDescription());
assertEquals(Role.MASTER, controller.getRole());
}
示例3: testSetRoleOthercases
import net.floodlightcontroller.core.IHAListener; //导入方法依赖的package包/类
/** Test other setRole cases: re-setting role to the current role,
* setting role to equal, etc.
*/
@Test
public void testSetRoleOthercases() throws Exception {
doSetUp(Role.SLAVE);
OFChannelHandler h = createMock(OFChannelHandler.class);
// Add the channel handler. The controller should call sendRoleRequest
h.sendRoleRequest(Role.SLAVE);
expectLastCall().once();
replay(h);
controller.addSwitchChannelAndSendInitialRole(h);
verify(h);
// remove the channel. Nothing should
reset(h);
replay(h);
controller.removeSwitchChannel(h);
// Create and add the HA listener
IHAListener listener = createMock(IHAListener.class);
expect(listener.getName()).andReturn("foo").anyTimes();
setupListenerOrdering(listener);
replay(listener);
controller.addHAListener(listener);
// Set role to slave again. Nothing should happen
controller.setRole(Role.SLAVE, "FooBar");
controller.processUpdateQueueForTesting();
verify(listener);
reset(listener);
listener.transitionToMaster();
expectLastCall().once();
replay(listener);
// set role to equal. Should set to master internally
controller.setRole(Role.EQUAL, "ToEqual");
controller.processUpdateQueueForTesting();
verify(listener);
RoleInfo info = controller.getRoleInfo();
assertEquals(Role.MASTER.toString(), info.getRole());
assertEquals("ToEqual", info.getRoleChangeDescription());
assertEquals(Role.MASTER, controller.getRole());
verify(h); // no calls should have happened on h
}
示例4: transitionToMaster
import net.floodlightcontroller.core.IHAListener; //导入方法依赖的package包/类
/**
* Dispatches a new role change notification
* @param oldRole
* @param newRole
*/
public void transitionToMaster() {
for (IHAListener rl : haListeners.getOrderedListeners()) {
rl.transitionToMaster();
}
}