Package com.yahoo.messagebus.network.rpc
Class RPCServicePool
java.lang.Object
com.yahoo.messagebus.network.rpc.RPCServicePool
Class used to reuse services for the same address when sending messages over the rpc network.
- Author:
- Simon Thoresen Hult
-
Constructor Summary
ConstructorDescriptionRPCServicePool
(RPCNetwork net, int maxSize) Create a new service pool for the given network. -
Method Summary
Modifier and TypeMethodDescriptionint
getSize()
Returns the number of services available in the pool.boolean
hasService
(String pattern) Returns whether or not there is a service available in the pool the corresponds to the given pattern.Returns the RPCServiceAddress that corresponds to a given pattern.
-
Constructor Details
-
RPCServicePool
Create a new service pool for the given network.- Parameters:
net
- The underlying RPC network.maxSize
- The max number of services to cache.
-
-
Method Details
-
resolve
Returns the RPCServiceAddress that corresponds to a given pattern. This reuses the RPCService object for matching pattern so that load balancing is possible on the network level.- Parameters:
pattern
- The pattern for the service we require.- Returns:
- A service address for the given pattern.
-
getSize
public int getSize()Returns the number of services available in the pool. This number will never exceed the limit given at construction time.- Returns:
- The current size of this pool.
-
hasService
Returns whether or not there is a service available in the pool the corresponds to the given pattern.- Parameters:
pattern
- The pattern to check for.- Returns:
- True if a corresponding service is in the pool.
-