@Test public void testVerifyRoleReplyReceived() { LinkedList<OFSwitchImpl> switches = new LinkedList<OFSwitchImpl>(); OFSwitchImpl sw1 = EasyMock.createMock(OFSwitchImpl.class); expect(sw1.checkFirstPendingRoleRequestCookie(123456)) .andReturn(false).once(); switches.add(sw1); OFSwitchImpl sw2 = EasyMock.createMock(OFSwitchImpl.class); expect(sw2.checkFirstPendingRoleRequestCookie(123456)) .andReturn(true).once(); Channel channel2 = createMock(Channel.class); expect(sw2.getChannel()).andReturn(channel2); expect(channel2.close()).andReturn(null); switches.add(sw2); replay(sw1, sw2); roleChanger.verifyRoleReplyReceived(switches, 123456); verify(sw1, sw2); assertEquals(2, switches.size()); }
@LogMessageDoc(level="WARN", message="Timeout while waiting for role reply from switch {switch}." + " Disconnecting", explanation="Timed out waiting for the switch to respond to " + "a request to change the HA role.", recommendation=LogMessageDoc.CHECK_SWITCH) protected void verifyRoleReplyReceived(Collection<OFSwitchImpl> switches, long cookie) { for (OFSwitchImpl sw: switches) { if (sw.checkFirstPendingRoleRequestCookie(cookie)) { sw.getChannel().close(); log.warn("Timeout while waiting for role reply from switch {}." + " Disconnecting", sw); } } }
RoleChanger { @LogMessageDoc(level="WARN", message="Timeout while waiting for role reply from switch {switch}." + " Disconnecting", explanation="Timed out waiting for the switch to respond to " + "a request to change the HA role.", recommendation=LogMessageDoc.CHECK_SWITCH) protected void verifyRoleReplyReceived(Collection<OFSwitchImpl> switches, long cookie) { for (OFSwitchImpl sw: switches) { if (sw.checkFirstPendingRoleRequestCookie(cookie)) { sw.getChannel().close(); log.warn("Timeout while waiting for role reply from switch {}." + " Disconnecting", sw); } } } }
RoleChanger { @LogMessageDoc(level="WARN", message="Timeout while waiting for role reply from switch {switch}." + " Disconnecting", explanation="Timed out waiting for the switch to respond to " + "a request to change the HA role.", recommendation=LogMessageDoc.CHECK_SWITCH) protected void verifyRoleReplyReceived(Collection<OFSwitchImpl> switches, long cookie) { for (OFSwitchImpl sw: switches) { if (sw.checkFirstPendingRoleRequestCookie(cookie)) { sw.getChannel().close(); log.warn("Timeout while waiting for role reply from switch {}." + " Disconnecting", sw); } } } RoleChanger(); }
RoleChanger { @LogMessageDoc(level="WARN", message="Timeout while waiting for role reply from switch {switch}." + " Disconnecting", explanation="Timed out waiting for the switch to respond to " + "a request to change the HA role.", recommendation=LogMessageDoc.CHECK_SWITCH) protected void verifyRoleReplyReceived(Collection<OFSwitchImpl> switches, long cookie) { for (OFSwitchImpl sw: switches) { if (sw.checkFirstPendingRoleRequestCookie(cookie)) { sw.getChannel().close(); log.warn("Timeout while waiting for role reply from switch {}." + " Disconnecting", sw); } } } RoleChanger(); synchronized void submitRequest(Collection<OFSwitchImpl> switches, Role role); }
RoleChanger { @LogMessageDoc(level="WARN", message="Timeout while waiting for role reply from switch {switch}." + " Disconnecting", explanation="Timed out waiting for the switch to respond to " + "a request to change the HA role.", recommendation=LogMessageDoc.CHECK_SWITCH) protected void verifyRoleReplyReceived(Collection<OFSwitchImpl> switches, long cookie) { for (OFSwitchImpl sw: switches) { if (sw.checkFirstPendingRoleRequestCookie(cookie)) { sw.getChannel().close(); log.warn("Timeout while waiting for role reply from switch {}." + " Disconnecting", sw); } } } RoleChanger(); synchronized void submitRequest(Collection<OFSwitchImpl> switches, Role role);  }