public ControllerCounters(IDebugCounterService debugCounters) { debugCounters.registerModule(prefix); debugCounters.registerModule(OFConnectionCounters.COUNTER_MODULE); dispatchMessageWhileStandby = debugCounters.registerCounter(prefix, "dispatch-message-while-slave", "Number of times an OF message was received " + "and supposed to be dispatched but the " + "controller was in SLAVE role and the message " + "was not dispatched"); // does this cnt make sense? more specific?? per type? // count stops? dispatchMessage = debugCounters.registerCounter(prefix, "dispatch-message", "Number of times an OF message was dispatched " + "to registered modules"); // TODO: FIXME // Need a better way to handle these packetParsingError = debugCounters.registerCounter(prefix, "packet-parsing-error", "Number of times the packet parsing " + "encountered an error", MetaData.ERROR); packetIn = debugCounters.registerCounter(prefix, "packet-in", "Number of packet_in's seen"); }
@Override @Before public void setUp() throws Exception { dc = new DebugCounterServiceImpl(); dc.registerModule(OFConnectionCounters.COUNTER_MODULE); auxId = OFAuxId.of(5); dpId = DatapathId.of(5); counters = new OFConnectionCounters(dc, dpId, auxId); }
@Before public void setUp() throws Exception { switchManager = createMock(IOFSwitchManager.class); connectionListener = createMock(IOFConnectionListener.class); newConnectionListener = createMock(INewOFConnectionListener.class); newConnection = new Capture<IOFConnectionBackend>(); newFeaturesReply = new Capture<OFFeaturesReply>(); ctx = createMock(ChannelHandlerContext.class); channelStateEvent = createMock(ChannelStateEvent.class); channel = createMock(Channel.class); timer = new HashedWheelTimer(); messageEvent = createMock(MessageEvent.class); exceptionEventCapture = new Capture<ExceptionEvent>(CaptureType.ALL); pipeline = createMock(ChannelPipeline.class); writeCapture = new Capture<List<OFMessage>>(CaptureType.ALL); seenXids = null; // TODO: should mock IDebugCounterService and make sure // the expected counters are updated. debugCounterService = new DebugCounterServiceImpl(); debugCounterService.registerModule(OFConnectionCounters.COUNTER_MODULE); SwitchManagerCounters counters = new SwitchManagerCounters(debugCounterService); expect(switchManager.getCounters()).andReturn(counters).anyTimes(); replay(switchManager); handler = new OFChannelHandler(switchManager, newConnectionListener, pipeline, debugCounterService, timer); verify(switchManager); reset(switchManager); resetChannel(); // replay controller. Reset it if you need more specific behavior replay(switchManager); // Mock ctx and channelStateEvent expect(ctx.getChannel()).andReturn(channel).anyTimes(); expect(channelStateEvent.getChannel()).andReturn(channel).anyTimes(); replay(ctx, channelStateEvent); /* Setup an exception event capture on the channel. Right now * we only expect exception events to be send up the channel. * However, it's easy to extend to other events if we need it */ pipeline.sendUpstream(capture(exceptionEventCapture)); expectLastCall().anyTimes(); expect(pipeline.get(OFMessageDecoder.class)).andReturn(new OFMessageDecoder()).anyTimes(); replay(pipeline); }
@Before public void setUp() throws Exception { setUpFeaturesReply(); switchManager = createMock(IOFSwitchManager.class); connectionListener = createMock(IOFConnectionListener.class); newConnectionListener = createMock(INewOFConnectionListener.class); newConnection = new Capture<IOFConnectionBackend>(); newFeaturesReply = new Capture<OFFeaturesReply>(); ctx = createMock(ChannelHandlerContext.class); channelStateEvent = createMock(ChannelStateEvent.class); channel = createMock(Channel.class); timer = new HashedWheelTimer(); messageEvent = createMock(MessageEvent.class); exceptionEventCapture = new Capture<ExceptionEvent>(CaptureType.ALL); pipeline = createMock(ChannelPipeline.class); writeCapture = new Capture<List<OFMessage>>(CaptureType.ALL); seenXids = null; // TODO: should mock IDebugCounterService and make sure // the expected counters are updated. debugCounterService = new DebugCounterServiceImpl(); debugCounterService.registerModule(OFConnectionCounters.COUNTER_MODULE); SwitchManagerCounters counters = new SwitchManagerCounters(debugCounterService); expect(switchManager.getCounters()).andReturn(counters).anyTimes(); replay(switchManager); handler = new OFChannelHandler(switchManager, newConnectionListener, pipeline, debugCounterService, /* 62 is OF versions 1.0 thru 1.4 in decimal */ timer, Collections.singletonList(U32.of(62)), OFFactories.getFactory(OFVersion.OF_14)); verify(switchManager); reset(switchManager); resetChannel(); // replay controller. Reset it if you need more specific behavior replay(switchManager); // Mock ctx and channelStateEvent expect(ctx.getChannel()).andReturn(channel).anyTimes(); expect(channelStateEvent.getChannel()).andReturn(channel).anyTimes(); replay(ctx, channelStateEvent); /* Setup an exception event capture on the channel. Right now * we only expect exception events to be send up the channel. * However, it's easy to extend to other events if we need it */ pipeline.sendUpstream(capture(exceptionEventCapture)); expectLastCall().anyTimes(); expect(pipeline.get(OFMessageDecoder.class)).andReturn(new OFMessageDecoder()).anyTimes(); replay(pipeline); }
@Before public void setUp() throws Exception { setUpFeaturesReply(); switchManager = createMock(IOFSwitchManager.class); connectionListener = createMock(IOFConnectionListener.class); newConnectionListener = createMock(INewOFConnectionListener.class); newConnection = new Capture<IOFConnectionBackend>(); newFeaturesReply = new Capture<OFFeaturesReply>(); ctx = createMock(ChannelHandlerContext.class); channelStateEvent = createMock(ChannelStateEvent.class); channel = createMock(Channel.class); timer = new HashedWheelTimer(); messageEvent = createMock(MessageEvent.class); exceptionEventCapture = new Capture<ExceptionEvent>(CaptureType.ALL); pipeline = createMock(ChannelPipeline.class); writeCapture = new Capture<List<OFMessage>>(CaptureType.ALL); seenXids = null; // TODO: should mock IDebugCounterService and make sure // the expected counters are updated. debugCounterService = new DebugCounterServiceImpl(); debugCounterService.registerModule(OFConnectionCounters.COUNTER_MODULE); SwitchManagerCounters counters = new SwitchManagerCounters(debugCounterService); expect(switchManager.getCounters()).andReturn(counters).anyTimes(); replay(switchManager); handler = new OFChannelHandler(switchManager, newConnectionListener, pipeline, debugCounterService, timer, Collections.singletonList(U32.of(0)), OFFactories.getFactory(OFVersion.OF_14)); verify(switchManager); reset(switchManager); resetChannel(); // replay controller. Reset it if you need more specific behavior replay(switchManager); // Mock ctx and channelStateEvent expect(ctx.getChannel()).andReturn(channel).anyTimes(); expect(channelStateEvent.getChannel()).andReturn(channel).anyTimes(); replay(ctx, channelStateEvent); /* Setup an exception event capture on the channel. Right now * we only expect exception events to be send up the channel. * However, it's easy to extend to other events if we need it */ pipeline.sendUpstream(capture(exceptionEventCapture)); expectLastCall().anyTimes(); expect(pipeline.get(OFMessageDecoder.class)).andReturn(new OFMessageDecoder()).anyTimes(); replay(pipeline); }