@Test void shouldNotDropRandomlySelectedPeersWhenBelowMinimum() { assertThat(new TargetPeerRange(5, 10, 3).getRandomlySelectedPeersToDrop(2, 15)).isZero(); }
public int getRandomlySelectedPeersToDrop( final int currentRandomlySelectedPeerCount, final int currentTotalPeerCount) { final int totalPeersToDrop = getPeersToDrop(currentTotalPeerCount); if (totalPeersToDrop == 0) { return 0; } return currentRandomlySelectedPeerCount > minimumRandomlySelectedPeerCount ? Math.min( currentRandomlySelectedPeerCount - minimumRandomlySelectedPeerCount, totalPeersToDrop) : 0; }
TargetPeerRange { public int getRandomlySelectedPeersToDrop( final int currentRandomlySelectedPeerCount, final int currentTotalPeerCount) { final int totalPeersToDrop = getPeersToDrop(currentTotalPeerCount); if (totalPeersToDrop == 0) { return 0; } return currentRandomlySelectedPeerCount > minimumRandomlySelectedPeerCount ? Math.min( currentRandomlySelectedPeerCount - minimumRandomlySelectedPeerCount, totalPeersToDrop) : 0; } }
TargetPeerRange { public int getRandomlySelectedPeersToDrop( final int currentRandomlySelectedPeerCount, final int currentTotalPeerCount) { final int totalPeersToDrop = getPeersToDrop(currentTotalPeerCount); if (totalPeersToDrop == 0) { return 0; } return currentRandomlySelectedPeerCount > minimumRandomlySelectedPeerCount ? Math.min( currentRandomlySelectedPeerCount - minimumRandomlySelectedPeerCount, totalPeersToDrop) : 0; } TargetPeerRange(
      final int addPeersWhenLessThan,
      final int dropPeersWhenGreaterThan,
      final int minimumRandomlySelectedPeerCount); }
TargetPeerRange { public int getRandomlySelectedPeersToDrop( final int currentRandomlySelectedPeerCount, final int currentTotalPeerCount) { final int totalPeersToDrop = getPeersToDrop(currentTotalPeerCount); if (totalPeersToDrop == 0) { return 0; } return currentRandomlySelectedPeerCount > minimumRandomlySelectedPeerCount ? Math.min( currentRandomlySelectedPeerCount - minimumRandomlySelectedPeerCount, totalPeersToDrop) : 0; } TargetPeerRange(
      final int addPeersWhenLessThan,
      final int dropPeersWhenGreaterThan,
      final int minimumRandomlySelectedPeerCount); int getPeersToAdd(final int currentPeerCount); int getPeersToDrop(final int currentPeerCount); int getRandomlySelectedPeersToAdd(final int currentRandomlySelectedPeerCount); int getRandomlySelectedPeersToDrop(
      final int currentRandomlySelectedPeerCount, final int currentTotalPeerCount); }
TargetPeerRange { public int getRandomlySelectedPeersToDrop( final int currentRandomlySelectedPeerCount, final int currentTotalPeerCount) { final int totalPeersToDrop = getPeersToDrop(currentTotalPeerCount); if (totalPeersToDrop == 0) { return 0; } return currentRandomlySelectedPeerCount > minimumRandomlySelectedPeerCount ? Math.min( currentRandomlySelectedPeerCount - minimumRandomlySelectedPeerCount, totalPeersToDrop) : 0; } TargetPeerRange(
      final int addPeersWhenLessThan,
      final int dropPeersWhenGreaterThan,
      final int minimumRandomlySelectedPeerCount); int getPeersToAdd(final int currentPeerCount); int getPeersToDrop(final int currentPeerCount); int getRandomlySelectedPeersToAdd(final int currentRandomlySelectedPeerCount); int getRandomlySelectedPeersToDrop(
      final int currentRandomlySelectedPeerCount, final int currentTotalPeerCount);  }