@Test public void testGetNextMessageIdFailsIfMaxPeersIsReached() { int MAX_PEERS = 2; config.setLong(NetworkConfig.Keys.MAX_ACTIVE_PEERS, MAX_PEERS); InMemoryMessageIdProvider provider = new InMemoryMessageIdProvider(config); addPeers(provider, MAX_PEERS); assertThat( "Should not have been able to add more peers", provider.getNextMessageId(getPeerAddress(MAX_PEERS + 1)), is(-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);  }