AbstractRouterRpcFairnessPolicyController (Apache Hadoop HDFS-RBF 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.federation.fairness, class: AbstractRouterRpcFairnessPolicyController

Package org.apache.hadoop.hdfs.server.federation.fairness

# Class AbstractRouterRpcFairnessPolicyController

java.lang.Object
org.apache.hadoop.hdfs.server.federation.fairness.AbstractRouterRpcFairnessPolicyController

All Implemented Interfaces:
  `RouterRpcFairnessPolicyController`

Direct Known Subclasses:
  `ProportionRouterRpcFairnessPolicyController`, `RouterAsyncRpcFairnessPolicyController`, `StaticRouterRpcFairnessPolicyController`

public class AbstractRouterRpcFairnessPolicyController extends Object implements RouterRpcFairnessPolicyController
Base fairness policy that implements @RouterRpcFairnessPolicyController. Internally a map of nameservice to Semaphore is used to control permits.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractRouterRpcFairnessPolicyController()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `acquirePermit(String nsId)`
  Request permission for a specific name service to continue the call and connect to downstream name node.
  `boolean`
  `contains(String nsId)`
  Determine whether ns has registered handlers.
  `String`
  `getAvailableHandlerOnPerNs()`
  Returns the JSON string of the available handler for each name service.
  `int`
  `getAvailablePermits(String nsId)`
  Returns the available handler for each name service.
  `void`
  `init(org.apache.hadoop.conf.Configuration conf)`
  `protected void`
  `insertNameServiceWithPermits(String nsId, int maxPermits)`
  `void`
  `releasePermit(String nsId)`
  Handler threads are expected to invoke this method that signals controller to release the resources allocated to the thread for the particular name service.
  `void`
  `shutdown()`
  Shutdown steps to stop accepting new permission requests and clean-up.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### LOG

    public static final org.slf4j.Logger LOG

- ## Constructor Details

  - ### AbstractRouterRpcFairnessPolicyController

    public AbstractRouterRpcFairnessPolicyController()

- ## Method Details

  - ### init

    public void init(org.apache.hadoop.conf.Configuration conf)

  - ### acquirePermit

    public boolean acquirePermit(String nsId)
    Description copied from interface: `RouterRpcFairnessPolicyController`
    Request permission for a specific name service to continue the call and connect to downstream name node. Controllers based on policies defined and allocations done at start-up through assignHandlersToNameservices, may provide a permission or reject the request by throwing exception.
    Specified by:
      `acquirePermit` in interface `RouterRpcFairnessPolicyController`
    Parameters:
      `nsId` - NS id for which a permission to continue is requested.
    Returns:
      true or false based on whether permit is given.

  - ### releasePermit

    public void releasePermit(String nsId)
    Description copied from interface: `RouterRpcFairnessPolicyController`
    Handler threads are expected to invoke this method that signals controller to release the resources allocated to the thread for the particular name service. This would mean permissions getting available for other handlers to request for this specific name service.
    Specified by:
      `releasePermit` in interface `RouterRpcFairnessPolicyController`
    Parameters:
      `nsId` - Name service id for which permission release request is made.

  - ### shutdown

    public void shutdown()
    Description copied from interface: `RouterRpcFairnessPolicyController`
    Shutdown steps to stop accepting new permission requests and clean-up.
    Specified by:
      `shutdown` in interface `RouterRpcFairnessPolicyController`

  - ### insertNameServiceWithPermits

    protected void insertNameServiceWithPermits(String nsId, int maxPermits)

  - ### getAvailablePermits

    public int getAvailablePermits(String nsId)
    Description copied from interface: `RouterRpcFairnessPolicyController`
    Returns the available handler for each name service.
    Specified by:
      `getAvailablePermits` in interface `RouterRpcFairnessPolicyController`
    Parameters:
      `nsId` - name service id.
    Returns:
      the available handler for each name service.

  - ### getAvailableHandlerOnPerNs

    public String getAvailableHandlerOnPerNs()
    Description copied from interface: `RouterRpcFairnessPolicyController`
    Returns the JSON string of the available handler for each name service.
    Specified by:
      `getAvailableHandlerOnPerNs` in interface `RouterRpcFairnessPolicyController`
    Returns:
      the JSON string of the available handler for each name service.

  - ### contains

    public boolean contains(String nsId)
    Description copied from interface: `RouterRpcFairnessPolicyController`
    Determine whether ns has registered handlers.
    Specified by:
      `contains` in interface `RouterRpcFairnessPolicyController`
    Parameters:
      `nsId` - name service id.
    Returns:
      true if the ns has registered handlers, false in other cases.