Class LifecyclePolicy

java.lang.Object
org.elasticsearch.xpack.core.ilm.LifecyclePolicy
All Implemented Interfaces:
Diffable<LifecyclePolicy>, SimpleDiffable<LifecyclePolicy>, Writeable, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject

public class LifecyclePolicy extends Object implements SimpleDiffable<LifecyclePolicy>, org.elasticsearch.xcontent.ToXContentObject
Represents the lifecycle of an index from creation to deletion. A LifecyclePolicy is made up of a set of Phases which it will move through. Policies are constrained by a LifecycleType which governs which Phases and LifecycleActions are allowed to be defined and in which order they are executed.
  • Field Details

    • PHASES_FIELD

      public static final org.elasticsearch.xcontent.ParseField PHASES_FIELD
    • PARSER

      public static final org.elasticsearch.xcontent.ConstructingObjectParser<LifecyclePolicy,String> PARSER
  • Constructor Details

  • Method Details

    • validate

      public void validate()
    • parse

      public static LifecyclePolicy parse(org.elasticsearch.xcontent.XContentParser parser, String name)
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • getName

      public String getName()
      Returns:
      the name of this LifecyclePolicy
    • getType

      public LifecycleType getType()
      Returns:
      the type of this LifecyclePolicy
    • getPhases

      public Map<String,Phase> getPhases()
      Returns:
      the Phases for this LifecyclePolicy in the order in which they will be executed.
    • getMetadata

      public Map<String,Object> getMetadata()
      Returns:
      the custom metadata of this LifecyclePolicy
    • getDeprecated

      public Boolean getDeprecated()
    • isDeprecated

      public boolean isDeprecated()
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • toSteps

      public List<Step> toSteps(Client client, XPackLicenseState licenseState)
      This method is used to compile this policy into its execution plan built out of Step instances. The order of the Phases and LifecycleActions is determined by the LifecycleType associated with this policy.

      The order of the policy will have this structure:

      - initialize policy context step - phase-1 phase-after-step - ... phase-1 action steps - phase-2 phase-after-step - ... - terminal policy step

      We first initialize the policy's context and ensure that the index has proper settings set. Then we begin each phase's after-step along with all its actions as steps. Finally, we have a terminal step to inform us that this policy's steps are all complete. Each phase's `after` step is associated with the previous phase's phase. For example, the warm phase's `after` is associated with the hot phase so that it is clear that we haven't stepped into the warm phase just yet (until this step is complete).

      Parameters:
      client - The Elasticsearch Client to use during execution of AsyncActionStep and AsyncWaitStep steps.
      licenseState - The license state to use in actions and steps
      Returns:
      The list of Step objects in order of their execution.
    • isActionSafe

      public boolean isActionSafe(Step.StepKey stepKey)
    • validatePolicyName

      public static void validatePolicyName(String policy)
      Validate the name for an policy against some static rules. Intended to match MetadataCreateIndexService.validateIndexOrAliasName(String, BiFunction)
      Parameters:
      policy - the policy name to validate
      Throws:
      IllegalArgumentException - if the name is invalid
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object