/** * Initializes an unassigned shard on a node. * * @param existingAllocationId allocation id to use. If null, a fresh allocation id is generated. */ public ShardRouting initialize(String nodeId, @Nullable String existingAllocationId, long expectedShardSize) { assert state == ShardRoutingState.UNASSIGNED : this; assert relocatingNodeId == null : this; final AllocationId allocationId; if (existingAllocationId == null) { allocationId = AllocationId.newInitializing(); } else { allocationId = AllocationId.newInitializing(existingAllocationId); } return new ShardRouting(shardId, nodeId, null, primary, ShardRoutingState.INITIALIZING, recoverySource, unassignedInfo, allocationId, expectedShardSize); }
/** * Reinitializes a replica shard, giving it a fresh allocation id */ public ShardRouting reinitializeReplicaShard() { assert state == ShardRoutingState.INITIALIZING : this; assert primary == false : this; assert isRelocationTarget() == false : this; return new ShardRouting(shardId, currentNodeId, null, primary, ShardRoutingState.INITIALIZING, recoverySource, unassignedInfo, AllocationId.newInitializing(), expectedShardSize); }
protected void newAllocationId(Environment environment, ShardPath shardPath, Terminal terminal) throws IOException { final Path shardStatePath = shardPath.getShardStatePath(); final ShardStateMetaData shardStateMetaData = ShardStateMetaData.FORMAT.loadLatestState(logger, namedXContentRegistry, shardStatePath); if (shardStateMetaData == null) { throw new ElasticsearchException("No shard state meta data at " + shardStatePath); } final AllocationId newAllocationId = AllocationId.newInitializing(); terminal.println("Changing allocation id " + shardStateMetaData.allocationId.getId() + " to " + newAllocationId.getId()); final ShardStateMetaData newShardStateMetaData = new ShardStateMetaData(shardStateMetaData.primary, shardStateMetaData.indexUUID, newAllocationId); ShardStateMetaData.FORMAT.write(newShardStateMetaData, shardStatePath); terminal.println(""); terminal.println("You should run the following command to allocate this shard:"); printRerouteCommand(shardPath, terminal, true); }
private static AllocationId buildAllocationId(ShardRoutingState state) { switch (state) { case UNASSIGNED: return null; case INITIALIZING: case STARTED: return AllocationId.newInitializing(); case RELOCATING: AllocationId allocationId = AllocationId.newInitializing(); return AllocationId.newRelocation(allocationId); default: throw new IllegalStateException("illegal state"); } }
/** * Initializes an unassigned shard on a node. */ void initialize(String nodeId, long expectedShardSize) { ensureNotFrozen(); version++; assert state == ShardRoutingState.UNASSIGNED : this; assert relocatingNodeId == null : this; state = ShardRoutingState.INITIALIZING; currentNodeId = nodeId; allocationId = AllocationId.newInitializing(); this.expectedShardSize = expectedShardSize; }
/** * Initializes an unassigned shard on a node. * * @param existingAllocationId allocation id to use. If null, a fresh allocation id is generated. */ public ShardRouting initialize(String nodeId, @Nullable String existingAllocationId, long expectedShardSize) { assert state == ShardRoutingState.UNASSIGNED : this; assert relocatingNodeId == null : this; final AllocationId allocationId; if (existingAllocationId == null) { allocationId = AllocationId.newInitializing(); } else { allocationId = AllocationId.newInitializing(existingAllocationId); } return new ShardRouting(shardId, nodeId, null, primary, ShardRoutingState.INITIALIZING, recoverySource, unassignedInfo, allocationId, expectedShardSize); }
/** * Initializes an unassigned shard on a node. * * @param existingAllocationId allocation id to use. If null, a fresh allocation id is generated. */ public ShardRouting initialize(String nodeId, @Nullable String existingAllocationId, long expectedShardSize) { assert state == ShardRoutingState.UNASSIGNED : this; assert relocatingNodeId == null : this; final AllocationId allocationId; if (existingAllocationId == null) { allocationId = AllocationId.newInitializing(); } else { allocationId = AllocationId.newInitializing(existingAllocationId); } return new ShardRouting(shardId, nodeId, null, primary, ShardRoutingState.INITIALIZING, recoverySource, unassignedInfo, allocationId, expectedShardSize); }
/** * Initializes an unassigned shard on a node. * * @param existingAllocationId allocation id to use. If null, a fresh allocation id is generated. */ public ShardRouting initialize(String nodeId, @Nullable String existingAllocationId, long expectedShardSize) { assert state == ShardRoutingState.UNASSIGNED : this; assert relocatingNodeId == null : this; final AllocationId allocationId; if (existingAllocationId == null) { allocationId = AllocationId.newInitializing(); } else { allocationId = AllocationId.newInitializing(existingAllocationId); } return new ShardRouting(shardId, nodeId, null, primary, ShardRoutingState.INITIALIZING, recoverySource, unassignedInfo, allocationId, expectedShardSize); }
/** * Reinitializes a replica shard, giving it a fresh allocation id */ public ShardRouting reinitializeReplicaShard() { assert state == ShardRoutingState.INITIALIZING : this; assert primary == false : this; assert isRelocationTarget() == false : this; return new ShardRouting(shardId, currentNodeId, null, primary, ShardRoutingState.INITIALIZING, recoverySource, unassignedInfo, AllocationId.newInitializing(), expectedShardSize); }
/** * Moves the shard from started to initializing */ void reinitializeShard() { ensureNotFrozen(); assert state == ShardRoutingState.STARTED; version++; state = ShardRoutingState.INITIALIZING; allocationId = AllocationId.newInitializing(); this.unassignedInfo = new UnassignedInfo(UnassignedInfo.Reason.REINITIALIZED, null); }
/** * Reinitializes a replica shard, giving it a fresh allocation id */ public ShardRouting reinitializeReplicaShard() { assert state == ShardRoutingState.INITIALIZING : this; assert primary == false : this; assert isRelocationTarget() == false : this; return new ShardRouting(shardId, currentNodeId, null, primary, ShardRoutingState.INITIALIZING, recoverySource, unassignedInfo, AllocationId.newInitializing(), expectedShardSize); }
/** * Reinitializes a replica shard, giving it a fresh allocation id */ public ShardRouting reinitializeReplicaShard() { assert state == ShardRoutingState.INITIALIZING : this; assert primary == false : this; assert isRelocationTarget() == false : this; return new ShardRouting(shardId, currentNodeId, null, primary, ShardRoutingState.INITIALIZING, recoverySource, unassignedInfo, AllocationId.newInitializing(), expectedShardSize); }
protected void newAllocationId(Environment environment, ShardPath shardPath, Terminal terminal) throws IOException { final Path shardStatePath = shardPath.getShardStatePath(); final ShardStateMetaData shardStateMetaData = ShardStateMetaData.FORMAT.loadLatestState(logger, namedXContentRegistry, shardStatePath); if (shardStateMetaData == null) { throw new ElasticsearchException("No shard state meta data at " + shardStatePath); } final AllocationId newAllocationId = AllocationId.newInitializing(); terminal.println("Changing allocation id " + shardStateMetaData.allocationId.getId() + " to " + newAllocationId.getId()); final ShardStateMetaData newShardStateMetaData = new ShardStateMetaData(shardStateMetaData.primary, shardStateMetaData.indexUUID, newAllocationId); ShardStateMetaData.FORMAT.write(newShardStateMetaData, shardStatePath); terminal.println(""); terminal.println("You should run the following command to allocate this shard:"); printRerouteCommand(shardPath, terminal, true); }
protected void newAllocationId(Environment environment, ShardPath shardPath, Terminal terminal) throws IOException { final Path shardStatePath = shardPath.getShardStatePath(); final ShardStateMetaData shardStateMetaData = ShardStateMetaData.FORMAT.loadLatestState(logger, namedXContentRegistry, shardStatePath); if (shardStateMetaData == null) { throw new ElasticsearchException("No shard state meta data at " + shardStatePath); } final AllocationId newAllocationId = AllocationId.newInitializing(); terminal.println("Changing allocation id " + shardStateMetaData.allocationId.getId() + " to " + newAllocationId.getId()); final ShardStateMetaData newShardStateMetaData = new ShardStateMetaData(shardStateMetaData.primary, shardStateMetaData.indexUUID, newAllocationId); ShardStateMetaData.FORMAT.write(newShardStateMetaData, shardStatePath); terminal.println(""); terminal.println("You should run the following command to allocate this shard:"); printRerouteCommand(shardPath, terminal, true); }
public abstract class EngineTestCase extends ESTestCase { protected final AllocationId allocationId = AllocationId.newInitializing(); protected static final IndexSettings INDEX_SETTINGS = IndexSettingsModule.newIndexSettings("index", Settings.EMPTY);