Class AllocationId

java.lang.Object
org.elasticsearch.cluster.routing.AllocationId
All Implemented Interfaces:
Writeable, ToXContent, ToXContentObject

public class AllocationId
extends java.lang.Object
implements ToXContentObject, Writeable
Uniquely identifies an allocation. An allocation is a shard moving from unassigned to initializing, or relocation.

Relocation is a special case, where the origin shard is relocating with a relocationId and same id, and the target shard (only materialized in RoutingNodes) is initializing with the id set to the origin shard relocationId. Once relocation is done, the new allocation id is set to the relocationId. This is similar behavior to how ShardRouting#currentNodeId is used.

  • Method Details

    • writeTo

      public void writeTo​(StreamOutput out) throws java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      java.io.IOException
    • newInitializing

      public static AllocationId newInitializing()
      Creates a new allocation id for initializing allocation.
    • newInitializing

      public static AllocationId newInitializing​(java.lang.String existingAllocationId)
      Creates a new allocation id for initializing allocation based on an existing id.
    • newTargetRelocation

      public static AllocationId newTargetRelocation​(AllocationId allocationId)
      Creates a new allocation id for the target initializing shard that is the result of a relocation.
    • newRelocation

      public static AllocationId newRelocation​(AllocationId allocationId)
      Creates a new allocation id for a shard that moves to be relocated, populating the transient holder for relocationId.
    • cancelRelocation

      public static AllocationId cancelRelocation​(AllocationId allocationId)
      Creates a new allocation id representing a cancelled relocation.

      Note that this is expected to be called on the allocation id of the *source* shard

    • finishRelocation

      public static AllocationId finishRelocation​(AllocationId allocationId)
      Creates a new allocation id finalizing a relocation.

      Note that this is expected to be called on the allocation id of the *target* shard and thus it only needs to clear the relocating id.

    • getId

      public java.lang.String getId()
      The allocation id uniquely identifying an allocation, note, if it is relocation the getRelocationId() need to be taken into account as well.
    • getRelocationId

      public java.lang.String getRelocationId()
      The transient relocation id holding the unique id that is used for relocation.
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • toXContent

      public XContentBuilder toXContent​(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      java.io.IOException
    • fromXContent

      public static AllocationId fromXContent​(XContentParser parser) throws java.io.IOException
      Throws:
      java.io.IOException