Jprotobuf-rpc-socket icon indicating copy to clipboard operation
Jprotobuf-rpc-socket copied to clipboard

minEvictableIdleTimeMillis is useless with default timeBetweenEvictionRunsMillis

Open ZiheLiu opened this issue 2 years ago • 0 comments

As for the connection pool, the idle object after minEvictableIdleTimeMillis is evicted in Evictor thread. Evictor thread is started only when timeBetweenEvictionRunsMillis > 0, and default timeBetweenEvictionRunsMillis is -1.

However, RpcClientOptions doesn't provide API to set timeBetweenEvictionRunsMillis. Could we provide RpcClientOptions::timeBetweenEvictionRunsMillis?

    public ChannelPool(RpcClient rpcClient, String host, int port) {
        this.clientConfig = rpcClient.getRpcClientOptions();
        objectFactory = new ChannelPoolObjectFactory(rpcClient, host, port);
        
        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        config.setJmxEnabled(clientConfig.isJmxEnabled());
        pool = new GenericObjectPool<Connection>(objectFactory, config);
        pool.setMaxIdle(clientConfig.getMaxIdleSize());
        pool.setMaxTotal(clientConfig.getThreadPoolSize());
        pool.setMaxWaitMillis(clientConfig.getMaxWait());
        pool.setMinIdle(clientConfig.getMinIdleSize());
        pool.setMinEvictableIdleTimeMillis(clientConfig.getMinEvictableIdleTime());
        pool.setTestOnBorrow(clientConfig.isTestOnBorrow());
        pool.setTestOnReturn(clientConfig.isTestOnReturn());
        pool.setLifo(clientConfig.isLifo());
        
    }

ZiheLiu avatar Apr 25 '22 02:04 ZiheLiu