Class ShardRouting

    • Field Detail

      • UNAVAILABLE_EXPECTED_SHARD_SIZE

        public static final long UNAVAILABLE_EXPECTED_SHARD_SIZE
        Used if shard size is not available
        See Also:
        Constant Field Values
    • Constructor Detail

      • ShardRouting

        public ShardRouting​(ShardId shardId,
                            StreamInput in)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • ShardRouting

        public ShardRouting​(StreamInput in)
                     throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • index

        public Index index()
      • getIndexName

        public java.lang.String getIndexName()
        The index name.
      • id

        public int id()
        The shard id.
      • getId

        public int getId()
        The shard id.
      • unassigned

        public boolean unassigned()
        The shard is unassigned (not allocated to any node).
      • initializing

        public boolean initializing()
        The shard is initializing (usually recovering either from peer shard or from gateway).
      • active

        public boolean active()
        Returns true iff the this shard is currently started or relocating to another node. Otherwise false
      • started

        public boolean started()
        The shard is in started mode.
      • relocating

        public boolean relocating()
        Returns true iff the this shard is currently relocating to another node. Otherwise false
        See Also:
        ShardRoutingState.RELOCATING
      • assignedToNode

        public boolean assignedToNode()
        Returns true iff this shard is assigned to a node ie. not unassigned. Otherwise false
      • currentNodeId

        public java.lang.String currentNodeId()
        The current node id the shard is allocated on.
      • relocatingNodeId

        public java.lang.String relocatingNodeId()
        The relocating node id the shard is either relocating to or relocating from.
      • getTargetRelocatingShard

        public ShardRouting getTargetRelocatingShard()
        Returns a shard routing representing the target shard. The target shard routing will be the INITIALIZING state and have relocatingNodeId set to the source node.
      • unassignedInfo

        @Nullable
        public UnassignedInfo unassignedInfo()
        Additional metadata on why the shard is/was unassigned. The metadata is kept around until the shard moves to STARTED.
      • allocationId

        @Nullable
        public AllocationId allocationId()
        An id that uniquely identifies an allocation.
      • primary

        public boolean primary()
        Returns true iff this shard is a primary.
      • shardId

        public ShardId shardId()
        The shard id.
      • shardsIt

        public ShardIterator shardsIt()
        A shard iterator with just this shard in it.
      • writeToThin

        public void writeToThin​(StreamOutput out)
                         throws java.io.IOException
        Writes shard information to StreamOutput without writing index name and shard id
        Parameters:
        out - StreamOutput to write shard information to
        Throws:
        java.io.IOException - if something happens during write
      • initialize

        public ShardRouting initialize​(java.lang.String nodeId,
                                       @Nullable
                                       java.lang.String existingAllocationId,
                                       long expectedShardSize)
        Initializes an unassigned shard on a node.
        Parameters:
        existingAllocationId - allocation id to use. If null, a fresh allocation id is generated.
      • relocate

        public ShardRouting relocate​(java.lang.String relocatingNodeId,
                                     long expectedShardSize)
        Relocate the shard to another node.
        Parameters:
        relocatingNodeId - id of the node to relocate the shard
      • cancelRelocation

        public ShardRouting cancelRelocation()
        Cancel relocation of a shard. The shards state must be set to RELOCATING.
      • removeRelocationSource

        public ShardRouting removeRelocationSource()
        Removes relocation source of a non-primary shard. The shard state must be INITIALIZING. This allows the non-primary shard to continue recovery from the primary even though its non-primary relocation source has failed.
      • reinitializeReplicaShard

        public ShardRouting reinitializeReplicaShard()
        Reinitializes a replica shard, giving it a fresh allocation id
      • moveToStarted

        public ShardRouting moveToStarted()
        Set the shards state to STARTED. The shards state must be INITIALIZING or RELOCATING. Any relocation will be canceled.
      • isSameAllocation

        public boolean isSameAllocation​(ShardRouting other)
        returns true if this routing has the same allocation ID as another.

        Note: if both shard routing has a null as their allocationId(), this method returns false as the routing describe no allocation at all..

      • isRelocationTarget

        public boolean isRelocationTarget()
        Returns true if this shard is a relocation target for another shard (i.e., was created with initializeTargetRelocatingShard()
      • isRelocationTargetOf

        public boolean isRelocationTargetOf​(ShardRouting other)
        returns true if the routing is the relocation target of the given routing
      • isRelocationSourceOf

        public boolean isRelocationSourceOf​(ShardRouting other)
        returns true if the routing is the relocation source for the given routing
      • equalsIgnoringMetaData

        public boolean equalsIgnoringMetaData​(ShardRouting other)
        returns true if the current routing is identical to the other routing in all but meta fields, i.e., unassigned info
      • 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
      • shortSummary

        public java.lang.String shortSummary()
        A short description of the shard.