本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFExperimenter类的典型用法代码示例。如果您正苦于以下问题:Java OFExperimenter类的具体用法?Java OFExperimenter怎么用?Java OFExperimenter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFExperimenter类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFExperimenter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleNiciraRole
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的package包/类
@Override
public void handleNiciraRole(OFMessage m) throws SwitchStateException {
RoleState r = this.roleMan.extractNiciraRoleReply((OFExperimenter) m);
if (r == null) {
// The message wasn't really a Nicira role reply. We just
// dispatch it to the OFMessage listeners in this case.
this.handleMessage(m);
return;
}
RoleRecvStatus rrs = this.roleMan.deliverRoleReply(
new RoleReplyInfo(r, null, m.getXid()));
if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
if (r == RoleState.MASTER) {
this.transitionToMasterSwitch();
} else if (r == RoleState.EQUAL ||
r == RoleState.SLAVE) {
this.transitionToEqualSwitch();
}
} else {
this.disconnectSwitch();
}
}
示例2: sendNxRoleRequest
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的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;
}
示例3: handleNiciraRole
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的package包/类
@Override
public void handleNiciraRole(OFMessage m) throws SwitchStateException {
RoleState r = this.roleMan.extractNiciraRoleReply((OFExperimenter) m);
if (r == null) {
// The message wasn't really a Nicira role reply. We just
// dispatch it to the OFMessage listeners in this case.
this.handleMessage(m);
return;
}
RoleRecvStatus rrs = this.roleMan.deliverRoleReply(
new RoleReplyInfo(r, null, m.getXid()));
if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
if (r == RoleState.MASTER) {
this.role = r;
this.transitionToMasterSwitch();
} else if (r == RoleState.EQUAL ||
r == RoleState.SLAVE) {
this.transitionToEqualSwitch();
}
} else {
this.disconnectSwitch();
}
}
示例4: sendNxRoleRequest
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的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;
}
示例5: sendNxRoleRequest
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的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;
}
示例6: processOFExperimenter
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的package包/类
@Override
void processOFExperimenter(OFChannelHandler h, OFExperimenter m)
throws IOException, SwitchStateException {
Role role = extractNiciraRoleReply(h, m);
// If role == null it means the vendor (experimenter) message
// wasn't really a Nicira role reply. We ignore this case.
if (role != null) {
RoleReplyInfo rri = new RoleReplyInfo(role, null, m.getXid());
RoleRecvStatus rrs = h.roleChanger.deliverRoleReply(rri);
if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
setRoleAndStartDriverHandshake(h, rri.getRole());
} // else do nothing - wait for the correct expected reply
} else {
unhandledMessageReceived(h, m);
}
}
示例7: setupSwitchSendRoleRequestAndVerify
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的package包/类
/**
* Setup the mock switch and write capture for a role request, set the
* role and verify mocks.
* @param supportsNxRole whether the switch supports role request messages
* to setup the attribute. This must be null (don't yet know if roles
* supported: send to check) or true.
* @param xid The xid to use in the role request
* @param role The role to send
* @throws IOException
*/
private void setupSwitchSendRoleRequestAndVerify(Boolean supportsNxRole,
int xid,
Role role) throws IOException {
RoleRecvStatus expectation = RoleRecvStatus.MATCHED_SET_ROLE;
expect(swImplBase.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
.andReturn(supportsNxRole).atLeastOnce();
if (supportsNxRole != null && supportsNxRole) {
expect(swImplBase.getNextTransactionId()).andReturn(xid).once();
swImplBase.write(capture(writeCapture),
EasyMock.<FloodlightContext>anyObject());
expectLastCall().anyTimes();
}
replay(swImplBase);
handler.sendRoleRequest(role, expectation);
if (supportsNxRole != null && supportsNxRole) {
List<OFMessage> msgs = getMessagesFromCapture();
assertEquals(1, msgs.size());
verifyNiciraMessage((OFExperimenter)msgs.get(0));
}
}
示例8: extractNiciraRoleReply
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的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;
}
示例9: processOFMessage
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的package包/类
@Override
void processOFMessage(OFChannelHandler h, OFMessage m)
throws IOException, SwitchStateException {
if (h.sw.isDriverHandshakeComplete()) {
moveToActive(h);
h.state.processOFMessage(h, m);
return;
}
if (m.getType() == OFType.ECHO_REQUEST) {
processOFEchoRequest(h, (OFEchoRequest) m);
} else if (m.getType() == OFType.ECHO_REPLY) {
processOFEchoReply(h, (OFEchoReply) m);
} else if (m.getType() == OFType.ROLE_REPLY) {
h.sw.handleRole(m);
} else if (m.getType() == OFType.ERROR) {
if (!h.sw.handleRoleError((OFErrorMsg)m)) {
h.sw.processDriverHandshakeMessage(m);
if (h.sw.isDriverHandshakeComplete()) {
moveToActive(h);
}
}
} else {
if (m.getType() == OFType.EXPERIMENTER &&
((OFExperimenter) m).getExperimenter() ==
RoleManager.NICIRA_EXPERIMENTER) {
h.sw.handleNiciraRole(m);
} else {
h.sw.processDriverHandshakeMessage(m);
if (h.sw.isDriverHandshakeComplete()) {
moveToActive(h);
}
}
}
}
示例10: processOFExperimenter
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的package包/类
void processOFExperimenter(OFChannelHandler h, OFExperimenter m)
throws IOException, SwitchStateException {
// TODO: it might make sense to parse the vendor message here
// into the known vendor messages we support and then call more
// specific event handlers
unhandledMessageReceived(h, m);
}
示例11: processOFMessage
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的package包/类
/**
* Process an OF message received on the channel and
* update state accordingly.
*
* The main "event" of the state machine. Process the received message,
* send follow up message if required and update state if required.
*
* Switches on the message type and calls more specific event handlers
* for each individual OF message type. If we receive a message that
* is supposed to be sent from a controller to a switch we throw
* a SwitchStateExeption.
*
* The more specific handlers can also throw SwitchStateExceptions
*
* @param h The OFChannelHandler that received the message
* @param m The message we received.
* @throws SwitchStateException
* @throws IOException
*/
void processOFMessage(OFMessage m) {
roleChanger.checkTimeout();
switch(m.getType()) {
case BARRIER_REPLY:
processOFBarrierReply((OFBarrierReply) m);
break;
case ERROR:
processOFError((OFErrorMsg) m);
break;
case FLOW_REMOVED:
processOFFlowRemoved((OFFlowRemoved) m);
break;
case GET_CONFIG_REPLY:
processOFGetConfigReply((OFGetConfigReply) m);
break;
case PACKET_IN:
processOFPacketIn((OFPacketIn) m);
break;
case PORT_STATUS:
processOFPortStatus((OFPortStatus) m);
break;
case QUEUE_GET_CONFIG_REPLY:
processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
break;
case STATS_REPLY:
processOFStatsReply((OFStatsReply) m);
break;
case ROLE_REPLY:
processOFRoleReply((OFRoleReply) m);
break;
case EXPERIMENTER:
processOFExperimenter((OFExperimenter) m);
break;
default:
illegalMessageReceived(m);
break;
}
}
示例12: processOFExperimenter
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入依赖的package包/类
@Override
void processOFExperimenter(OFExperimenter m) {
OFControllerRole role = extractNiciraRoleReply(m);
// If role == null it measn the message wasn't really a
// Nicira role reply. We ignore this case.
if (role != null) {
roleChanger.deliverRoleReply(m.getXid(), role);
} else {
unhandledMessageReceived(m);
}
}