io.milvus.pool

## Class ClientPool<C,T>

- java.lang.Object
- - io.milvus.pool.ClientPool<C,T>

Direct Known Subclasses:
  MilvusClientV1Pool, MilvusClientV2Pool

    public class ClientPool<C,T>
    extends java.lang.Object

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `clear()` Release/disconnect idle clients of all key groups.
`void` `clear(java.lang.String key)` Release/disconnect idle clients of a key group.
`void` `close()` Release/disconnect all clients of all key groups, close the pool.
`int` `getActiveClientNumber(java.lang.String key)` Return the number of active clients of a key group
`T` `getClient(java.lang.String key)` Get a client object which is idle from the pool.
`int` `getIdleClientNumber(java.lang.String key)` Return the number of idle clients of a key group
`int` `getTotalActiveClientNumber()` Return the number of active clients of all key group
`int` `getTotalIdleClientNumber()` Return the number of idle clients of all key group
`void` `returnClient(java.lang.String key, T grpcClient)` Return a client object.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getClient

    public T getClient(java.lang.String key)

Get a client object which is idle from the pool. Once the client is hold by the caller, it will be marked as active state and cannot be fetched by other caller. If the number of clients hits the MaxTotalPerKey value, this method will be blocked for MaxBlockWaitDuration. If no idle client available after MaxBlockWaitDuration, this method will return a null object to caller.

Parameters:
  `key` - the key of a group where the client belong
Returns:
  MilvusClient or MilvusClientV2

#### returnClient

    public void returnClient(java.lang.String key,
                             T grpcClient)

Return a client object. Once a client is returned, it becomes idle state and wait the next caller. The caller should ensure the client is returned. Otherwise, the client will keep in active state and cannot be used by the next caller. Throw exceptions if the key doesn't exist or the client is not belong to this key group.

Parameters:
  `key` - the key of a group where the client belong
  `grpcClient` - the client object to return

#### close

    public void close()

Release/disconnect all clients of all key groups, close the pool.

#### clear

    public void clear()

Release/disconnect idle clients of all key groups.

#### clear

    public void clear(java.lang.String key)

Release/disconnect idle clients of a key group.

Parameters:
  `key` - the key of a group

#### getIdleClientNumber

    public int getIdleClientNumber(java.lang.String key)

Return the number of idle clients of a key group

Parameters:
  `key` - the key of a group

#### getActiveClientNumber

    public int getActiveClientNumber(java.lang.String key)

Return the number of active clients of a key group

Parameters:
  `key` - the key of a group

#### getTotalIdleClientNumber

    public int getTotalIdleClientNumber()

Return the number of idle clients of all key group

#### getTotalActiveClientNumber

    public int getTotalActiveClientNumber()

Return the number of active clients of all key group