/** * Creates a new allocation id for the target initializing shard that is the result * of a relocation. */ public static AllocationId newTargetRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getRelocationId(), allocationId.getId()); }
/** * Creates a new allocation id representing a cancelled relocation. * <p> * Note that this is expected to be called on the allocation id * of the *source* shard */ public static AllocationId cancelRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getId(), null); }
/** * Creates a new allocation id finalizing a relocation. * <p> * 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. */ public static AllocationId finishRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getId(), null); }
/** * Set the shards state to <code>STARTED</code>. The shards state must be * <code>INITIALIZING</code> or <code>RELOCATING</code>. Any relocation will be * canceled. */ public ShardRouting moveToStarted() { assert state == ShardRoutingState.INITIALIZING : "expected an initializing shard " + this; AllocationId allocationId = this.allocationId; if (allocationId.getRelocationId() != null) { // relocation target allocationId = AllocationId.finishRelocation(allocationId); } return new ShardRouting(shardId, currentNodeId, null, primary, ShardRoutingState.STARTED, null, null, allocationId, UNAVAILABLE_EXPECTED_SHARD_SIZE); }
/** returns true if the routing is the relocation target of the given routing */ public boolean isRelocationTargetOf(ShardRouting other) { boolean b = this.allocationId != null && other.allocationId != null && this.state == ShardRoutingState.INITIALIZING && this.allocationId.getId().equals(other.allocationId.getRelocationId()); assert b == false || other.state == ShardRoutingState.RELOCATING : "ShardRouting is a relocation target but the source shard state isn't relocating. This [" + this + "], other [" + other + "]"; assert b == false || other.allocationId.getId().equals(this.allocationId.getRelocationId()) : "ShardRouting is a relocation target but the source id isn't equal to source's allocationId.getRelocationId." + " This [" + this + "], other [" + other + "]"; assert b == false || other.currentNodeId().equals(this.relocatingNodeId) : "ShardRouting is a relocation target but source current node id isn't equal to target relocating node." + " This [" + this + "], other [" + other + "]"; assert b == false || this.currentNodeId().equals(other.relocatingNodeId) : "ShardRouting is a relocation target but current node id isn't equal to source relocating node." + " This [" + this + "], other [" + other + "]"; assert b == false || this.shardId.equals(other.shardId) : "ShardRouting is a relocation target but both indexRoutings are not of the same shard id." + " This [" + this + "], other [" + other + "]"; assert b == false || this.primary == other.primary : "ShardRouting is a relocation target but primary flag is different." + " This [" + this + "], target [" + other + "]"; return b; }
/** returns true if the routing is the relocation source for the given routing */ public boolean isRelocationSourceOf(ShardRouting other) { boolean b = this.allocationId != null && other.allocationId != null && other.state == ShardRoutingState.INITIALIZING && other.allocationId.getId().equals(this.allocationId.getRelocationId()); assert b == false || this.state == ShardRoutingState.RELOCATING : "ShardRouting is a relocation source but shard state isn't relocating. This [" + this + "], other [" + other + "]"; assert b == false || this.allocationId.getId().equals(other.allocationId.getRelocationId()) : "ShardRouting is a relocation source but the allocation id isn't equal to other.allocationId.getRelocationId." + " This [" + this + "], other [" + other + "]"; assert b == false || this.currentNodeId().equals(other.relocatingNodeId) : "ShardRouting is a relocation source but current node isn't equal to other's relocating node." + " This [" + this + "], other [" + other + "]"; assert b == false || other.currentNodeId().equals(this.relocatingNodeId) : "ShardRouting is a relocation source but relocating node isn't equal to other's current node." + " This [" + this + "], other [" + other + "]"; assert b == false || this.shardId.equals(other.shardId) : "ShardRouting is a relocation source but both indexRoutings are not of the same shard." + " This [" + this + "], target [" + other + "]"; assert b == false || this.primary == other.primary : "ShardRouting is a relocation source but primary flag is different. This [" + this + "], target [" + other + "]"; return b; }
/** * Creates a new allocation id for a shard that moves to be relocated, populating * the transient holder for relocationId. */ public static AllocationId newRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() == null; return new AllocationId(allocationId.getId(), UUIDs.randomBase64UUID()); }
|| routingTable.primaryShard().allocationId().getRelocationId().equals(shardAllocationId));
/** * Creates a new allocation id for the target initializing shard that is the result * of a relocation. */ public static AllocationId newTargetRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getRelocationId(), allocationId.getId()); }
/** * Creates a new allocation id for the target initializing shard that is the result * of a relocation. */ public static AllocationId newTargetRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getRelocationId(), allocationId.getId()); }
/** * Creates a new allocation id for the target initializing shard that is the result * of a relocation. */ public static AllocationId newTargetRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getRelocationId(), allocationId.getId()); }
if (routing.isRelocationTarget()) { ShardRouting sourceShard = getByAllocationId(routing.shardId(), routing.allocationId().getRelocationId());
ShardRouting targetShard = getByAllocationId(failedShard.shardId(), failedShard.allocationId().getRelocationId()); assert targetShard.isRelocationTargetOf(failedShard); if (failedShard.primary()) { unassignedInfo.shortSummary()); ShardRouting sourceShard = getByAllocationId(failedShard.shardId(), failedShard.allocationId().getRelocationId()); assert sourceShard.isRelocationSourceOf(failedShard); logger.trace("{}, resolved source to [{}]. canceling relocation ... ({})", failedShard.shardId(), sourceShard,
/** * Creates a new allocation id representing a cancelled relocation. * <p> * Note that this is expected to be called on the allocation id * of the *source* shard */ public static AllocationId cancelRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getId(), null); }
/** * Creates a new allocation id finalizing a relocation. * <p> * 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. */ public static AllocationId finishRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getId(), null); }
/** * Creates a new allocation id representing a cancelled relocation. * <p> * Note that this is expected to be called on the allocation id * of the *source* shard */ public static AllocationId cancelRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getId(), null); }
/** * Creates a new allocation id finalizing a relocation. * <p> * 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. */ public static AllocationId finishRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getId(), null); }
/** * Creates a new allocation id finalizing a relocation. * <p> * 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. */ public static AllocationId finishRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() != null; return new AllocationId(allocationId.getId(), null); }
/** * Creates a new allocation id for a shard that moves to be relocated, populating * the transient holder for relocationId. */ public static AllocationId newRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() == null; return new AllocationId(allocationId.getId(), UUIDs.randomBase64UUID()); }
/** * Creates a new allocation id for a shard that moves to be relocated, populating * the transient holder for relocationId. */ public static AllocationId newRelocation(AllocationId allocationId) { assert allocationId.getRelocationId() == null; return new AllocationId(allocationId.getId(), UUIDs.randomBase64UUID()); }