static List<Integer> getTargetTpcPorts(List<Integer> tpcPorts, ClientTpcConfig tpcConfig) {
        List<Integer> targetTpcPorts;
        int tpcConnectionCount = tpcConfig.getConnectionCount();
        if (tpcConnectionCount == 0 || tpcConnectionCount >= tpcPorts.size()) {
            // zero means connect to all.
            targetTpcPorts = tpcPorts;
        } else {
            // we make a copy of the tpc ports because items are removed.
            List<Integer> tpcPortsCopy = new LinkedList<>(tpcPorts);
            targetTpcPorts = new ArrayList<>(tpcConnectionCount);
            ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
            for (int k = 0; k < tpcConnectionCount; k++) {
                int index = threadLocalRandom.nextInt(tpcPortsCopy.size());
                targetTpcPorts.add(tpcPortsCopy.remove(index));
            }
        }
        return targetTpcPorts;
    }
@Test
    public void testGetTargetTpcPorts_whenConnectToAll() {
        ClientTpcConfig config = new ClientTpcConfig();
        List<Integer> tpcPorts = asList(1, 2, 3);

        // when larger than the number of tpc ports, return the full set.
        config.setConnectionCount(tpcPorts.size() + 1);
        assertEquals(tpcPorts, getTargetTpcPorts(tpcPorts, config));

        // when equal than the number of tpc ports, return the full set.
        config.setConnectionCount(tpcPorts.size());
        assertEquals(tpcPorts, getTargetTpcPorts(tpcPorts, config));

        // When 0, return the full set.
        config.setConnectionCount(0);
        assertEquals(tpcPorts, getTargetTpcPorts(tpcPorts, config));
    }