本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFRoleRequest类的典型用法代码示例。如果您正苦于以下问题:Java OFRoleRequest类的具体用法?Java OFRoleRequest怎么用?Java OFRoleRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFRoleRequest类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFRoleRequest类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveToWaitInitialRole
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
moveToWaitAppHandshakeState();
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));
reset(sw);
expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
replay(sw);
reset(roleManager);
expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
roleManager.notifyControllerConnectionUpdate();
expectLastCall().once();
replay(roleManager);
WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
state.enterNextPlugin();
// Expect wait initial role's enterState message to be written
OFMessage msg = connection.retrieveMessage();
assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
verifyUniqueXids(msg);
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
示例2: processWrittenOFMessage
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
void processWrittenOFMessage(OFMessage m) {
switch(m.getType()) {
case ROLE_REQUEST:
processOFRoleRequest((OFRoleRequest) m);
break;
case EXPERIMENTER:
if (m instanceof OFNiciraControllerRoleRequest) {
processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
}
break;
default:
/*
* no-op:
* we can send any request at any time
*/
break;
}
}
示例3: moveToWaitInitialRole
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
moveToWaitAppHandshakeState();
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));
reset(sw);
expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
replay(sw);
reset(roleManager);
expect(roleManager.getOFControllerRole(null)).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
roleManager.notifyControllerConnectionUpdate();
expectLastCall().once();
replay(roleManager);
WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
state.enterNextPlugin();
// Expect wait initial role's enterState message to be written
OFMessage msg = connection.retrieveMessage();
assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
verifyUniqueXids(msg);
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
示例4: processRoleRequest
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
@Override
public void processRoleRequest(Channel channel, OFMessage msg) {
OFRoleRequest ofRoleRequest = (OFRoleRequest) msg;
OFControllerRole oldRole = role(channel);
OFControllerRole newRole = ofRoleRequest.getRole();
if (oldRole.equals(newRole)) {
log.trace("No change needed to existing role {}", oldRole);
} else {
log.trace("Changing role from {} to {}", oldRole, newRole);
setRole(channel, newRole);
}
OFRoleReply ofRoleReply = FACTORY.buildRoleReply()
.setRole(role(channel))
.setXid(msg.getXid())
.build();
channel.writeAndFlush(Collections.singletonList(ofRoleReply));
log.trace("request {}; reply {}", msg, ofRoleReply);
}
示例5: sendRoleRequest
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
@Override
public final void sendRoleRequest(OFMessage msg) {
if (msg instanceof OFRoleRequest ||
msg instanceof OFNiciraControllerRoleRequest) {
sendMsgsOnChannel(Collections.singletonList(msg));
return;
}
throw new IllegalArgumentException("Someone is trying to send " +
"a non role request message");
}
示例6: sendOF13RoleRequest
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
private int sendOF13RoleRequest(RoleState role) throws IOException {
// Convert the role enum to the appropriate role to send
OFControllerRole roleToSend = OFControllerRole.ROLE_NOCHANGE;
switch (role) {
case EQUAL:
roleToSend = OFControllerRole.ROLE_EQUAL;
break;
case MASTER:
roleToSend = OFControllerRole.ROLE_MASTER;
break;
case SLAVE:
roleToSend = OFControllerRole.ROLE_SLAVE;
break;
default:
log.warn("Sending default role.noChange to switch {}."
+ " Should only be used for queries.", sw);
}
int xid = sw.getNextTransactionId();
OFRoleRequest rrm = OFFactories.getFactory(OFVersion.OF_13)
.buildRoleRequest()
.setRole(roleToSend)
.setXid(xid)
//FIXME fix below when we actually use generation ids
.setGenerationId(U64.ZERO)
.build();
sw.sendRoleRequest(rrm);
return xid;
}
示例7: processWrittenOFMessage
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
void processWrittenOFMessage(OFMessage m) {
switch(m.getType()) {
case ROLE_REQUEST:
processOFRoleRequest((OFRoleRequest) m);
break;
case EXPERIMENTER:
if (m instanceof OFNiciraControllerRoleRequest) {
processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
}
break;
default:
break;
}
}
示例8: sendRoleRequestIfNotPending
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
void sendRoleRequestIfNotPending(OFRoleRequest role) {
try {
roleChanger.sendRoleRequestIfNotPending(role.getRole(), 0);
} catch (IOException e) {
log.error("Disconnecting switch {} due to IO Error: {}",
getSwitchInfoString(), e.getMessage());
mainConnection.disconnect();
}
}
示例9: sendRoleRequest
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
void sendRoleRequest(OFRoleRequest role) {
try {
roleChanger.sendRoleRequest(role.getRole(), role.getXid());
} catch (IOException e) {
log.error("Disconnecting switch {} due to IO Error: {}",
getSwitchInfoString(), e.getMessage());
mainConnection.disconnect();
}
}
示例10: testWriteRequestOFErrorMsg
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
/** write a request which triggers an OFErrorMsg response */
@Test(timeout = 5000)
public void testWriteRequestOFErrorMsg() throws InterruptedException, ExecutionException {
Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();
OFRoleRequest roleRequest = factory.buildRoleRequest().setRole(OFControllerRole.ROLE_MASTER).build();
ListenableFuture<OFRoleReply> future = conn.writeRequest(roleRequest);
assertThat("Connection should have 1 pending request",
conn.getPendingRequestIds().size(), equalTo(1));
eventLoop.runTasks();
assertThat("Should have captured MsgList", cMsgList.getValue(),
Matchers.<OFMessage> contains(roleRequest));
assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
OFRoleRequestFailedErrorMsg roleError = factory.errorMsgs().buildRoleRequestFailedErrorMsg()
.setXid(roleRequest.getXid())
.setCode(OFRoleRequestFailedCode.STALE)
.build();
assertThat("Connection should have accepted the response",
conn.deliverResponse(roleError),
equalTo(true));
OFErrorMsgException e =
FutureTestUtils.assertFutureFailedWithException(future,
OFErrorMsgException.class);
assertThat(e.getErrorMessage(), CoreMatchers.<OFErrorMsg>equalTo(roleError));
}
示例11: processWrittenOFMessage
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
void processWrittenOFMessage(OFMessage m) {
switch(m.getType()) {
case ROLE_REQUEST:
processOFRoleRequest((OFRoleRequest) m);
break;
case EXPERIMENTER:
if (m instanceof OFNiciraControllerRoleRequest) {
processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
}
break;
default:
illegalMessageReceived(m);
break;
}
}
示例12: testWriteRequestOFErrorMsg
import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
/** write a request which triggers an OFErrorMsg response */
@Test(timeout = 5000)
public void testWriteRequestOFErrorMsg() throws InterruptedException, ExecutionException {
Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();
OFRoleRequest roleRequest = factory.buildRoleRequest().setRole(OFControllerRole.ROLE_MASTER).build();
ListenableFuture<OFRoleReply> future = conn.writeRequest(roleRequest);
assertThat("Connection should have 1 pending request",
conn.getPendingRequestIds().size(), equalTo(1));
assertThat("Should have captured MsgList", cMsgList.getValue(),
Matchers.<OFMessage> contains(roleRequest));
assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
OFRoleRequestFailedErrorMsg roleError = factory.errorMsgs().buildRoleRequestFailedErrorMsg()
.setXid(roleRequest.getXid())
.setCode(OFRoleRequestFailedCode.STALE)
.build();
assertThat("Connection should have accepted the response",
conn.deliverResponse(roleError),
equalTo(true));
OFErrorMsgException e =
FutureTestUtils.assertFutureFailedWithException(future,
OFErrorMsgException.class);
assertThat(e.getErrorMessage(), CoreMatchers.<OFErrorMsg>equalTo(roleError));
}