Class RPCServicePool

java.lang.Object
com.yahoo.messagebus.network.rpc.RPCServicePool

public class RPCServicePool extends Object
Class used to reuse services for the same address when sending messages over the rpc network.
Author:
Simon Thoresen Hult
  • Constructor Details

    • 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 Details

    • resolve

      public RPCServiceAddress resolve(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(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.