本文整理汇总了Java中org.openflow.vendor.nicira.OFRoleRequestVendorData类的典型用法代码示例。如果您正苦于以下问题:Java OFRoleRequestVendorData类的具体用法?Java OFRoleRequestVendorData怎么用?Java OFRoleRequestVendorData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFRoleRequestVendorData类属于org.openflow.vendor.nicira包,在下文中一共展示了OFRoleRequestVendorData类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendNxRoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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;
}
示例2: initVendorMessages
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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
示例3: extractNiciraRoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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;
}
示例4: verifyRoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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());
}
示例5: doSendNxRoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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
示例6: processOFVendor
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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);
}
}
示例7: doSendNxRoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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);
}
示例8: doSendNxRoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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.setFloodlightProvider(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(),
(FloodlightContext)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);
}
示例9: sendNxRoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的package包/类
/**
* Send NX role request message to the switch requesting the specified role.
*
* This method should ONLY be called by @see RoleChanger.submitRequest().
*
* After sending the request add it to the queue of pending request. We
* use the queue to later verify that we indeed receive the correct reply.
* @param sw switch to send the role request message to
* @param role role to request
* @param cookie an opaque value that will be stored in the pending queue so
* RoleChanger can check for timeouts.
* @return transaction id of the role request message that was sent
*/
protected int sendNxRoleRequest(Role role, long cookie)
throws IOException {
synchronized(pendingRoleRequests) {
// Convert the role enum to the appropriate integer constant used
// in the NX role request message
int nxRole = 0;
switch (role) {
case EQUAL:
nxRole = OFRoleVendorData.NX_ROLE_OTHER;
break;
case MASTER:
nxRole = OFRoleVendorData.NX_ROLE_MASTER;
break;
case SLAVE:
nxRole = OFRoleVendorData.NX_ROLE_SLAVE;
break;
default:
log.error("Invalid Role specified for switch {}."
+ " Disconnecting.", this);
// TODO: should throw an error
return 0;
}
// Construct the role request message
OFVendor roleRequest = (OFVendor)floodlightProvider.
getOFMessageFactory().getMessage(OFType.VENDOR);
int xid = this.getNextTransactionId();
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
List<OFMessage> msglist = new ArrayList<OFMessage>(1);
msglist.add(roleRequest);
// FIXME: should this use this.write() in order for messages to
// be processed by handleOutgoingMessage()
this.channel.write(msglist);
pendingRoleRequests.add(new PendingRoleRequestEntry(xid, role, cookie));
return xid;
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:60,代码来源:OFSwitchImpl.java
示例10: sendHARoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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
* @param cookie an opaque value that will be stored in the pending queue so
* RoleChanger can check for timeouts.
* @return transaction id of the role request message that was sent
*/
protected int sendHARoleRequest(IOFSwitch sw, Role role, long cookie)
throws IOException, HARoleUnsupportedException {
// There are three cases to consider:
//
// 1) If the controller role at the point the switch connected was
// null/disabled, then we never sent the role request probe to the
// switch and therefore never set the SWITCH_SUPPORTS_NX_ROLE
// attribute for the switch, so supportsNxRole is null. In that
// case since we're now enabling role support for the controller
// we should send out the role request probe/update to the switch.
//
// 2) If supportsNxRole == Boolean.TRUE then that means we've already
// sent the role request probe to the switch and it replied with
// a role reply message, so we know it supports role request
// messages. Now we're changing the role and we want to send
// it another role request message to inform it of the new role
// for the controller.
//
// 3) If supportsNxRole == Boolean.FALSE, then that means we sent the
// role request probe to the switch but it responded with an error
// indicating that it didn't understand the role request message.
// In that case, we simply throw an unsupported exception.
Boolean supportsNxRole = (Boolean)
sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE);
if ((supportsNxRole != null) && !supportsNxRole) {
throw new HARoleUnsupportedException();
}
int xid = sw.getNextTransactionId();
// Convert the role enum to the appropriate integer constant used
// in the NX role request message
int nxRole = 0;
switch (role) {
case EQUAL:
nxRole = OFRoleVendorData.NX_ROLE_OTHER;
break;
case MASTER:
nxRole = OFRoleVendorData.NX_ROLE_MASTER;
break;
case SLAVE:
nxRole = OFRoleVendorData.NX_ROLE_SLAVE;
break;
default:
log.error("Invalid Role specified for switch {}."
+ " Disconnecting.", sw);
throw new HARoleUnsupportedException();
}
// Construct the role request message
OFVendor roleRequest = (OFVendor)controller.
getOFMessageFactory().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
List<OFMessage> msgList = new ArrayList<OFMessage>(1);
msgList.add(roleRequest);
sw.write(msgList, new ListenerContext());
return xid;
}
示例11: sendHARoleRequest
import org.openflow.vendor.nicira.OFRoleRequestVendorData; //导入依赖的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
* @param cookie an opaque value that will be stored in the pending queue so
* RoleChanger can check for timeouts.
* @return transaction id of the role request message that was sent
*/
protected int sendHARoleRequest(IOFSwitch sw, Role role, long cookie)
throws IOException, HARoleUnsupportedException {
// There are three cases to consider:
//
// 1) If the controller role at the point the switch connected was
// null/disabled, then we never sent the role request probe to the
// switch and therefore never set the SWITCH_SUPPORTS_NX_ROLE
// attribute for the switch, so supportsNxRole is null. In that
// case since we're now enabling role support for the controller
// we should send out the role request probe/update to the switch.
//
// 2) If supportsNxRole == Boolean.TRUE then that means we've already
// sent the role request probe to the switch and it replied with
// a role reply message, so we know it supports role request
// messages. Now we're changing the role and we want to send
// it another role request message to inform it of the new role
// for the controller.
//
// 3) If supportsNxRole == Boolean.FALSE, then that means we sent the
// role request probe to the switch but it responded with an error
// indicating that it didn't understand the role request message.
// In that case, we simply throw an unsupported exception.
Boolean supportsNxRole = (Boolean)
sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE);
if ((supportsNxRole != null) && !supportsNxRole) {
throw new HARoleUnsupportedException();
}
int xid = sw.getNextTransactionId();
// Convert the role enum to the appropriate integer constant used
// in the NX role request message
int nxRole = 0;
switch (role) {
case EQUAL:
nxRole = OFRoleVendorData.NX_ROLE_OTHER;
break;
case MASTER:
nxRole = OFRoleVendorData.NX_ROLE_MASTER;
break;
case SLAVE:
nxRole = OFRoleVendorData.NX_ROLE_SLAVE;
break;
default:
log.error("Invalid Role specified for switch {}."
+ " Disconnecting.", sw);
throw new HARoleUnsupportedException();
}
// Construct the role request message
OFVendor roleRequest = (OFVendor)controller.
getOFMessageFactory().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
List<OFMessage> msgList = new ArrayList<OFMessage>(1);
msgList.add(roleRequest);
sw.write(msgList, new FloodlightContext());
return xid;
}