public static JedisCluster newJedisCluster(String hostsAndPorts, String password,
            long timeoutMs) {
    """
	Creates a new {@link JedisCluster}.
	
	@param hostsAndPorts
	format {@code host1:port1,host2:port2...}
	@param password
	@param timeoutMs
	@return
    """
        final int maxTotal = Runtime.getRuntime().availableProcessors();
        final int maxIdle = maxTotal / 2;

        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(maxTotal);
        poolConfig.setMinIdle(1);
        poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
        poolConfig.setMaxWaitMillis(timeoutMs + 1000);
        // poolConfig.setTestOnBorrow(true);
        poolConfig.setTestWhileIdle(true);

        Set<HostAndPort> clusterNodes = new HashSet<>();
        String[] hapList = hostsAndPorts.split("[,;\\s]+");
        for (String hostAndPort : hapList) {
            String[] tokens = hostAndPort.split(":");
            String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
            int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
            clusterNodes.add(new HostAndPort(host, port));
        }

        JedisCluster jedisCluster = new JedisCluster(clusterNodes, (int) timeoutMs, (int) timeoutMs,
                DEFAULT_MAX_ATTEMPTS, password, poolConfig);
        return jedisCluster;
    }
public static JedisCluster newJedisCluster(String hostsAndPorts, String password,
            long timeoutMs) {
        final int maxTotal = Runtime.getRuntime().availableProcessors();
        final int maxIdle = maxTotal / 2;

        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(maxTotal);
        poolConfig.setMinIdle(1);
        poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
        poolConfig.setMaxWaitMillis(timeoutMs + 1000);
        // poolConfig.setTestOnBorrow(true);
        poolConfig.setTestWhileIdle(true);

        Set<HostAndPort> clusterNodes = new HashSet<>();
        String[] hapList = hostsAndPorts.split("[,;\\s]+");
        for (String hostAndPort : hapList) {
            String[] tokens = hostAndPort.split(":");
            String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
            int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
            clusterNodes.add(new HostAndPort(host, port));
        }

        JedisCluster jedisCluster = new JedisCluster(clusterNodes, (int) timeoutMs, (int) timeoutMs,
                DEFAULT_MAX_ATTEMPTS, password, poolConfig);
        return jedisCluster;
    }
public static JedisCluster newJedisCluster ( String hostsAndPorts , String password , long timeoutMs ) { final int maxTotal = Runtime . getRuntime ( ) . availableProcessors ( ) ; final int maxIdle = maxTotal / 2 ; JedisPoolConfig poolConfig = new JedisPoolConfig ( ) ; poolConfig . setMaxTotal ( maxTotal ) ; poolConfig . setMinIdle ( 1 ) ; poolConfig . setMaxIdle ( maxIdle > 0 ? maxIdle : 1 ) ; poolConfig . setMaxWaitMillis ( timeoutMs + 1000 ) ; // poolConfig.setTestOnBorrow(true); poolConfig . setTestWhileIdle ( true ) ; Set < HostAndPort > clusterNodes = new HashSet <> ( ) ; String [ ] hapList = hostsAndPorts . split ( "[,;\\s]+" ) ; for ( String hostAndPort : hapList ) { String [ ] tokens = hostAndPort . split ( ":" ) ; String host = tokens . length > 0 ? tokens [ 0 ] : Protocol . DEFAULT_HOST ; int port = tokens . length > 1 ? Integer . parseInt ( tokens [ 1 ] ) : Protocol . DEFAULT_PORT ; clusterNodes . add ( new HostAndPort ( host , port ) ) ; } JedisCluster jedisCluster = new JedisCluster ( clusterNodes , ( int ) timeoutMs , ( int ) timeoutMs , DEFAULT_MAX_ATTEMPTS , password , poolConfig ) ; return jedisCluster ; }
Creates a new {@link JedisCluster}.

@param hostsAndPorts
format {@code host1:port1,host2:port2...}
@param password
@param timeoutMs
@return
Creates a new { @link JedisCluster } .