/** * A short description of the shard. */ public String shortSummary() { StringBuilder sb = new StringBuilder(); sb.append('[').append(shardId.getIndexName()).append(']').append('[').append(shardId.getId()).append(']'); sb.append(", node[").append(currentNodeId).append("], "); if (relocatingNodeId != null) { sb.append("relocating [").append(relocatingNodeId).append("], "); } if (primary) { sb.append("[P]"); } else { sb.append("[R]"); } if (recoverySource != null) { sb.append(", recovery_source[").append(recoverySource).append("]"); } sb.append(", s[").append(state).append("]"); if (allocationId != null) { sb.append(", a").append(allocationId); } if (this.unassignedInfo != null) { sb.append(", ").append(unassignedInfo.toString()); } if (expectedShardSize != UNAVAILABLE_EXPECTED_SHARD_SIZE) { sb.append(", expected_shard_size[").append(expectedShardSize).append("]"); } return sb.toString(); }
@Override public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocation) { final UnassignedInfo unassignedInfo = shardRouting.unassignedInfo(); final Decision decision; if (unassignedInfo != null && unassignedInfo.getNumFailedAllocations() > 0) { final IndexMetaData indexMetaData = allocation.metaData().getIndexSafe(shardRouting.index()); final int maxRetry = SETTING_ALLOCATION_MAX_RETRY.get(indexMetaData.getSettings()); if (unassignedInfo.getNumFailedAllocations() >= maxRetry) { decision = allocation.decision(Decision.NO, NAME, "shard has exceeded the maximum number of retries [%d] on " + "failed allocation attempts - manually call [/_cluster/reroute?retry_failed=true] to retry, [%s]", maxRetry, unassignedInfo.toString()); } else { decision = allocation.decision(Decision.YES, NAME, "shard has failed allocating [%d] times but [%d] retries are allowed", unassignedInfo.getNumFailedAllocations(), maxRetry); } } else { decision = allocation.decision(Decision.YES, NAME, "shard has no previous failures"); } return decision; }
sb.append(", ").append(unassignedInfo.toString());
/** * A short description of the shard. */ public String shortSummary() { StringBuilder sb = new StringBuilder(); sb.append('[').append(shardId.getIndexName()).append(']').append('[').append(shardId.getId()).append(']'); sb.append(", node[").append(currentNodeId).append("], "); if (relocatingNodeId != null) { sb.append("relocating [").append(relocatingNodeId).append("], "); } if (primary) { sb.append("[P]"); } else { sb.append("[R]"); } if (recoverySource != null) { sb.append(", recovery_source[").append(recoverySource).append("]"); } sb.append(", s[").append(state).append("]"); if (allocationId != null) { sb.append(", a").append(allocationId); } if (this.unassignedInfo != null) { sb.append(", ").append(unassignedInfo.toString()); } if (expectedShardSize != UNAVAILABLE_EXPECTED_SHARD_SIZE) { sb.append(", expected_shard_size[").append(expectedShardSize).append("]"); } return sb.toString(); }
/** * A short description of the shard. */ public String shortSummary() { StringBuilder sb = new StringBuilder(); sb.append('[').append(shardId.getIndexName()).append(']').append('[').append(shardId.getId()).append(']'); sb.append(", node[").append(currentNodeId).append("], "); if (relocatingNodeId != null) { sb.append("relocating [").append(relocatingNodeId).append("], "); } if (primary) { sb.append("[P]"); } else { sb.append("[R]"); } if (recoverySource != null) { sb.append(", recovery_source[").append(recoverySource).append("]"); } sb.append(", s[").append(state).append("]"); if (allocationId != null) { sb.append(", a").append(allocationId); } if (this.unassignedInfo != null) { sb.append(", ").append(unassignedInfo.toString()); } if (expectedShardSize != UNAVAILABLE_EXPECTED_SHARD_SIZE) { sb.append(", expected_shard_size[").append(expectedShardSize).append("]"); } return sb.toString(); }
/** * A short description of the shard. */ public String shortSummary() { StringBuilder sb = new StringBuilder(); sb.append('[').append(shardId.getIndexName()).append(']').append('[').append(shardId.getId()).append(']'); sb.append(", node[").append(currentNodeId).append("], "); if (relocatingNodeId != null) { sb.append("relocating [").append(relocatingNodeId).append("], "); } if (primary) { sb.append("[P]"); } else { sb.append("[R]"); } if (recoverySource != null) { sb.append(", recovery_source[").append(recoverySource).append("]"); } sb.append(", s[").append(state).append("]"); if (allocationId != null) { sb.append(", a").append(allocationId); } if (this.unassignedInfo != null) { sb.append(", ").append(unassignedInfo.toString()); } if (expectedShardSize != UNAVAILABLE_EXPECTED_SHARD_SIZE) { sb.append(", expected_shard_size[").append(expectedShardSize).append("]"); } return sb.toString(); }
@Override public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocation) { final UnassignedInfo unassignedInfo = shardRouting.unassignedInfo(); final Decision decision; if (unassignedInfo != null && unassignedInfo.getNumFailedAllocations() > 0) { final IndexMetaData indexMetaData = allocation.metaData().getIndexSafe(shardRouting.index()); final int maxRetry = SETTING_ALLOCATION_MAX_RETRY.get(indexMetaData.getSettings()); if (allocation.isRetryFailed()) { // manual allocation - retry // if we are called via the _reroute API we ignore the failure counter and try to allocate // this improves the usability since people don't need to raise the limits to issue retries since a simple _reroute call is // enough to manually retry. decision = allocation.decision(Decision.YES, NAME, "shard has exceeded the maximum number of retries [%d] on " + "failed allocation attempts - retrying once due to a manual reroute command, [%s]", maxRetry, unassignedInfo.toString()); } else if (unassignedInfo.getNumFailedAllocations() >= maxRetry) { decision = allocation.decision(Decision.NO, NAME, "shard has exceeded the maximum number of retries [%d] on " + "failed allocation attempts - manually call [/_cluster/reroute?retry_failed=true] to retry, [%s]", maxRetry, unassignedInfo.toString()); } else { decision = allocation.decision(Decision.YES, NAME, "shard has failed allocating [%d] times but [%d] retries are allowed", unassignedInfo.getNumFailedAllocations(), maxRetry); } } else { decision = allocation.decision(Decision.YES, NAME, "shard has no previous failures"); } return decision; }
@Override public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocation) { final UnassignedInfo unassignedInfo = shardRouting.unassignedInfo(); final Decision decision; if (unassignedInfo != null && unassignedInfo.getNumFailedAllocations() > 0) { final IndexMetaData indexMetaData = allocation.metaData().getIndexSafe(shardRouting.index()); final int maxRetry = SETTING_ALLOCATION_MAX_RETRY.get(indexMetaData.getSettings()); if (unassignedInfo.getNumFailedAllocations() >= maxRetry) { decision = allocation.decision(Decision.NO, NAME, "shard has exceeded the maximum number of retries [%d] on " + "failed allocation attempts - manually call [/_cluster/reroute?retry_failed=true] to retry, [%s]", maxRetry, unassignedInfo.toString()); } else { decision = allocation.decision(Decision.YES, NAME, "shard has failed allocating [%d] times but [%d] retries are allowed", unassignedInfo.getNumFailedAllocations(), maxRetry); } } else { decision = allocation.decision(Decision.YES, NAME, "shard has no previous failures"); } return decision; }
@Override public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocation) { final UnassignedInfo unassignedInfo = shardRouting.unassignedInfo(); final Decision decision; if (unassignedInfo != null && unassignedInfo.getNumFailedAllocations() > 0) { final IndexMetaData indexMetaData = allocation.metaData().getIndexSafe(shardRouting.index()); final int maxRetry = SETTING_ALLOCATION_MAX_RETRY.get(indexMetaData.getSettings()); if (unassignedInfo.getNumFailedAllocations() >= maxRetry) { decision = allocation.decision(Decision.NO, NAME, "shard has exceeded the maximum number of retries [%d] on " + "failed allocation attempts - manually call [/_cluster/reroute?retry_failed=true] to retry, [%s]", maxRetry, unassignedInfo.toString()); } else { decision = allocation.decision(Decision.YES, NAME, "shard has failed allocating [%d] times but [%d] retries are allowed", unassignedInfo.getNumFailedAllocations(), maxRetry); } } else { decision = allocation.decision(Decision.YES, NAME, "shard has no previous failures"); } return decision; }