Package com.yahoo.messagebus.network.rpc
Class RPCServicePool
- java.lang.Object
-
- com.yahoo.messagebus.network.rpc.RPCServicePool
-
public class RPCServicePool extends java.lang.Object
Class used to reuse services for the same address when sending messages over the rpc network.- Author:
- Simon Thoresen Hult
-
-
Constructor Summary
Constructors Constructor Description RPCServicePool(RPCNetwork net, int maxSize)
Create a new service pool for the given network.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getSize()
Returns the number of services available in the pool.boolean
hasService(java.lang.String pattern)
Returns whether or not there is a service available in the pool the corresponds to the given pattern.RPCServiceAddress
resolve(java.lang.String pattern)
Returns the RPCServiceAddress that corresponds to a given pattern.
-
-
-
Constructor Detail
-
RPCServicePool
public RPCServicePool(RPCNetwork net, int maxSize)
Create a new service pool for the given network.- Parameters:
net
- The underlying RPC network.maxSize
- The max number of services to cache.
-
-
Method Detail
-
resolve
public RPCServiceAddress resolve(java.lang.String pattern)
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
public boolean hasService(java.lang.String pattern)
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.
-
-