Package io.milvus.pool
Class ClientPool<C,T>
java.lang.Object
io.milvus.pool.ClientPool<C,T>
- Direct Known Subclasses:
MilvusClientV1Pool,MilvusClientV2Pool
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedClientPool(PoolConfig config, PoolClientFactory clientFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Release/disconnect idle clients of all key groups.voidRelease/disconnect idle clients of a key group.voidclose()Release/disconnect all clients of all key groups, close the pool.intReturn the number of active clients of a key groupGet a client object which is idle from the pool.intReturn the number of idle clients of a key groupintReturn the number of active clients of all key groupintReturn the number of idle clients of all key groupvoidreturnClient(String key, T grpcClient) Return a client object.
-
Field Details
-
clientPool
-
config
-
clientFactory
-
-
Constructor Details
-
ClientPool
protected ClientPool() -
ClientPool
-
-
Method Details
-
getClient
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
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 belonggrpcClient- 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
Release/disconnect idle clients of a key group.- Parameters:
key- the key of a group
-
getIdleClientNumber
Return the number of idle clients of a key group- Parameters:
key- the key of a group
-
getActiveClientNumber
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
-