Package com.yahoo.messagebus.network.rpc
Class RPCTargetPool
java.lang.Object
com.yahoo.messagebus.network.rpc.RPCTargetPool
Class used to reuse targets for the same address when sending messages over the rpc network.
- Author:
- Haavard Pettersen
-
Constructor Summary
ConstructorDescriptionRPCTargetPool
(double expireSecs, int numTargetsPerSpec) Constructs a new instance of this class, and registers theSystemTimer
for detecting and closing connections that have expired according to the given parameter.RPCTargetPool
(com.yahoo.concurrent.Timer timer, double expireSecs, int numTargetsPerSpec) Constructs a new instance of this class, using the givenTimer
for detecting and closing connections that have expired according to the second paramter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
flushTargets
(boolean force) Closes all unused target connections.getTarget
(com.yahoo.jrt.Supervisor orb, RPCServiceAddress address) This method will return a target for the given address.int
size()
Returns the number of targets currently contained in this.
-
Constructor Details
-
RPCTargetPool
public RPCTargetPool(double expireSecs, int numTargetsPerSpec) Constructs a new instance of this class, and registers theSystemTimer
for detecting and closing connections that have expired according to the given parameter.- Parameters:
expireSecs
- The number of seconds until an idle connection is closed.
-
RPCTargetPool
public RPCTargetPool(com.yahoo.concurrent.Timer timer, double expireSecs, int numTargetsPerSpec) Constructs a new instance of this class, using the givenTimer
for detecting and closing connections that have expired according to the second paramter.- Parameters:
timer
- The timer to use for connection expiration.expireSecs
- The number of seconds until an idle connection is closed.
-
-
Method Details
-
flushTargets
public void flushTargets(boolean force) Closes all unused target connections. Unless the force argument is true, this method will allow a grace period for all connections after last use before it starts closing them. This allows the most recently used connections to stay open.- Parameters:
force
- Whether or not to force flush.
-
getTarget
This method will return a target for the given address. If a target does not currently exist for the given address, it will be created and added to the internal map. Each target is also reference counted so that an active target is never expired.- Parameters:
orb
- The supervisor to use to connect to the target.address
- The address to resolve to a target.- Returns:
- A target for the given address.
-
size
public int size()Returns the number of targets currently contained in this.- Returns:
- The size of the internal map.
-