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

## Interface FederationPolicyManager

- All Known Implementing Classes:
    AbstractPolicyManager, HashBroadcastPolicyManager, HomePolicyManager, PriorityBroadcastPolicyManager, RejectAllPolicyManager, UniformBroadcastPolicyManager, WeightedLocalityPolicyManager

      public interface FederationPolicyManager

  Implementors need to provide the ability to serliaze a policy and its configuration as a `SubClusterPolicyConfiguration`, as well as provide (re)initialization mechanics for the underlying `FederationAMRMProxyPolicy` and `FederationRouterPolicy`. The serialization aspects are used by admin APIs or a policy engine to store a serialized configuration in the `FederationStateStore`, while the getters methods are used to obtain a propertly inizialized policy in the `Router` and `AMRMProxy` respectively. This interface by design binds together `FederationAMRMProxyPolicy` and `FederationRouterPolicy` and provide lifecycle support for serialization and deserialization, to reduce configuration mistakes (combining incompatible policies).

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `FederationAMRMProxyPolicy` | `getAMRMPolicy(FederationPolicyInitializationContext policyContext, FederationAMRMProxyPolicy oldInstance)` If the current instance is compatible, this method returns the same instance of `FederationAMRMProxyPolicy` reinitialized with the current context, otherwise a new instance initialized with the current context is provided.
    `String` | `getQueue()` This method returns the queue this policy is configured for.
    `FederationRouterPolicy` | `getRouterPolicy(FederationPolicyInitializationContext policyContext, FederationRouterPolicy oldInstance)` If the current instance is compatible, this method returns the same instance of `FederationRouterPolicy` reinitialized with the current context, otherwise a new instance initialized with the current context is provided.
    `SubClusterPolicyConfiguration` | `serializeConf()` This method is invoked to derive a `SubClusterPolicyConfiguration`.
    `void` | `setQueue(String queue)` This methods provides a setter for the queue this policy is specified for.

- - ### Method Detail

    - #### getAMRMPolicy

          FederationAMRMProxyPolicy getAMRMPolicy(FederationPolicyInitializationContext policyContext,
                                                  FederationAMRMProxyPolicy oldInstance)
                                           throws FederationPolicyInitializationException

      If the current instance is compatible, this method returns the same instance of `FederationAMRMProxyPolicy` reinitialized with the current context, otherwise a new instance initialized with the current context is provided. If the instance is compatible with the current class the implementors should attempt to reinitalize (retaining state). To affect a complete policy reset oldInstance should be null.
      Parameters:
        `policyContext` - the current context
        `oldInstance` - the existing (possibly null) instance.
      Returns:
        an updated `FederationAMRMProxyPolicy`.
      Throws:
        `FederationPolicyInitializationException` - if the initialization cannot be completed properly. The oldInstance should be still valid in case of failed initialization.

    - #### getRouterPolicy

          FederationRouterPolicy getRouterPolicy(FederationPolicyInitializationContext policyContext,
                                                 FederationRouterPolicy oldInstance)
                                          throws FederationPolicyInitializationException

      If the current instance is compatible, this method returns the same instance of `FederationRouterPolicy` reinitialized with the current context, otherwise a new instance initialized with the current context is provided. If the instance is compatible with the current class the implementors should attempt to reinitalize (retaining state). To affect a complete policy reset oldInstance shoulb be set to null.
      Parameters:
        `policyContext` - the current context
        `oldInstance` - the existing (possibly null) instance.
      Returns:
        an updated `FederationRouterPolicy`.
      Throws:
        `FederationPolicyInitializationException` - if the initalization cannot be completed properly. The oldInstance should be still valid in case of failed initialization.

    - #### serializeConf

          SubClusterPolicyConfiguration serializeConf()
                                               throws FederationPolicyInitializationException

      This method is invoked to derive a `SubClusterPolicyConfiguration`. This is to be used when writing a policy object in the federation policy store.
      Returns:
        a valid policy configuration representing this object parametrization.
      Throws:
        `FederationPolicyInitializationException` - if the current state cannot be serialized properly

    - #### getQueue

          String getQueue()

      This method returns the queue this policy is configured for.
      Returns:
        the name of the queue.

    - #### setQueue

          void setQueue(String queue)

      This methods provides a setter for the queue this policy is specified for.
      Parameters:
        `queue` - the name of the queue.

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