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


Java RoleInfo类代码示例

本文整理汇总了Java中net.floodlightcontroller.core.RoleInfo的典型用法代码示例。如果您正苦于以下问题:Java RoleInfo类的具体用法?Java RoleInfo怎么用?Java RoleInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RoleInfo类属于net.floodlightcontroller.core包,在下文中一共展示了RoleInfo类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RoleManager

import net.floodlightcontroller.core.RoleInfo; //导入依赖的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

示例2: RoleManager

import net.floodlightcontroller.core.RoleInfo; //导入依赖的package包/类
/**
 * @param role initial role
 * @param roleChangeDescription initial value of the change description
 * @throws NullPointerException if role or roleChangeDescription is null
 * @throws IllegalArgumentException if role is EQUAL
 */
public RoleManager(Role role, String roleChangeDescription) {
    if (role == null)
        throw new NullPointerException("role must not be null");
    if (role == Role.EQUAL)
        throw new IllegalArgumentException("role must not be EQUAL");
    if (roleChangeDescription == null) {
        throw new NullPointerException("roleChangeDescription must " +
                                       "not be null");
    }

    this.role = role;
    this.roleChangeDescription = roleChangeDescription;
    this.connectedChannelHandlers = new HashSet<OFChannelHandler>();
    this.currentRoleInfo = new RoleInfo(this.role,
                                   this.roleChangeDescription,
                                   new Date());
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:24,代码来源:Controller.java

示例3: getRole

import net.floodlightcontroller.core.RoleInfo; //导入依赖的package包/类
@Get("json")
public Map<String, String> getRole() {
    IFloodlightProviderService floodlightProvider =
            (IFloodlightProviderService)getContext().getAttributes().
                get(IFloodlightProviderService.class.getCanonicalName());
    Map<String, String> retValue = new HashMap<String, String>();
    RoleInfo ri = floodlightProvider.getRoleInfo();
    retValue.put(STR_ROLE, ri.getRole().toString());
    retValue.put(STR_ROLE_CHANGE_DESC, ri.getRoleChangeDescription());
    retValue.put(STR_ROLE_CHANGE_DATE_TIME, ri.getRoleChangeDateTime().toString());
    return retValue;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:13,代码来源:ControllerRoleResource.java

示例4: setRole

import net.floodlightcontroller.core.RoleInfo; //导入依赖的package包/类
/**
 * Set the controller's new role and notify switches.
 *
 * This method updates the controllers current role and notifies all
 * connected switches of the new role is different from the current
 * role. We dampen calls to this method. See class description for
 * details.
 *
 * @param role The new role.
 * @param roleChangeDescription A textual description of why the role
 * was changed. For information purposes only.
 * @throws NullPointerException if role or roleChangeDescription is null
 */
public synchronized void setRole(@Nonnull HARole role, @Nonnull String roleChangeDescription) {
    Preconditions.checkNotNull(role, "role must not be null");
    Preconditions.checkNotNull(roleChangeDescription, "roleChangeDescription must not be null");

    if (role == getRole()) {
        counters.setSameRole.increment();
        log.debug("Received role request for {} but controller is "
                + "already {}. Ignoring it.", role, this.getRole());
        return;
    }

    if (this.getRole() == HARole.STANDBY && role == HARole.ACTIVE) {
        // At this point we are guaranteed that we will execute the code
        // below exactly once during the lifetime of this process! And
        // it will be a to MASTER transition
        counters.setRoleMaster.increment();
    }

    log.info("Received role request for {} (reason: {})."
            + " Initiating transition", role, roleChangeDescription);

    currentRoleInfo =
            new RoleInfo(role, roleChangeDescription, new Date());

    controller.addUpdateToQueue(new HARoleUpdate(role));
    controller.addUpdateToQueue(new SwitchRoleUpdate(role));

}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:42,代码来源:RoleManager.java

示例5: testGetRoleInfoDefault

import net.floodlightcontroller.core.RoleInfo; //导入依赖的package包/类
@Test
public void testGetRoleInfoDefault() {
    RoleInfo info = controller.getRoleInfo();
    assertEquals(HARole.ACTIVE, info.getRole());
    assertNotNull(info.getRoleChangeDescription());
    assertEquals(HARole.ACTIVE, controller.getRole());
    // FIXME: RoleInfo's date. but the format is kinda broken
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:9,代码来源:ControllerTest.java

示例6: testSetRole

import net.floodlightcontroller.core.RoleInfo; //导入依赖的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(HARole.STANDBY);
    RoleInfo info = controller.getRoleInfo();
    assertEquals(HARole.STANDBY, info.getRole());
    assertEquals(HARole.STANDBY, controller.getRole());


    OFSwitchHandshakeHandler h = createMock(OFSwitchHandshakeHandler.class);

    // Reassert the role.
    reset(h);
    h.sendRoleRequestIfNotPending(OFControllerRole.ROLE_SLAVE);
    replay(h);
    controller.reassertRole(h, HARole.STANDBY);
    verify(h);

    // reassert a different role: no-op
    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());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:44,代码来源:ControllerTest.java

示例7: setRole

import net.floodlightcontroller.core.RoleInfo; //导入依赖的package包/类
/**
 * Set the controller's new role and notify switches.
 *
 * This method updates the controllers current role and notifies all
 * connected switches of the new role is different from the current
 * role. We dampen calls to this method. See class description for
 * details.
 *
 * @param role The new role.
 * @param roleChangeDescription A textual description of why the role
 * was changed. For information purposes only.
 * @throws NullPointerException if role or roleChangeDescription is null
 */
public synchronized void setRole(@Nonnull HARole role, @Nonnull String roleChangeDescription) {
    Preconditions.checkNotNull(role, "role must not be null");
    Preconditions.checkNotNull(roleChangeDescription, "roleChangeDescription must not be null");

    if (role == getRole()) {
        counters.setSameRole.increment();
        log.debug("Received role request for {} but controller is "
                + "already {}. Ignoring it.", role, this.getRole());
        return;
    }

    if (this.getRole() == HARole.STANDBY && role == HARole.ACTIVE) {
        // At this point we are guaranteed that we will execute the code
        // below exactly once during the lifetime of this process! And
        // it will be a to MASTER transition
        counters.setRoleMaster.increment();
    }
    
    if (role == HARole.EQUAL) {
    	if (this.getRole() == HARole.ACTIVE) {
    		counters.setRoleEQUAL.increment();
    	} else { // previous role was STANDBY
    		//TODO: handle standby to EQUAL 
    		log.debug("Received role request for {} but controller is "
                    + "in {}. returning as of now.", role, this.getRole());
    		return;
    	}
    }

    log.info("Received role request for {} (reason: {})."
            + " Initiating transition", role, roleChangeDescription);

    currentRoleInfo =
            new RoleInfo(role, roleChangeDescription, new Date());

    controller.addUpdateToQueue(new HARoleUpdate(role));
    controller.addUpdateToQueue(new SwitchRoleUpdate(role));

}
 
开发者ID:hksoni,项目名称:SDN-Multicast,代码行数:53,代码来源:RoleManager.java

示例8: getRole

import net.floodlightcontroller.core.RoleInfo; //导入依赖的package包/类
@Get("json")
public RoleInfo getRole() {
    IFloodlightProviderService floodlightProvider =
            (IFloodlightProviderService)getContext().getAttributes().
                get(IFloodlightProviderService.class.getCanonicalName());
    return floodlightProvider.getRoleInfo();
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:8,代码来源:ControllerRoleResource.java

示例9: setRole

import net.floodlightcontroller.core.RoleInfo; //导入依赖的package包/类
@Post("json")
@LogMessageDoc(level="WARN",
               message="Invalid role value specified in REST API to " +
                  "set controller role",
               explanation="An HA role change request was malformed.",
               recommendation=LogMessageDoc.CHECK_CONTROLLER)
public void setRole(RoleInfo roleInfo) {
    //Role role = Role.lookupRole(roleInfo.getRole());
    Role role = null;
    try {
        role = Role.valueOf(roleInfo.getRole().toUpperCase());
    }
    catch (IllegalArgumentException e) {
        // The role value in the REST call didn't match a valid
        // role name, so just leave the role as null and handle
        // the error below.
    }
    if (role == null) {
        log.warn ("Invalid role value specified in REST API to " +
        		  "set controller role");
        setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "Invalid role value");
        return;
    }
    String roleChangeDescription = roleInfo.getRoleChangeDescription();
    if (roleChangeDescription == null)
        roleChangeDescription = "<none>";

    IFloodlightProviderService floodlightProvider =
            (IFloodlightProviderService)getContext().getAttributes().
                get(IFloodlightProviderService.class.getCanonicalName());

    floodlightProvider.setRole(role, roleChangeDescription);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:34,代码来源:ControllerRoleResource.java

示例10: testGetRoleInfoDefault

import net.floodlightcontroller.core.RoleInfo; //导入依赖的package包/类
@Test
public void testGetRoleInfoDefault() {
    RoleInfo info = controller.getRoleInfo();
    assertEquals(Role.MASTER.toString(), info.getRole());
    assertNotNull(info.getRoleChangeDescription());
    assertEquals(Role.MASTER, controller.getRole());
    // FIXME: RoleInfo's date. but the format is kinda broken
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:9,代码来源:ControllerTest.java


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