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


Java OFNiciraVendorData类代码示例

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


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

示例1: sendNxRoleRequest

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的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 {

    int xid = sw.getNextTransactionId();
    // Convert the role enum to the appropriate integer constant used
    // in the NX role request message
    int nxRole = role.toNxRole();

    // Construct the role request message
    OFVendor roleRequest = (OFVendor)BasicFactory.getInstance()
            .getMessage(OFType.VENDOR);
    roleRequest.setXid(xid);
    roleRequest.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
    OFRoleRequestVendorData roleRequestData = new OFRoleRequestVendorData();
    roleRequestData.setRole(nxRole);
    roleRequest.setVendorData(roleRequestData);
    roleRequest.setLengthU(OFVendor.MINIMUM_LENGTH +
            roleRequestData.getLength());

    // Send it to the switch
    sw.write(Collections.<OFMessage>singletonList(roleRequest),
             new FloodlightContext());

    return xid;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:33,代码来源:OFChannelHandler.java

示例2: extractNiciraRoleReply

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的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.
 * FIXME: The message parser should make sure that the Nicira role is
 * actually valid. Why do we need to take care of it ?!?
 */
protected Role extractNiciraRoleReply(OFChannelHandler h,
                                      OFVendor vendorMessage) {
    int vendor = vendorMessage.getVendor();
    if (vendor != OFNiciraVendorData.NX_VENDOR_ID)
        return null;
    if (! (vendorMessage.getVendorData() instanceof OFRoleReplyVendorData))
        return null;
    OFRoleReplyVendorData roleReplyVendorData =
            (OFRoleReplyVendorData) vendorMessage.getVendorData();
    Role role = Role.fromNxRole(roleReplyVendorData.getRole());
    if (role == null) {
        String msg = String.format("Switch: [%s], State: [%s], "
                + "received NX_ROLE_REPLY with invalid role "
                + "value %d",
                h.getSwitchInfoString(),
                this.toString(),
                roleReplyVendorData.getRole());
        throw new SwitchStateException(msg);
    }
    return role;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:37,代码来源:OFChannelHandler.java

示例3: initVendorMessages

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
private void initVendorMessages() {
    // Configure openflowj to be able to parse the role request/reply
    // vendor messages.
    OFBasicVendorId niciraVendorId = new OFBasicVendorId(
            OFNiciraVendorData.NX_VENDOR_ID, 4);
    OFVendorId.registerVendorId(niciraVendorId);
    OFBasicVendorDataType roleRequestVendorData =
            new OFBasicVendorDataType(
                    OFRoleRequestVendorData.NXT_ROLE_REQUEST,
                    OFRoleRequestVendorData.getInstantiable());
    niciraVendorId.registerVendorDataType(roleRequestVendorData);
    OFBasicVendorDataType roleReplyVendorData =
            new OFBasicVendorDataType(
                    OFRoleReplyVendorData.NXT_ROLE_REPLY,
                    OFRoleReplyVendorData.getInstantiable());
     niciraVendorId.registerVendorDataType(roleReplyVendorData);
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:18,代码来源:Controller.java

示例4: extractNiciraRoleRequest

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
/**
 * Extracts the vendor-specific (Nicira) role.
 *
 * @param chan the channel
 * @param vendorMessage the vendor message
 * @return the role
 */
private Role extractNiciraRoleRequest(Channel chan, OFVendor vendorMessage) {
    int vendor = vendorMessage.getVendor();
    if (vendor != OFNiciraVendorData.NX_VENDOR_ID) {
        return null;
    }
    if (!(vendorMessage.getVendorData() instanceof OFRoleRequestVendorData)) {
        return null;
    }
    OFRoleRequestVendorData roleRequestVendorData = (OFRoleRequestVendorData) vendorMessage
            .getVendorData();
    Role role = Role.fromNxRole(roleRequestVendorData.getRole());
    if (role == null) {
        String msg = String.format("Controller: [%s], State: [%s], "
                + "received NX_ROLE_REPLY with invalid role " + "value %d",
                chan.getRemoteAddress(), this.toString(),
                roleRequestVendorData.getRole());
        throw new ControllerStateException(msg);
    }
    return role;
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:28,代码来源:OVXSwitch.java

示例5: verifyRoleRequest

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
/**
 * Helper
 * Verify that the given OFMessage is a correct Nicira RoleRequest message
 * for the given role using the given xid.
 */
private void verifyRoleRequest(OFMessage m,
                               int expectedXid,
                               Role expectedRole) {
    assertEquals(OFType.VENDOR, m.getType());
    OFVendor vendorMsg = (OFVendor)m;
    assertEquals(expectedXid, vendorMsg.getXid());
    assertEquals(OFNiciraVendorData.NX_VENDOR_ID, vendorMsg.getVendor());
    assertTrue("Vendor data is not an instance of OFRoleRequestVendorData"
               + " its class is: " + vendorMsg.getVendorData().getClass().getName(),
               vendorMsg.getVendorData() instanceof OFRoleRequestVendorData);
    OFRoleRequestVendorData requestData =
            (OFRoleRequestVendorData)vendorMsg.getVendorData();
    assertEquals(expectedRole.toNxRole(), requestData.getRole());
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:20,代码来源:OFChannelHandlerTest.java

示例6: getRoleReply

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
/** Return a Nicira RoleReply message for the given role */
private OFMessage getRoleReply(int xid, Role role) {
    OFVendor vm = (OFVendor)BasicFactory.getInstance()
            .getMessage(OFType.VENDOR);
    vm.setXid(xid);
    vm.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
    OFRoleReplyVendorData replyData = new OFRoleReplyVendorData();
    replyData.setRole(role.toNxRole());
    vm.setVendorData(replyData);
    return vm;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:12,代码来源:OFChannelHandlerTest.java

示例7: handleVendorMessage

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
protected boolean handleVendorMessage(OFVendor vendorMessage) {
    boolean shouldHandleMessage = false;
    int vendor = vendorMessage.getVendor();
    switch (vendor) {
        case OFNiciraVendorData.NX_VENDOR_ID:
            OFNiciraVendorData niciraVendorData =
                (OFNiciraVendorData)vendorMessage.getVendorData();
            int dataType = niciraVendorData.getDataType();
            switch (dataType) {
                case OFRoleReplyVendorData.NXT_ROLE_REPLY:
                    OFRoleReplyVendorData roleReplyVendorData =
                            (OFRoleReplyVendorData) niciraVendorData;
                    handleRoleReplyMessage(vendorMessage, 
                                           roleReplyVendorData);
                    break;
                default:
                    log.warn("Unhandled Nicira VENDOR message; " +
                             "data type = {}", dataType);
                    break;
            }
            break;
        default:
            log.warn("Unhandled VENDOR message; vendor id = {}", vendor);
            break;
    }
    
    return shouldHandleMessage;
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:29,代码来源:Controller.java

示例8: doSendNxRoleRequest

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
public void doSendNxRoleRequest(Role role, int nx_role) throws Exception {
    long cookie = System.nanoTime();
    
    // verify that the correct OFMessage is sent
    Capture<List<OFMessage>> msgCapture = new Capture<List<OFMessage>>();
    expect(sw.channel.write(capture(msgCapture))).andReturn(null);
    replay(sw.channel);
    int xid = sw.sendNxRoleRequest(role, cookie);
    verify(sw.channel);
    List<OFMessage> msgList = msgCapture.getValue();
    assertEquals(1, msgList.size());
    OFMessage msg = msgList.get(0);
    assertEquals("Transaction Ids must match", xid, msg.getXid()); 
    assertTrue("Message must be an OFVendor type", msg instanceof OFVendor);
    assertEquals(OFType.VENDOR, msg.getType());
    OFVendor vendorMsg = (OFVendor)msg;
    assertEquals("Vendor message must be vendor Nicira",
                 OFNiciraVendorData.NX_VENDOR_ID, vendorMsg.getVendor());
    OFVendorData vendorData = vendorMsg.getVendorData();
    assertTrue("Vendor Data must be an OFRoleRequestVendorData",
                 vendorData instanceof OFRoleRequestVendorData);
    OFRoleRequestVendorData roleRequest = (OFRoleRequestVendorData)vendorData;
    assertEquals(nx_role, roleRequest.getRole());
    
    // Now verify that we've added the pending request correctly
    // to the pending queue
    assertEquals(1, sw.pendingRoleRequests.size());
    PendingRoleRequestEntry pendingRoleRequest = sw.pendingRoleRequests.poll();
    assertEquals(msg.getXid(), pendingRoleRequest.xid);
    assertEquals(role, pendingRoleRequest.role);
    assertEquals(cookie, pendingRoleRequest.cookie);
    reset(sw.channel);
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:34,代码来源:OFSwitchImplTest.java

示例9: getRoleReplyMsgForRoleReplyTest

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
protected OFVendor getRoleReplyMsgForRoleReplyTest(int xid, int nicira_role) {
    OFVendor msg = new OFVendor();
    msg.setXid(xid);
    msg.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
    OFRoleReplyVendorData roleReplyVendorData = 
            new OFRoleReplyVendorData(OFRoleReplyVendorData.NXT_ROLE_REPLY);
    msg.setVendorData(roleReplyVendorData);
    roleReplyVendorData.setRole(nicira_role);
    return msg;
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:11,代码来源:ControllerTest.java

示例10: sendRoleReply

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
/**
 * Sends a role reply.
 *
 * @param role the role
 * @param xid the transaction ID
 * @param channel the channel on which to send
 */
private void sendRoleReply(Role role, int xid, Channel channel) {
    OFVendor vendor = new OFVendor();
    vendor.setXid(xid);
    vendor.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
    OFRoleReplyVendorData reply = new OFRoleReplyVendorData(role.toNxRole());
    vendor.setVendorData(reply);
    vendor.setLengthU(OFVendor.MINIMUM_LENGTH + reply.getLength());
    channel.write(Collections.singletonList(vendor));
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:17,代码来源:OVXSwitch.java

示例11: processOFVendor

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
@Override
void processOFVendor(final ControllerChannelHandler h,
        final OFVendor m) {
    if (m.getVendor() == OFNiciraVendorData.NX_VENDOR_ID
            && m.getVendorData() instanceof OFRoleRequestVendorData) {
        h.sw.handleRoleIO(m, h.channel);
    } else {
        this.unhandledMessageReceived(h, m);
    }
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:11,代码来源:ControllerChannelHandler.java

示例12: handleVendorMessage

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
protected boolean handleVendorMessage(OFVendor vendorMessage) {
    boolean shouldHandleMessage = false;
    int vendor = vendorMessage.getVendor();
    switch (vendor) {
        case OFNiciraVendorData.NX_VENDOR_ID:
            OFNiciraVendorData niciraVendorData =
                (OFNiciraVendorData)vendorMessage.getVendorData();
            int dataType = niciraVendorData.getDataType();
            switch (dataType) {
                case OFRoleReplyVendorData.NXT_ROLE_REPLY:
                    OFRoleReplyVendorData roleReplyVendorData =
                            (OFRoleReplyVendorData) niciraVendorData;
                    roleChanger.handleRoleReplyMessage(sw,
                            vendorMessage, roleReplyVendorData);
                    break;
                default:
                    log.warn("Unhandled Nicira VENDOR message; " +
                             "data type = {}", dataType);
                    break;
            }
            break;
        default:
            shouldHandleMessage = true;
            break;
    }

    return shouldHandleMessage;
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:29,代码来源:Controller.java

示例13: getRoleReplyMsgForRoleReplyTest

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
protected OFVendor getRoleReplyMsgForRoleReplyTest(int xid, int nicira_role) {
    OFVendor msg = new OFVendor();
    msg.setXid(xid);
    msg.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
    OFRoleReplyVendorData roleReplyVendorData =
            new OFRoleReplyVendorData(OFRoleReplyVendorData.NXT_ROLE_REPLY);
    msg.setVendorData(roleReplyVendorData);
    roleReplyVendorData.setRole(nicira_role);
    return msg;
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:11,代码来源:ControllerTest.java

示例14: doSendNxRoleRequest

import org.openflow.vendor.nicira.OFNiciraVendorData; //导入依赖的package包/类
public void doSendNxRoleRequest(Role role, int nx_role) throws Exception {
    long cookie = System.nanoTime();
    OFSwitchImpl sw = new OFSwitchImpl();
    Channel ch = createMock(Channel.class);
    sw.setChannel(ch);
    sw.setControllerProvider(controller);
    
    // verify that the correct OFMessage is sent
    Capture<List<OFMessage>> msgCapture = new Capture<List<OFMessage>>();
    // expect(sw.channel.getRemoteAddress()).andReturn(null);
    controller.handleOutgoingMessage(
            (IOFSwitch)EasyMock.anyObject(),
            (OFMessage)EasyMock.anyObject(),
            (ListenerContext)EasyMock.anyObject());
    expect(ch.write(capture(msgCapture))).andReturn(null);
    replay(ch, controller);
    int xid = roleChanger.sendHARoleRequest(sw, role, cookie);
    verify(ch, controller);
    List<OFMessage> msgList = msgCapture.getValue();
    assertEquals(1, msgList.size());
    OFMessage msg = msgList.get(0);
    assertEquals("Transaction Ids must match", xid, msg.getXid()); 
    assertTrue("Message must be an OFVendor type", msg instanceof OFVendor);
    assertEquals(OFType.VENDOR, msg.getType());
    OFVendor vendorMsg = (OFVendor)msg;
    assertEquals("Vendor message must be vendor Nicira",
                 OFNiciraVendorData.NX_VENDOR_ID, vendorMsg.getVendor());
    OFVendorData vendorData = vendorMsg.getVendorData();
    assertTrue("Vendor Data must be an OFRoleRequestVendorData",
                 vendorData instanceof OFRoleRequestVendorData);
    OFRoleRequestVendorData roleRequest = (OFRoleRequestVendorData)vendorData;
    assertEquals(nx_role, roleRequest.getRole());
    
    reset(ch);
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:36,代码来源:RoleChangerTest.java


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