@Test public void testInitialMoveToMasterWithRole() throws Exception { int xid = 42; MockStorageSourceConfig cfg = new MockStorageSourceConfig(); cfg.dpid = HexString.toHexString(featuresReply.getDatapathId()); cfg.isPresent = false; doMoveToWaitInitialRole(cfg); assertEquals(OFChannelHandler.ChannelState.WAIT_INITIAL_ROLE, handler.getStateForTesting()); setupSwitchSendRoleRequestAndVerify(null, xid, Role.MASTER); assertEquals(OFChannelHandler.ChannelState.WAIT_INITIAL_ROLE, handler.getStateForTesting()); reset(sw); expect(sw.inputThrottled(anyObject(OFMessage.class))) .andReturn(false).anyTimes(); sw.setAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, true); expectLastCall().once(); sw.setHARole(Role.MASTER); expectLastCall().once(); replay(sw); verify(controller); reset(controller); controller.switchActivated(sw); expectLastCall().once(); OFMessage reply = getRoleReply(xid, Role.MASTER); sendMessageToHandlerNoControllerReset(Collections.singletonList(reply)); assertEquals(OFChannelHandler.ChannelState.MASTER, handler.getStateForTesting()); }
ChannelState getStateForTesting() { return state; }
OFChannelHandler extends IdleStateAwareChannelHandler { ChannelState getStateForTesting() { return state; } }
OFChannelHandler extends IdleStateAwareChannelHandler { ChannelState getStateForTesting() { return state; } OFChannelHandler(Controller controller); }
OFChannelHandler extends IdleStateAwareChannelHandler { ChannelState getStateForTesting() { return state; } OFChannelHandler(Controller controller); @Override @LogMessageDoc(message="New switch connection from {ip address}", explanation="A new switch has connected from the " + "specified IP address") void channelConnected(ChannelHandlerContext ctx,
                                 ChannelStateEvent e); @Override @LogMessageDoc(message="Disconnected switch {switch information}", explanation="The specified switch has disconnected.") void channelDisconnected(ChannelHandlerContext ctx,
                                    ChannelStateEvent e); @Override @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch} due to read timeout", explanation="The connected switch has failed to send any " + "messages or respond to echo requests", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch}: failed to " + "complete handshake", explanation="The switch did not respond correctly " + "to handshake messages", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch} due to IO Error: {}", explanation="There was an error communicating with the switch", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch} due to switch " + "state error: {error}", explanation="The switch sent an unexpected message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch} due to " + "message parse failure", explanation="Could not parse a message from the switch", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Terminating controller due to storage exception", explanation=Controller.ERROR_DATABASE, recommendation=LogMessageDoc.CHECK_CONTROLLER), @LogMessageDoc(level="ERROR", message="Could not process message: queue full", explanation="OpenFlow messages are arriving faster than " + " the controller can process them.", recommendation=LogMessageDoc.CHECK_CONTROLLER), @LogMessageDoc(level="ERROR", message="Error while processing message " + "from switch {switch} {cause}", explanation="An error occurred processing the switch message", recommendation=LogMessageDoc.GENERIC_ACTION) }) void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e); @Override void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e); @Override void messageReceived(ChannelHandlerContext ctx, MessageEvent e); static String getErrorString(OFError error); }
OFChannelHandler extends IdleStateAwareChannelHandler { ChannelState getStateForTesting() { return state; } OFChannelHandler(Controller controller); @Override @LogMessageDoc(message="New switch connection from {ip address}", explanation="A new switch has connected from the " + "specified IP address") void channelConnected(ChannelHandlerContext ctx,
                                 ChannelStateEvent e); @Override @LogMessageDoc(message="Disconnected switch {switch information}", explanation="The specified switch has disconnected.") void channelDisconnected(ChannelHandlerContext ctx,
                                    ChannelStateEvent e); @Override @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch} due to read timeout", explanation="The connected switch has failed to send any " + "messages or respond to echo requests", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch}: failed to " + "complete handshake", explanation="The switch did not respond correctly " + "to handshake messages", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch} due to IO Error: {}", explanation="There was an error communicating with the switch", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch} due to switch " + "state error: {error}", explanation="The switch sent an unexpected message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Disconnecting switch {switch} due to " + "message parse failure", explanation="Could not parse a message from the switch", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="ERROR", message="Terminating controller due to storage exception", explanation=Controller.ERROR_DATABASE, recommendation=LogMessageDoc.CHECK_CONTROLLER), @LogMessageDoc(level="ERROR", message="Could not process message: queue full", explanation="OpenFlow messages are arriving faster than " + " the controller can process them.", recommendation=LogMessageDoc.CHECK_CONTROLLER), @LogMessageDoc(level="ERROR", message="Error while processing message " + "from switch {switch} {cause}", explanation="An error occurred processing the switch message", recommendation=LogMessageDoc.GENERIC_ACTION) }) void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e); @Override void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e); @Override void messageReceived(ChannelHandlerContext ctx, MessageEvent e); static String getErrorString(OFError error);  }