@Test public void testGetNextMessageIdIfMaxPeersIsReachedWithStaleEntry() throws InterruptedException { int MAX_PEERS = 2; int MAX_PEER_INACTIVITY_PERIOD = 1; config.setLong(NetworkConfig.Keys.MAX_ACTIVE_PEERS, MAX_PEERS); config.setLong(NetworkConfig.Keys.MAX_PEER_INACTIVITY_PERIOD, MAX_PEER_INACTIVITY_PERIOD); InMemoryMessageIdProvider provider = new InMemoryMessageIdProvider(config); addPeers(provider, MAX_PEERS); Thread.sleep(MAX_PEER_INACTIVITY_PERIOD * 1200); assertThat(provider.getNextMessageId(getPeerAddress(MAX_PEERS + 1)), is(not(-1))); }
@Override public int getNextMessageId(final InetSocketAddress destination) { MessageIdTracker tracker = getTracker(destination); if (tracker == null) { return Message.NONE; } else { return tracker.getNextMessageId(); } }
InMemoryMessageIdProvider implements MessageIdProvider { @Override public int getNextMessageId(final InetSocketAddress destination) { MessageIdTracker tracker = getTracker(destination); if (tracker == null) { return Message.NONE; } else { return tracker.getNextMessageId(); } } }
InMemoryMessageIdProvider implements MessageIdProvider { @Override public int getNextMessageId(final InetSocketAddress destination) { MessageIdTracker tracker = getTracker(destination); if (tracker == null) { return Message.NONE; } else { return tracker.getNextMessageId(); } } InMemoryMessageIdProvider(final NetworkConfig config); }
InMemoryMessageIdProvider implements MessageIdProvider { @Override public int getNextMessageId(final InetSocketAddress destination) { MessageIdTracker tracker = getTracker(destination); if (tracker == null) { return Message.NONE; } else { return tracker.getNextMessageId(); } } InMemoryMessageIdProvider(final NetworkConfig config); @Override int getNextMessageId(final InetSocketAddress destination); }
InMemoryMessageIdProvider implements MessageIdProvider { @Override public int getNextMessageId(final InetSocketAddress destination) { MessageIdTracker tracker = getTracker(destination); if (tracker == null) { return Message.NONE; } else { return tracker.getNextMessageId(); } } InMemoryMessageIdProvider(final NetworkConfig config); @Override int getNextMessageId(final InetSocketAddress destination);  }