Class WeightedTimeCostProvider

java.lang.Object
org.apache.hadoop.ipc.WeightedTimeCostProvider
All Implemented Interfaces:
CostProvider

public class WeightedTimeCostProvider extends Object implements CostProvider
A CostProvider that calculates the cost for an operation as a weighted sum of its processing time values (see ProcessingDetails). This can be used by specifying the CommonConfigurationKeys.IPC_COST_PROVIDER_KEY configuration key.

This allows for configuration of how heavily each of the operations within ProcessingDetails is weighted. By default, ProcessingDetails.Timing.LOCKFREE, ProcessingDetails.Timing.RESPONSE, and ProcessingDetails.Timing.HANDLER times have a weight of 1, ProcessingDetails.Timing.LOCKSHARED has a weight of 10, ProcessingDetails.Timing.LOCKEXCLUSIVE has a weight of 100, and others are ignored. These values can all be configured using the WEIGHT_CONFIG_PREFIX key, prefixed with the IPC namespace, and suffixed with the name of the timing measurement from ProcessingDetails (all lowercase). For example, to set the lock exclusive weight to be 1000, set:

   ipc.8020.cost-provider.impl=org.apache.hadoop.ipc.WeightedTimeCostProvider
   ipc.8020.weighted-cost.lockexclusive=1000
 
  • Field Details

    • WEIGHT_CONFIG_PREFIX

      public static final String WEIGHT_CONFIG_PREFIX
      The prefix used in configuration values specifying the weight to use when determining the cost of an operation. See the class Javadoc for more info.
      See Also:
  • Constructor Details

    • WeightedTimeCostProvider

      public WeightedTimeCostProvider()
  • Method Details

    • init

      public void init(String namespace, Configuration conf)
      Description copied from interface: CostProvider
      Initialize this provider using the given configuration, examining only ones which fall within the provided namespace.
      Specified by:
      init in interface CostProvider
      Parameters:
      namespace - The namespace to use when looking up configurations.
      conf - The configuration
    • getCost

      public long getCost(ProcessingDetails details)
      Calculates a weighted sum of the times stored on the provided processing details to be used as the cost in DecayRpcScheduler.
      Specified by:
      getCost in interface CostProvider
      Parameters:
      details - Processing details
      Returns:
      The weighted sum of the times. The returned unit is the same as the default unit used by the provided processing details.