当前位置: 首页>>代码示例>>Java>>正文


Java HARole类代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:17,代码来源:TopologyManager.java

示例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();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:TopologyManager.java

示例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());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:RoleManager.java

示例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);
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:21,代码来源:OFSwitchManager.java

示例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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:OFSwitchManagerTest.java

示例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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:ControllerTest.java

示例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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:ControllerTest.java

示例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));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:17,代码来源:RoleManagerTest.java

示例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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:25,代码来源:OFSwitchHandlerTestBase.java

示例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();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:TopologyManager.java

示例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;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:Controller.java

示例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);
 }
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:33,代码来源:Controller.java

示例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);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:OFSwitchManagerTest.java

示例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);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:OFSwitchHandlerTestBase.java

示例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;
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:12,代码来源:MockFloodlightProvider.java


注:本文中的net.floodlightcontroller.core.HARole类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。