本文整理汇总了Java中net.floodlightcontroller.core.HARole类的典型用法代码示例。如果您正苦于以下问题:Java HARole类的具体用法?Java HARole怎么用?Java HARole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HARole类属于net.floodlightcontroller.core包,在下文中一共展示了HARole类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
@Override
public void run() {
try {
if (ldUpdates.peek() != null) {
updateTopology();
}
handleMiscellaneousPeriodicEvents();
}
catch (Exception e) {
log.error("Error in topology instance task thread", e);
} finally {
if (floodlightProviderService.getRole() != HARole.STANDBY) {
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS, TimeUnit.MILLISECONDS);
}
}
}
示例2: startUp
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
@Override
public void startUp(FloodlightModuleContext context) {
clearCurrentTopology();
// Initialize role to floodlight provider role.
this.role = floodlightProviderService.getRole();
ScheduledExecutorService ses = threadPoolService.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new UpdateTopologyWorker());
if (role != HARole.STANDBY) {
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS, TimeUnit.MILLISECONDS);
}
linkDiscoveryService.addListener(this);
floodlightProviderService.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProviderService.addHAListener(this.haListener);
addRestletRoutable();
}
示例3: RoleManager
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/**
* @param role initial role
* @param roleChangeDescription initial value of the change description
* @throws NullPointerException if role or roleChangeDescription is null
*/
public RoleManager(@Nonnull Controller controller,
@Nonnull IShutdownService shutdownService,
@Nonnull HARole role,
@Nonnull String roleChangeDescription) {
Preconditions.checkNotNull(controller, "controller must not be null");
Preconditions.checkNotNull(role, "role must not be null");
Preconditions.checkNotNull(roleChangeDescription, "roleChangeDescription must not be null");
Preconditions.checkNotNull(shutdownService, "shutdownService must not be null");
this.currentRoleInfo = new RoleInfo(role,
roleChangeDescription,
new Date());
this.controller = controller;
this.shutdownService = shutdownService;
this.counters = new RoleManagerCounters(controller.getDebugCounter());
}
示例4: switchAddedToStore
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/**
* Called when we receive a store notification about a new or updated
* switch.
* @param sw
*/
private synchronized void switchAddedToStore(IOFSwitch sw) {
if (floodlightProvider.getRole() != HARole.STANDBY) {
return; // only read from store if slave
}
DatapathId dpid = sw.getId();
IOFSwitch oldSw = syncedSwitches.put(dpid, sw);
if (oldSw == null) {
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.ADDED));
} else {
// The switch already exists in storage, see if anything
// has changed
sendNotificationsIfSwitchDiffers(oldSw, sw);
}
}
示例5: testNewSwitchActivatedWhileSlave
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
示例6: testChannelHandlerMaster
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/**
* Test interaction with OFChannelHandler when the current role is
* master.
*/
@Test
public void testChannelHandlerMaster() {
OFSwitchHandshakeHandler h = createMock(OFSwitchHandshakeHandler.class);
// Reassert the role.
reset(h);
h.sendRoleRequestIfNotPending(OFControllerRole.ROLE_MASTER);
replay(h);
controller.reassertRole(h, HARole.ACTIVE);
verify(h);
// reassert a different role: no-op
reset(h);
replay(h);
controller.reassertRole(h, HARole.STANDBY);
verify(h);
}
示例7: testSetRoleOthercases
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/** Test other setRole cases: re-setting role to the current role,
* setting role to equal, etc.
*/
@Test
public void testSetRoleOthercases() throws Exception {
doSetUp(HARole.STANDBY);
// 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(HARole.STANDBY, "FooBar");
controller.processUpdateQueueForTesting();
verify(listener);
reset(listener);
expect(listener.getName()).andReturn("foo").anyTimes();
listener.transitionToActive();
expectLastCall().once();
replay(listener);
}
示例8: doSetUp
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
private void doSetUp(HARole role) {
controller = createMock(Controller.class);
// Mock controller behavior
reset(controller);
IDebugCounterService counterService = new MockDebugCounterService();
expect(controller.getDebugCounter()).andReturn(counterService).anyTimes();
replay(controller);
IShutdownService shutdownService = createMock(IShutdownService.class);
roleManager = new RoleManager(controller, shutdownService , role, "test");
// Make sure the desired role is set
assertTrue(roleManager.getRole().equals(role));
}
示例9: testReassertMaster
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/**
* Test re-assert MASTER
*
*/
@Test
public void testReassertMaster() throws Exception {
testInitialMoveToMasterWithRole();
OFMessage err = getBadRequestErrorMessage(OFBadRequestCode.EPERM, 42);
reset(roleManager);
roleManager.reassertRole(switchHandler, HARole.ACTIVE);
expectLastCall().once();
replay(roleManager);
reset(switchManager);
switchManager.handleMessage(sw, err, null);
expectLastCall().once();
replay(switchManager);
switchHandler.processOFMessage(err);
verify(sw);
}
示例10: startUp
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
@Override
public void startUp(FloodlightModuleContext context) {
clearCurrentTopology();
// Initialize role to floodlight provider role.
this.role = floodlightProviderService.getRole();
ScheduledExecutorService ses = threadPoolService.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new UpdateTopologyWorker());
if (role != HARole.STANDBY)
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
TimeUnit.MILLISECONDS);
linkDiscoveryService.addListener(this);
floodlightProviderService.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProviderService.addHAListener(this.haListener);
addRestletRoutable();
}
示例11: getInitialRole
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
@LogMessageDocs({
@LogMessageDoc(message="Controller role set to {role}",
explanation="Setting the initial HA role to "),
@LogMessageDoc(level="ERROR",
message="Invalid current role value: {role}",
explanation="An invalid HA role value was read from the " +
"properties file",
recommendation=LogMessageDoc.CHECK_CONTROLLER)
})
protected HARole getInitialRole(Map<String, String> configParams) {
HARole role = HARole.STANDBY;
String roleString = configParams.get("role");
if (roleString != null) {
try {
role = HARole.valueOfBackwardsCompatible(roleString);
}
catch (IllegalArgumentException exc) {
log.error("Invalid current role value: {}", roleString);
}
}
log.info("Controller role set to {}", role);
return role;
}
示例12: init
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/**
* Initialize internal data structures
*/
public void init(Map<String, String> configParams) throws FloodlightModuleException {
this.moduleLoaderState = ModuleLoaderState.INIT;
// These data structures are initialized here because other
// module's startUp() might be called before ours
this.messageListeners = new ConcurrentHashMap<OFType, ListenerDispatcher<OFType, IOFMessageListener>>();
this.haListeners = new ListenerDispatcher<HAListenerTypeMarker, IHAListener>();
this.controllerNodeIPsCache = new HashMap<String, String>();
this.updates = new LinkedBlockingQueue<IUpdate>();
this.providerMap = new HashMap<String, List<IInfoProvider>>();
setConfigParams(configParams);
HARole initialRole = getInitialRole(configParams);
this.notifiedRole = initialRole;
this.shutdownService = new ShutdownServiceImpl();
this.roleManager = new RoleManager(this, this.shutdownService,
this.notifiedRole,
INITIAL_ROLE_CHANGE_DESCRIPTION);
this.timer = new HashedWheelTimer();
// Switch Service Startup
this.switchService.registerLogicalOFMessageCategory(LogicalOFMessageCategory.MAIN);
this.switchService.addOFSwitchListener(new NotificationSwitchListener());
this.counters = new ControllerCounters(debugCounterService);
}
示例13: testNewSwitchActivatedWhileSlave
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
示例14: testReassertMaster
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
/**
* Test re-assert MASTER
*
*/
@Test
public void testReassertMaster() throws Exception {
testInitialMoveToMasterWithRole();
OFMessage err = getBadRequestErrorMessage(OFBadRequestCode.EPERM, 42);
reset(roleManager);
roleManager.reassertRole(switchHandler, HARole.ACTIVE);
expectLastCall().once();
replay(roleManager);
reset(switchManager);
switchManager.handleMessage(sw, err, null);
expectLastCall().once();
replay(switchManager);
switchHandler.processOFMessage(err);
verify(sw);
}
示例15: getRole
import net.floodlightcontroller.core.HARole; //导入依赖的package包/类
@Override
public HARole getRole() {
/* DISABLE THIS CHECK FOR NOW. OTHER UNIT TESTS NEED TO BE UPDATED
* FIRST
if (this.role == null)
throw new IllegalStateException("You need to call setRole on "
+ "MockFloodlightProvider before calling startUp on "
+ "other modules");
*/
return this.role;
}