本文整理汇总了Java中net.floodlightcontroller.core.internal.OFChannelState.HandshakeState.READY属性的典型用法代码示例。如果您正苦于以下问题:Java HandshakeState.READY属性的具体用法?Java HandshakeState.READY怎么用?Java HandshakeState.READY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.floodlightcontroller.core.internal.OFChannelState.HandshakeState
的用法示例。
在下文中一共展示了HandshakeState.READY属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: channelDisconnected
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
if (sw != null && state.hsState == HandshakeState.READY) {
if (activeSwitches.containsKey(sw.getId())) {
// It's safe to call removeSwitch even though the map might
// not contain this particular switch but another with the
// same DPID
removeSwitch(sw);
}
synchronized(roleChanger) {
connectedSwitches.remove(sw);
}
sw.setConnected(false);
}
log.info("Disconnected switch {}", sw);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:19,代码来源:Controller.java
示例2: channelDisconnected
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
if (sw != null && state.hsState == HandshakeState.READY) {
if (activeSwitches.containsKey(sw.getId())) {
// It's safe to call removeSwitch even though the map might
// not contain this particular switch but another with the
// same DPID
removeSwitch(sw);
}
synchronized(roleChanger) {
connectedSwitches.remove(sw);
roleChanger.removePendingRequests(sw);
}
sw.setConnected(false);
}
log.info("Disconnected switch {}", sw);
}
示例3: testVendorMessageUnknown
@Test
public void testVendorMessageUnknown() throws Exception {
// Check behavior with an unknown vendor id
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
OFVendor msg = new OFVendor();
msg.setVendor(0);
chdlr.processOFMessage(msg);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:10,代码来源:ControllerTest.java
示例4: getChannelHandlerForRoleReplyTest
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(OFSwitchImpl.class);
return chdlr;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:7,代码来源:ControllerTest.java
示例5: testVendorMessageUnknown
@Test
public void testVendorMessageUnknown() throws Exception {
// Check behavior with an unknown vendor id
// Ensure that vendor message listeners get called, even for Vendors
// unknown to floodlight. It is the responsibility of the listener to
// discard unknown vendors.
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
OFVendor msg = new OFVendor();
msg.setVendor(0);
IOFSwitch sw = createMock(IOFSwitch.class);
chdlr.sw = sw;
controller.activeSwitches.put(1L, sw);
// prepare the Vendor Message Listener expectations
ListenerDispatcher<OFType, IOFMessageListener> ld =
new ListenerDispatcher<OFType, IOFMessageListener>();
IOFMessageListener ml = createMock(IOFMessageListener.class);
expect(ml.getName()).andReturn("Dummy").anyTimes();
expect(ml.isCallbackOrderingPrereq((OFType)anyObject(),
(String)anyObject())).andReturn(false).anyTimes();
expect(ml.isCallbackOrderingPostreq((OFType)anyObject(),
(String)anyObject())).andReturn(false).anyTimes();
expect(ml.receive(eq(sw), eq(msg), isA(FloodlightContext.class))).
andReturn(Command.CONTINUE).once();
controller.messageListeners.put(OFType.VENDOR, ld);
// prepare the switch and lock expectations
Lock lock = createNiceMock(Lock.class);
expect(sw.getListenerReadLock()).andReturn(lock).anyTimes();
expect(sw.isConnected()).andReturn(true).anyTimes();
expect(sw.getHARole()).andReturn(Role.MASTER).anyTimes();
expect(sw.getId()).andReturn(1L).anyTimes();
// test
replay(chdlr.sw, lock, ml);
ld.addListener(OFType.VENDOR, ml);
chdlr.processOFMessage(msg);
}
示例6: getChannelHandlerForRoleReplyTest
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(IOFSwitch.class);
return chdlr;
}
示例7: checkSwitchReady
protected void checkSwitchReady() {
if (state.hsState == HandshakeState.FEATURES_REPLY &&
state.hasDescription && state.hasGetConfigReply) {
state.hsState = HandshakeState.READY;
synchronized(roleChanger) {
// We need to keep track of all of the switches that are connected
// to the controller, in any role, so that we can later send the
// role request messages when the controller role changes.
// We need to be synchronized while doing this: we must not
// send a another role request to the connectedSwitches until
// we were able to add this new switch to connectedSwitches
// *and* send the current role to the new switch.
connectedSwitches.add(sw);
if (role != null) {
// Send a role request if role support is enabled for the controller
// This is a probe that we'll use to determine if the switch
// actually supports the role request message. If it does we'll
// get back a role reply message. If it doesn't we'll get back an
// OFError message.
// If role is MASTER we will promote switch to active
// list when we receive the switch's role reply messages
log.debug("This controller's role is {}, " +
"sending initial role request msg to {}",
role, sw);
Collection<OFSwitchImpl> swList = new ArrayList<OFSwitchImpl>(1);
swList.add(sw);
roleChanger.submitRequest(swList, role);
}
else {
// Role supported not enabled on controller (for now)
// automatically promote switch to active state.
log.debug("This controller's role is null, " +
"not sending role request msg to {}",
role, sw);
// Need to clear FlowMods before we add the switch
// and dispatch updates otherwise we have a race condition.
sw.clearAllFlowMods();
addSwitch(sw);
state.firstRoleReplyReceived = true;
}
}
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:46,代码来源:Controller.java
示例8: testChannelDisconnected
@Test
public void testChannelDisconnected() throws Exception {
OFChannelState state = new OFChannelState();
state.hsState = OFChannelState.HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(OFSwitchImpl.class);
// Switch is active
expect(chdlr.sw.getId()).andReturn(0L).anyTimes();
expect(chdlr.sw.getStringId()).andReturn("00:00:00:00:00:00:00:00")
.anyTimes();
chdlr.sw.cancelAllStatisticsReplies();
chdlr.sw.setConnected(false);
expect(chdlr.sw.isConnected()).andReturn(true);
controller.connectedSwitches.add(chdlr.sw);
controller.activeSwitches.put(0L, chdlr.sw);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Switch is connected but not active
reset(chdlr.sw);
expect(chdlr.sw.getId()).andReturn(0L).anyTimes();
chdlr.sw.setConnected(false);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Not in ready state
state.hsState = HandshakeState.START;
reset(chdlr.sw);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Switch is null
state.hsState = HandshakeState.READY;
chdlr.sw = null;
chdlr.channelDisconnected(null, null);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:42,代码来源:ControllerTest.java
示例9: testRoleNotSupportedError
@Test
public void testRoleNotSupportedError() throws Exception {
int xid = 424242;
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(OFSwitchImpl.class);
Channel ch = createMock(Channel.class);
// the error returned when role request message is not supported by sw
OFError msg = new OFError();
msg.setType(OFType.ERROR);
msg.setXid(xid);
msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
msg.setErrorCode(OFBadRequestCode.OFPBRC_BAD_VENDOR);
// the switch connection should get disconnected when the controller is
// in SLAVE mode and the switch does not support role-request messages
state.firstRoleReplyReceived = false;
controller.role = Role.SLAVE;
expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
chdlr.sw.deliverRoleRequestNotSupported(xid);
expect(chdlr.sw.getChannel()).andReturn(ch).anyTimes();
expect(ch.close()).andReturn(null);
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("state.firstRoleReplyReceived must be true",
state.firstRoleReplyReceived);
assertTrue("activeSwitches must be empty",
controller.activeSwitches.isEmpty());
reset(ch, chdlr.sw);
// a different error message - should also reject role request
msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
msg.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
state.firstRoleReplyReceived = false;
controller.role = Role.SLAVE;
expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
chdlr.sw.deliverRoleRequestNotSupported(xid);
expect(chdlr.sw.getChannel()).andReturn(ch).anyTimes();
expect(ch.close()).andReturn(null);
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("state.firstRoleReplyReceived must be True even with EPERM",
state.firstRoleReplyReceived);
assertTrue("activeSwitches must be empty",
controller.activeSwitches.isEmpty());
reset(ch, chdlr.sw);
// We are MASTER, the switch should be added to the list of active
// switches.
state.firstRoleReplyReceived = false;
controller.role = Role.MASTER;
expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
chdlr.sw.deliverRoleRequestNotSupported(xid);
setupSwitchForAddSwitch(chdlr.sw, 0L);
chdlr.sw.clearAllFlowMods();
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("state.firstRoleReplyReceived must be true",
state.firstRoleReplyReceived);
assertSame("activeSwitches must contain this switch",
chdlr.sw, controller.activeSwitches.get(0L));
reset(ch, chdlr.sw);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:74,代码来源:ControllerTest.java
示例10: testChannelDisconnected
@Test
public void testChannelDisconnected() throws Exception {
OFChannelState state = new OFChannelState();
state.hsState = OFChannelState.HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(IOFSwitch.class);
// Switch is active
expect(chdlr.sw.getId()).andReturn(0L).anyTimes();
expect(chdlr.sw.getStringId()).andReturn("00:00:00:00:00:00:00:00")
.anyTimes();
chdlr.sw.cancelAllStatisticsReplies();
chdlr.sw.setConnected(false);
expect(chdlr.sw.isConnected()).andReturn(true);
controller.connectedSwitches.add(chdlr.sw);
controller.activeSwitches.put(0L, chdlr.sw);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Switch is connected but not active
reset(chdlr.sw);
expect(chdlr.sw.getId()).andReturn(0L).anyTimes();
chdlr.sw.setConnected(false);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Not in ready state
state.hsState = HandshakeState.START;
reset(chdlr.sw);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Switch is null
state.hsState = HandshakeState.READY;
chdlr.sw = null;
chdlr.channelDisconnected(null, null);
}
示例11: testChannelDisconnected
@Test
public void testChannelDisconnected() throws Exception {
OFChannelState state = new OFChannelState();
state.hsState = OFChannelState.HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(IOFSwitch.class);
// Switch is active
expect(chdlr.sw.getId()).andReturn(0L).anyTimes();
expect(chdlr.sw.getStringId()).andReturn("00:00:00:00:00:00:00:00")
.anyTimes();
chdlr.sw.cancelAllStatisticsReplies();
chdlr.sw.setConnected(false);
expect(chdlr.sw.isConnected()).andReturn(true);
controller.connectedSwitches.add(chdlr.sw);
controller.activeSwitches.put(0L, chdlr.sw);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Switch is connected but not active
reset(chdlr.sw);
expect(chdlr.sw.getId()).andReturn(0L).anyTimes();
chdlr.sw.setConnected(false);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Not in ready state
state.hsState = HandshakeState.START;
reset(chdlr.sw);
replay(chdlr.sw);
chdlr.channelDisconnected(null, null);
verify(chdlr.sw);
// Switch is null
state.hsState = HandshakeState.READY;
chdlr.sw = null;
chdlr.channelDisconnected(null, null);
}
示例12: testRoleNotSupportedError
@Test
public void testRoleNotSupportedError() throws Exception {
int xid = 424242;
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(IOFSwitch.class);
Channel ch = createMock(Channel.class);
// the error returned when role request message is not supported by sw
OFError msg = new OFError();
msg.setType(OFType.ERROR);
msg.setXid(xid);
msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
// the switch connection should get disconnected when the controller is
// in SLAVE mode and the switch does not support role-request messages
controller.role = Role.SLAVE;
setupPendingRoleRequest(chdlr.sw, xid, controller.role, 123456);
expect(chdlr.sw.getHARole()).andReturn(null);
chdlr.sw.setHARole(Role.SLAVE, false);
expect(chdlr.sw.getHARole()).andReturn(Role.SLAVE);
chdlr.sw.disconnectOutputStream();
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("activeSwitches must be empty",
controller.activeSwitches.isEmpty());
reset(ch, chdlr.sw);
// We are MASTER, the switch should be added to the list of active
// switches.
controller.role = Role.MASTER;
setupPendingRoleRequest(chdlr.sw, xid, controller.role, 123456);
expect(chdlr.sw.getHARole()).andReturn(null);
chdlr.sw.setHARole(controller.role, false);
setupSwitchForAddSwitch(chdlr.sw, 0L);
chdlr.sw.clearAllFlowMods();
expect(chdlr.sw.getHARole()).andReturn(null).anyTimes();
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertSame("activeSwitches must contain this switch",
chdlr.sw, controller.activeSwitches.get(0L));
reset(ch, chdlr.sw);
}
示例13: checkSwitchReady
protected void checkSwitchReady() {
if (!state.switchBindingDone) {
bindSwitchToDriver();
}
if (state.hsState == HandshakeState.FEATURES_REPLY &&
state.switchBindingDone) {
state.hsState = HandshakeState.READY;
// replay queued port status messages
for (OFMessage m : state.queuedOFMessages) {
try {
processOFMessage(m);
} catch (Exception e) {
log.error("Failed to process delayed OFMessage {} {}",
m, e.getCause());
}
}
state.queuedOFMessages.clear();
synchronized(roleChanger) {
// We need to keep track of all of the switches that are connected
// to the controller, in any role, so that we can later send the
// role request messages when the controller role changes.
// We need to be synchronized while doing this: we must not
// send a another role request to the connectedSwitches until
// we were able to add this new switch to connectedSwitches
// *and* send the current role to the new switch.
connectedSwitches.add(sw);
// Send a role request.
// This is a probe that we'll use to determine if the switch
// actually supports the role request message. If it does we'll
// get back a role reply message. If it doesn't we'll get back an
// OFError message.
// If role is MASTER we will promote switch to active
// list when we receive the switch's role reply messages
if (log.isDebugEnabled())
log.debug("This controller's role is {}, " +
"sending initial role request msg to {}",
role, sw);
Collection<IOFSwitch> swList = new ArrayList<IOFSwitch>(1);
swList.add(sw);
roleChanger.submitRequest(swList, role);
}
}
}
示例14: testErrorEPERM
@Test
public void testErrorEPERM() throws Exception {
// Check behavior with a BAD_REQUEST/EPERM error
// Ensure controller attempts to reset switch role.
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
OFError error = new OFError();
error.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
error.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
IOFSwitch sw = createMock(IOFSwitch.class);
chdlr.sw = sw;
controller.activeSwitches.put(1L, sw);
// prepare the switch and lock expectations
Lock lock = createNiceMock(Lock.class);
expect(sw.getListenerReadLock()).andReturn(lock).anyTimes();
expect(sw.isConnected()).andReturn(true).anyTimes();
expect(sw.getHARole()).andReturn(Role.MASTER).anyTimes();
expect(sw.getId()).andReturn(1L).anyTimes();
// Make sure controller attempts to reset switch master
expect(sw.getAttribute("supportsNxRole")).andReturn(true).anyTimes();
expect(sw.getNextTransactionId()).andReturn(0).anyTimes();
sw.write(EasyMock.<List<OFMessage>> anyObject(),
(FloodlightContext)anyObject());
// test
replay(sw, lock);
chdlr.processOFMessage(error);
DelayQueue<RoleChangeTask> pendingTasks =
controller.roleChanger.pendingTasks;
synchronized (pendingTasks) {
RoleChangeTask t;
while ((t = pendingTasks.peek()) == null ||
RoleChanger.RoleChangeTask.Type.TIMEOUT != t.type) {
pendingTasks.wait();
}
}
// Now there should be exactly one timeout task pending
assertEquals(1, pendingTasks.size());
}