/** * Returns a {@link List} of active shards * * @return a {@link List} of shards */ public List<ShardRouting> getActiveShards() { return activeShards(); }
/** * Returns true iff the active shard count in the shard routing table is enough * to meet the required shard count represented by this instance. */ public boolean enoughShardsActive(final IndexShardRoutingTable shardRoutingTable) { final int activeShardCount = shardRoutingTable.activeShards().size(); if (this == ActiveShardCount.ALL) { // adding 1 for the primary in addition to the total number of replicas, // which gives us the total number of shard copies return activeShardCount == shardRoutingTable.replicaShards().size() + 1; } else if (this == ActiveShardCount.DEFAULT) { return activeShardCount >= 1; } else { return activeShardCount >= value; } }
/** * Checks whether we can perform a write based on the required active shard count setting. * Returns **null* if OK to proceed, or a string describing the reason to stop */ protected String checkActiveShardCount() { final ShardId shardId = primary.routingEntry().shardId(); final ActiveShardCount waitForActiveShards = request.waitForActiveShards(); if (waitForActiveShards == ActiveShardCount.NONE) { return null; // not waiting for any shards } final IndexShardRoutingTable shardRoutingTable = primary.getReplicationGroup().getRoutingTable(); if (waitForActiveShards.enoughShardsActive(shardRoutingTable)) { return null; } else { final String resolvedShards = waitForActiveShards == ActiveShardCount.ALL ? Integer.toString(shardRoutingTable.shards().size()) : waitForActiveShards.toString(); logger.trace("[{}] not enough active copies to meet shard count of [{}] (have {}, needed {}), scheduling a retry. op [{}], " + "request [{}]", shardId, waitForActiveShards, shardRoutingTable.activeShards().size(), resolvedShards, opType, request); return "Not enough active copies to meet shard count of [" + waitForActiveShards + "] (have " + shardRoutingTable.activeShards().size() + ", needed " + resolvedShards + ")."; } }
if (newShardRoutingTable.activeShards().isEmpty() && updates.firstFailedPrimary != null) {
try { final IndexShardRoutingTable shardRoutingTable = getShardRoutingTable(shardId, state); final List<ShardRouting> activeShards = shardRoutingTable.activeShards(); final int totalShards = shardRoutingTable.getSize();
/** * Returns a {@link List} of active shards * * @return a {@link List} of shards */ public List<ShardRouting> getActiveShards() { return activeShards(); }
/** * Returns a {@link List} of active shards * * @return a {@link List} of shards */ public List<ShardRouting> getActiveShards() { return activeShards(); }
/** * Returns a {@link List} of active shards * * @return a {@link List} of shards */ public List<ShardRouting> getActiveShards() { return activeShards(); }
/** * Returns a {@link List} of active shards * * @return a {@link List} of shards */ public List<ShardRouting> getActiveShards() { return activeShards(); }
/** * Returns true iff the active shard count in the shard routing table is enough * to meet the required shard count represented by this instance. */ public boolean enoughShardsActive(final IndexShardRoutingTable shardRoutingTable) { final int activeShardCount = shardRoutingTable.activeShards().size(); if (this == ActiveShardCount.ALL) { // adding 1 for the primary in addition to the total number of replicas, // which gives us the total number of shard copies return activeShardCount == shardRoutingTable.replicaShards().size() + 1; } else if (this == ActiveShardCount.DEFAULT) { return activeShardCount >= 1; } else { return activeShardCount >= value; } }
/** * Returns true iff the active shard count in the shard routing table is enough * to meet the required shard count represented by this instance. */ public boolean enoughShardsActive(final IndexShardRoutingTable shardRoutingTable) { final int activeShardCount = shardRoutingTable.activeShards().size(); if (this == ActiveShardCount.ALL) { // adding 1 for the primary in addition to the total number of replicas, // which gives us the total number of shard copies return activeShardCount == shardRoutingTable.replicaShards().size() + 1; } else if (this == ActiveShardCount.DEFAULT) { return activeShardCount >= 1; } else { return activeShardCount >= value; } }
/** * Returns true iff the active shard count in the shard routing table is enough * to meet the required shard count represented by this instance. */ public boolean enoughShardsActive(final IndexShardRoutingTable shardRoutingTable) { final int activeShardCount = shardRoutingTable.activeShards().size(); if (this == ActiveShardCount.ALL) { // adding 1 for the primary in addition to the total number of replicas, // which gives us the total number of shard copies return activeShardCount == shardRoutingTable.replicaShards().size() + 1; } else if (this == ActiveShardCount.DEFAULT) { return activeShardCount >= 1; } else { return activeShardCount >= value; } }
/** * Checks whether we can perform a write based on the required active shard count setting. * Returns **null* if OK to proceed, or a string describing the reason to stop */ protected String checkActiveShardCount() { final ShardId shardId = primary.routingEntry().shardId(); final ActiveShardCount waitForActiveShards = request.waitForActiveShards(); if (waitForActiveShards == ActiveShardCount.NONE) { return null; // not waiting for any shards } final IndexShardRoutingTable shardRoutingTable = primary.getReplicationGroup().getRoutingTable(); if (waitForActiveShards.enoughShardsActive(shardRoutingTable)) { return null; } else { final String resolvedShards = waitForActiveShards == ActiveShardCount.ALL ? Integer.toString(shardRoutingTable.shards().size()) : waitForActiveShards.toString(); logger.trace("[{}] not enough active copies to meet shard count of [{}] (have {}, needed {}), scheduling a retry. op [{}], " + "request [{}]", shardId, waitForActiveShards, shardRoutingTable.activeShards().size(), resolvedShards, opType, request); return "Not enough active copies to meet shard count of [" + waitForActiveShards + "] (have " + shardRoutingTable.activeShards().size() + ", needed " + resolvedShards + ")."; } }
/** * Checks whether we can perform a write based on the required active shard count setting. * Returns **null* if OK to proceed, or a string describing the reason to stop */ protected String checkActiveShardCount() { final ShardId shardId = primary.routingEntry().shardId(); final ActiveShardCount waitForActiveShards = request.waitForActiveShards(); if (waitForActiveShards == ActiveShardCount.NONE) { return null; // not waiting for any shards } final IndexShardRoutingTable shardRoutingTable = primary.getReplicationGroup().getRoutingTable(); if (waitForActiveShards.enoughShardsActive(shardRoutingTable)) { return null; } else { final String resolvedShards = waitForActiveShards == ActiveShardCount.ALL ? Integer.toString(shardRoutingTable.shards().size()) : waitForActiveShards.toString(); logger.trace("[{}] not enough active copies to meet shard count of [{}] (have {}, needed {}), scheduling a retry. op [{}], " + "request [{}]", shardId, waitForActiveShards, shardRoutingTable.activeShards().size(), resolvedShards, opType, request); return "Not enough active copies to meet shard count of [" + waitForActiveShards + "] (have " + shardRoutingTable.activeShards().size() + ", needed " + resolvedShards + ")."; } }
: waitForActiveShards.toString(); logger.trace("[{}] not enough active copies to meet shard count of [{}] (have {}, needed {}), scheduling a retry. op [{}], " + "request [{}]", shardId, waitForActiveShards, shardRoutingTable.activeShards().size(), resolvedShards, opType, request); return "Not enough active copies to meet shard count of [" + waitForActiveShards + "] (have " + shardRoutingTable.activeShards().size() + ", needed " + resolvedShards + ").";
if (newShardRoutingTable.activeShards().isEmpty() && updates.firstFailedPrimary != null) {
private void innerAttemptSyncedFlush(final ShardId shardId, final ClusterState state, final ActionListener<ShardsSyncedFlushResult> actionListener) { try { final IndexShardRoutingTable shardRoutingTable = getShardRoutingTable(shardId, state); final List<ShardRouting> activeShards = shardRoutingTable.activeShards(); final int totalShards = shardRoutingTable.getSize();
private void innerAttemptSyncedFlush(final ShardId shardId, final ClusterState state, final ActionListener<ShardsSyncedFlushResult> actionListener) { try { final IndexShardRoutingTable shardRoutingTable = getShardRoutingTable(shardId, state); final List<ShardRouting> activeShards = shardRoutingTable.activeShards(); final int totalShards = shardRoutingTable.getSize();
private void innerAttemptSyncedFlush(final ShardId shardId, final ClusterState state, final ActionListener<ShardsSyncedFlushResult> actionListener) { try { final IndexShardRoutingTable shardRoutingTable = getShardRoutingTable(shardId, state); final List<ShardRouting> activeShards = shardRoutingTable.activeShards(); final int totalShards = shardRoutingTable.getSize();
private void innerAttemptSyncedFlush(final ShardId shardId, final ClusterState state, final ActionListener<ShardsSyncedFlushResult> actionListener) { try { final IndexShardRoutingTable shardRoutingTable = getShardRoutingTable(shardId, state); final List<ShardRouting> activeShards = shardRoutingTable.activeShards(); final int totalShards = shardRoutingTable.getSize();