Package com.yahoo.messagebus.network.rpc
Class RPCTargetPool
- java.lang.Object
-
- com.yahoo.messagebus.network.rpc.RPCTargetPool
-
public class RPCTargetPool extends java.lang.Object
Class used to reuse targets for the same address when sending messages over the rpc network.- Author:
- Haavard Pettersen
-
-
Constructor Summary
Constructors Constructor Description 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.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flushTargets(boolean force)
Closes all unused target connections.RPCTarget
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 Detail
-
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 Detail
-
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
public RPCTarget getTarget(com.yahoo.jrt.Supervisor orb, RPCServiceAddress address)
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.
-
-