本文整理汇总了Java中org.openflow.vendor.nicira.OFRoleVendorData.NX_ROLE_OTHER属性的典型用法代码示例。如果您正苦于以下问题:Java OFRoleVendorData.NX_ROLE_OTHER属性的具体用法?Java OFRoleVendorData.NX_ROLE_OTHER怎么用?Java OFRoleVendorData.NX_ROLE_OTHER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.openflow.vendor.nicira.OFRoleVendorData
的用法示例。
在下文中一共展示了OFRoleVendorData.NX_ROLE_OTHER属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: role
@LogMessageDoc(level="ERROR",
message="Invalid role value in role reply message",
explanation="Was unable to set the HA role (master or slave) " +
"for the controller.",
recommendation=LogMessageDoc.CHECK_CONTROLLER)
protected void handleRoleReplyMessage(IOFSwitch sw, OFVendor vendorMessage,
OFRoleReplyVendorData roleReplyVendorData) {
// Map from the role code in the message to our role enum
int nxRole = roleReplyVendorData.getRole();
Role role = null;
switch (nxRole) {
case OFRoleVendorData.NX_ROLE_OTHER:
role = Role.EQUAL;
break;
case OFRoleVendorData.NX_ROLE_MASTER:
role = Role.MASTER;
break;
case OFRoleVendorData.NX_ROLE_SLAVE:
role = Role.SLAVE;
break;
default:
log.error("Invalid role value in role reply message");
sw.disconnectOutputStream();
return;
}
log.debug("Handling role reply for role {} from {}. " +
"Controller's role is {} ",
new Object[] { role, sw, controller.role}
);
deliverRoleReply(sw, vendorMessage.getXid(), role);
}
示例2: sendNxRoleRequest
/**
* 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,代码行数:59,代码来源:OFSwitchImpl.java
示例3: sendHARoleRequest
/**
* 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;
}
示例4: sendHARoleRequest
/**
* 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;
}