org.apache.hadoop.yarn.server.federation.policies

## Class AbstractConfigurableFederationPolicy

- java.lang.Object
- - org.apache.hadoop.yarn.server.federation.policies.AbstractConfigurableFederationPolicy

- All Implemented Interfaces:
    ConfigurableFederationPolicy
  Direct Known Subclasses:
    AbstractAMRMProxyPolicy, AbstractRouterPolicy

      public abstract class AbstractConfigurableFederationPolicy
      extends Object
      implements ConfigurableFederationPolicy

  Base abstract class for a weighted `ConfigurableFederationPolicy`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractConfigurableFederationPolicy()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Map<SubClusterId,SubClusterInfo>` | `getActiveSubclusters()` This methods gets active subclusters map from the `FederationStateStoreFacade` and validate it not being null/empty.
    `boolean` | `getIsDirty()` Returns true whether the last reinitialization requires actual changes, or was "free" as the weights have not changed.
    `FederationPolicyInitializationContext` | `getPolicyContext()` Getter method for the `FederationPolicyInitializationContext`.
    `WeightedPolicyInfo` | `getPolicyInfo()` Getter method for the configuration weights.
    `void` | `reinitialize(FederationPolicyInitializationContext initializationContext)` This method is invoked to initialize of update the configuration of policies.
    `void` | `setPolicyContext(FederationPolicyInitializationContext policyContext)` Setter method for the `FederationPolicyInitializationContext`.
    `void` | `setPolicyInfo(WeightedPolicyInfo policyInfo)` Setter method for the configuration weights.
    `void` | `validate(WeightedPolicyInfo newPolicyInfo)` Overridable validation step for the policy configuration.

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

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

- - ### Constructor Detail

    - #### AbstractConfigurableFederationPolicy

          public AbstractConfigurableFederationPolicy()

  - ### Method Detail

    - #### reinitialize

          public void reinitialize(FederationPolicyInitializationContext initializationContext)
                            throws FederationPolicyInitializationException

      Description copied from interface: `ConfigurableFederationPolicy`
      This method is invoked to initialize of update the configuration of policies. The implementor should provide try-n-swap semantics, and retain state if possible.
      Specified by:
        `reinitialize` in interface `ConfigurableFederationPolicy`
      Parameters:
        `initializationContext` - the new context to provide to implementor.
      Throws:
        `FederationPolicyInitializationException` - in case the initialization fails.

    - #### validate

          public void validate(WeightedPolicyInfo newPolicyInfo)
                        throws FederationPolicyInitializationException

      Overridable validation step for the policy configuration.
      Parameters:
        `newPolicyInfo` - the configuration to test.
      Throws:
        `FederationPolicyInitializationException` - if the configuration is not valid.

    - #### getIsDirty

          public boolean getIsDirty()

      Returns true whether the last reinitialization requires actual changes, or was "free" as the weights have not changed. This is used by subclasses overriding reinitialize and calling super.reinitialize() to know wheter to quit early.
      Returns:
        whether more work is needed to initialize.

    - #### getPolicyInfo

          public WeightedPolicyInfo getPolicyInfo()

      Getter method for the configuration weights.
      Returns:
        the `WeightedPolicyInfo` representing the policy configuration.

    - #### setPolicyInfo

          public void setPolicyInfo(WeightedPolicyInfo policyInfo)

      Setter method for the configuration weights.
      Parameters:
        `policyInfo` - the `WeightedPolicyInfo` representing the policy configuration.

    - #### getPolicyContext

          public FederationPolicyInitializationContext getPolicyContext()

      Getter method for the `FederationPolicyInitializationContext`.
      Returns:
        the context for this policy.

    - #### setPolicyContext

          public void setPolicyContext(FederationPolicyInitializationContext policyContext)

      Setter method for the `FederationPolicyInitializationContext`.
      Parameters:
        `policyContext` - the context to assign to this policy.

    - #### getActiveSubclusters

          protected Map<SubClusterId,SubClusterInfo> getActiveSubclusters()
                                                                   throws org.apache.hadoop.yarn.exceptions.YarnException

      This methods gets active subclusters map from the `FederationStateStoreFacade` and validate it not being null/empty.
      Returns:
        the map of ids to info for all active subclusters.
      Throws:
        `org.apache.hadoop.yarn.exceptions.YarnException` - if we can't get the list.

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.