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


Java OFNiciraControllerRole类代码示例

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


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

示例1: sendNxRoleRequest

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
/**
 * Send NX role request message to the switch requesting the specified
 * role.
 *
 * @param role role to request
 */
private int sendNxRoleRequest(RoleState role) throws IOException {
    // Convert the role enum to the appropriate role to send
    OFNiciraControllerRole roleToSend = OFNiciraControllerRole.ROLE_OTHER;
    switch (role) {
    case MASTER:
        roleToSend = OFNiciraControllerRole.ROLE_MASTER;
        break;
    case SLAVE:
    case EQUAL:
    default:
        // ensuring that the only two roles sent to 1.0 switches with
        // Nicira role support, are MASTER and SLAVE
        roleToSend = OFNiciraControllerRole.ROLE_OTHER;
        log.debug("Sending Nx Role.SLAVE to switch {}.", sw);
    }
    int xid = sw.getNextTransactionId();
    OFExperimenter roleRequest = OFFactories.getFactory(OFVersion.OF_10)
            .buildNiciraControllerRoleRequest()
            .setXid(xid)
            .setRole(roleToSend)
            .build();
    sw.sendRoleRequest(roleRequest);
    return xid;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:RoleManager.java

示例2: sendNxRoleRequest

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
/**
 * Send NX role request message to the switch requesting the specified
 * role.
 *
 * @param role role to request
 */
private int sendNxRoleRequest(RoleState role) throws IOException {
    // Convert the role enum to the appropriate role to send
    OFNiciraControllerRole roleToSend = OFNiciraControllerRole.ROLE_OTHER;
    switch (role) {
    case MASTER:
        roleToSend = OFNiciraControllerRole.ROLE_MASTER;
        break;
    case SLAVE:
    case EQUAL:
    default:
        // ensuring that the only two roles sent to 1.0 switches with
        // Nicira role support, are MASTER and SLAVE
        roleToSend = OFNiciraControllerRole.ROLE_OTHER;
        log.warn("Sending Nx Role.SLAVE to switch {}.", sw);
    }
    int xid = sw.getNextTransactionId();
    OFExperimenter roleRequest = OFFactories.getFactory(OFVersion.OF_10)
            .buildNiciraControllerRoleRequest()
            .setXid(xid)
            .setRole(roleToSend)
            .build();
    sw.write(Collections.<OFMessage>singletonList(roleRequest));
    return xid;
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:31,代码来源:RoleManager.java

示例3: sendNxRoleRequest

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
/**
 * Send NX role request message to the switch requesting the specified
 * role.
 *
 * @param sw switch to send the role request message to
 * @param role role to request
 */
private int sendNxRoleRequest(Role role) throws IOException {
    // Convert the role enum to the appropriate role to send
    OFNiciraControllerRole roleToSend = OFNiciraControllerRole.ROLE_OTHER;
    switch (role) {
    case MASTER:
        roleToSend = OFNiciraControllerRole.ROLE_MASTER;
        break;
    case SLAVE:
    case EQUAL:
    default:
        // ensuring that the only two roles sent to 1.0 switches with
        // Nicira role support, are MASTER and SLAVE
        roleToSend = OFNiciraControllerRole.ROLE_SLAVE;
        log.warn("Sending Nx Role.SLAVE to switch {}.", sw);
    }
    int xid = sw.getNextTransactionId();
    OFExperimenter roleRequest = factory10
            .buildNiciraControllerRoleRequest()
            .setXid(xid)
            .setRole(roleToSend)
            .build();
    sw.write(Collections.<OFMessage>singletonList(roleRequest),
            new FloodlightContext());
    return xid;
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:33,代码来源:OFChannelHandler.java

示例4: getRoleReply

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
private OFMessage getRoleReply(long xid, Role role) {

        OFNiciraControllerRole nr = null;

        switch(role) {
        case MASTER:
            nr = OFNiciraControllerRole.ROLE_MASTER;
            break;
        case EQUAL:
            nr = OFNiciraControllerRole.ROLE_SLAVE;
            break;
        case SLAVE:
            nr = OFNiciraControllerRole.ROLE_SLAVE;
            break;
        default: //handled below
        }
        OFMessage m = factory10.buildNiciraControllerRoleReply()
                .setRole(nr)
                .setXid(xid)
                .build();
        return m;
    }
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:23,代码来源:OFChannelHandlerTest.java

示例5: extractNiciraRoleReply

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
/**
 * Extract the role from an OFVendor message.
 *
 * Extract the role from an OFVendor message if the message is a
 * Nicira role reply. Otherwise return null.
 *
 * @param experimenterMsg message
 * @return The role in the message if the message is a Nicira role
 * reply, null otherwise.
 * @throws SwitchStateException If the message is a Nicira role reply
 * but the numeric role value is unknown.
 */
@Override
public RoleState extractNiciraRoleReply(OFExperimenter experimenterMsg)
        throws SwitchStateException {
    int vendor = (int) experimenterMsg.getExperimenter();
    if (vendor != 0x2320) {
        return null;
    }
    OFNiciraControllerRoleReply nrr =
            (OFNiciraControllerRoleReply) experimenterMsg;

    RoleState role = null;
    OFNiciraControllerRole ncr = nrr.getRole();
    switch (ncr) {
    case ROLE_MASTER:
        role = RoleState.MASTER;
        break;
    case ROLE_OTHER:
        role = RoleState.EQUAL;
        break;
    case ROLE_SLAVE:
        role = RoleState.SLAVE;
        break;
    default: //handled below
    }

    if (role == null) {
        String msg = String.format("Switch: [%s], "
                + "received NX_ROLE_REPLY with invalid role "
                + "value %s",
                sw.getStringId(),
                nrr.getRole());
        throw new SwitchStateException(msg);
    }
    return role;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:48,代码来源:RoleManager.java

示例6: ofRoleToNiciraRole

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
public static OFNiciraControllerRole ofRoleToNiciraRole(OFControllerRole role) {
    switch(role) {
        case ROLE_EQUAL:
            return OFNiciraControllerRole.ROLE_OTHER;
        case ROLE_MASTER:
            return OFNiciraControllerRole.ROLE_MASTER;
        case ROLE_SLAVE:
            return OFNiciraControllerRole.ROLE_SLAVE;
        default:
            throw new IllegalArgumentException("Unknown role: " + role);
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:13,代码来源:NiciraRoleUtils.java

示例7: readFrom

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
public static OFNiciraControllerRole readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:8,代码来源:OFNiciraControllerRoleSerializerVer10.java

示例8: ofWireValue

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
public static OFNiciraControllerRole ofWireValue(int val) {
    switch(val) {
        case ROLE_OTHER_VAL:
            return OFNiciraControllerRole.ROLE_OTHER;
        case ROLE_MASTER_VAL:
            return OFNiciraControllerRole.ROLE_MASTER;
        case ROLE_SLAVE_VAL:
            return OFNiciraControllerRole.ROLE_SLAVE;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFNiciraControllerRole in version 1.0: " + val);
    }
}
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:13,代码来源:OFNiciraControllerRoleSerializerVer10.java

示例9: toWireValue

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
public static int toWireValue(OFNiciraControllerRole e) {
    switch(e) {
        case ROLE_OTHER:
            return ROLE_OTHER_VAL;
        case ROLE_MASTER:
            return ROLE_MASTER_VAL;
        case ROLE_SLAVE:
            return ROLE_SLAVE_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFNiciraControllerRole in version 1.0: " + e);
    }
}
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:13,代码来源:OFNiciraControllerRoleSerializerVer10.java

示例10: extractNiciraRoleReply

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
/**
 * Extract the role from an OFVendor message.
 *
 * Extract the role from an OFVendor message if the message is a Nicira
 * role reply. Otherwise return null.
 *
 * @param h The channel handler receiving the message
 * @param vendorMessage The vendor message to parse.
 * @return The role in the message if the message is a Nicira role
 *         reply, null otherwise.
 * @throws SwitchStateException If the message is a Nicira role reply
 *         but the numeric role value is unknown.
 */
protected Role extractNiciraRoleReply(OFChannelHandler h,
        OFExperimenter experimenterMsg) throws SwitchStateException {
    int vendor = (int) experimenterMsg.getExperimenter();
    if (vendor != 0x2320) // magic number representing nicira
        return null;
    OFNiciraControllerRoleReply nrr =
            (OFNiciraControllerRoleReply) experimenterMsg;

    Role role = null;
    OFNiciraControllerRole ncr = nrr.getRole();
    switch (ncr) {
    case ROLE_MASTER:
        role = Role.MASTER;
        break;
    case ROLE_OTHER:
        role = Role.EQUAL;
        break;
    case ROLE_SLAVE:
        role = Role.SLAVE;
        break;
    default: // handled below
    }

    if (role == null) {
        String msg = String.format("Switch: [%s], State: [%s], "
                + "received NX_ROLE_REPLY with invalid role "
                + "value %d",
                h.getSwitchInfoString(),
                this.toString(),
                nrr.getRole());
        throw new SwitchStateException(msg);
    }
    return role;
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:48,代码来源:OFChannelHandler.java

示例11: readFrom

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
public static OFNiciraControllerRole readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:8,代码来源:OFNiciraControllerRoleSerializerVer10.java

示例12: testMessageDispatchComplete

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
/**
 * Test dispatch of messages while in Complete state
 */
@Test
public void testMessageDispatchComplete() throws Exception {
    moveToComplete();
    newConnection.getValue().setListener(connectionListener);

    resetChannel();
    expect(channel.writeAndFlush(capture(writeCapture))).andReturn(null).atLeastOnce();
    replay(channel);

    // Send echo request. expect reply
    OFMessage echoRequest = factory.buildEchoRequest().build();
    sendMessageToHandlerWithControllerReset(ImmutableList.<OFMessage>of(echoRequest));

    List<OFMessage> msgs = getMessagesFromCapture();
    assertEquals(1, msgs.size());
    assertEquals(OFType.ECHO_REPLY, msgs.get(0).getType());

    // Send barrier reply. expect dispatch
    OFBarrierReply barrierReply = factory.buildBarrierReply()
            .build();

    resetAndExpectConnectionListener(barrierReply);


    // Send packet in. expect dispatch
    OFFlowRemoved flowRemoved = factory.buildFlowRemoved()
            .build();

    resetAndExpectConnectionListener(flowRemoved);

    // Send get config reply. expect dispatch
    OFGetConfigReply getConfigReply = factory.buildGetConfigReply()
            .build();

    resetAndExpectConnectionListener(getConfigReply);

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();

    resetAndExpectConnectionListener(pi);

    // Send port status. expect dispatch
    OFPortStatus portStatus = factory.buildPortStatus()
            .setReason(OFPortReason.DELETE)
            .setDesc(portDesc)
            .build();

    resetAndExpectConnectionListener(portStatus);

    // Send queue reply. expect dispatch
    OFQueueGetConfigReply queueReply = factory.buildQueueGetConfigReply()
            .build();

    resetAndExpectConnectionListener(queueReply);

    // Send stat reply. expect dispatch
    OFFlowStatsReply statReply = factory.buildFlowStatsReply()
            .build();

    resetAndExpectConnectionListener(statReply);

    // Send role reply. expect dispatch
    OFNiciraControllerRoleReply roleReply = factory.buildNiciraControllerRoleReply()
            .setRole(OFNiciraControllerRole.ROLE_MASTER)
            .build();

    resetAndExpectConnectionListener(roleReply);

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

示例13: testMessageDispatchComplete

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
/**
 * Test dispatch of messages while in Complete state
 */
@Test
public void testMessageDispatchComplete() throws Exception {
    moveToComplete();
    newConnection.getValue().setListener(connectionListener);

    resetChannel();
    channel.write(capture(writeCapture));
    expectLastCall().andReturn(null).atLeastOnce();
    replay(channel);

    // Send echo request. expect reply
    OFMessage echoRequest = factory.buildEchoRequest().build();
    sendMessageToHandlerWithControllerReset(ImmutableList.<OFMessage>of(echoRequest));

    List<OFMessage> msgs = getMessagesFromCapture();
    assertEquals(1, msgs.size());
    assertEquals(OFType.ECHO_REPLY, msgs.get(0).getType());

    // Send barrier reply. expect dispatch
    OFBarrierReply barrierReply = factory.buildBarrierReply()
            .build();

    resetAndExpectConnectionListener(barrierReply);


    // Send packet in. expect dispatch
    OFFlowRemoved flowRemoved = factory.buildFlowRemoved()
            .build();

    resetAndExpectConnectionListener(flowRemoved);

    // Send get config reply. expect dispatch
    OFGetConfigReply getConfigReply = factory.buildGetConfigReply()
            .build();

    resetAndExpectConnectionListener(getConfigReply);

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();

    resetAndExpectConnectionListener(pi);

    // Send port status. expect dispatch
    OFPortStatus portStatus = factory.buildPortStatus()
            .setReason(OFPortReason.DELETE)
            .setDesc(portDesc)
            .build();

    resetAndExpectConnectionListener(portStatus);

    // Send queue reply. expect dispatch
    OFQueueGetConfigReply queueReply = factory.buildQueueGetConfigReply()
            .build();

    resetAndExpectConnectionListener(queueReply);

    // Send stat reply. expect dispatch
    OFFlowStatsReply statReply = factory.buildFlowStatsReply()
            .build();

    resetAndExpectConnectionListener(statReply);

    // Send role reply. expect dispatch
    OFNiciraControllerRoleReply roleReply = factory.buildNiciraControllerRoleReply()
            .setRole(OFNiciraControllerRole.ROLE_MASTER)
            .build();

    resetAndExpectConnectionListener(roleReply);

}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:76,代码来源:OFChannelHandlerVer10Test.java

示例14: writeTo

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
public static void writeTo(ChannelBuffer bb, OFNiciraControllerRole e) {
    bb.writeInt(toWireValue(e));
}
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:4,代码来源:OFNiciraControllerRoleSerializerVer10.java

示例15: putTo

import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole; //导入依赖的package包/类
public static void putTo(OFNiciraControllerRole e, PrimitiveSink sink) {
    sink.putInt(toWireValue(e));
}
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:4,代码来源:OFNiciraControllerRoleSerializerVer10.java


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