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_whenConnectToSubset() {
        ClientTpcConfig config = new ClientTpcConfig();

        config.setConnectionCount(2);
        List<Integer> tpcPorts = asList(1, 2, 3);
        List<Integer> result = getTargetTpcPorts(tpcPorts, config);

        assertEquals(2, result.size());
        assertTrue(tpcPorts.containsAll(result));
    }