log warning when failing to list started shards on other nodes when doing local gateway allocation

This commit is contained in:
kimchy 2011-03-01 00:25:03 +02:00
parent 906ec57f20
commit 0662f65fda
1 changed files with 32 additions and 3 deletions

View File

@ -82,6 +82,9 @@ public class LocalGatewayNodeAllocation extends NodeAllocation {
for (ShardRouting shardRouting : allocation.failedShards()) { for (ShardRouting shardRouting : allocation.failedShards()) {
cachedStores.remove(shardRouting.shardId()); cachedStores.remove(shardRouting.shardId());
} }
TransportNodesListGatewayStartedShards.NodesLocalGatewayStartedShards nodesState = null;
for (ShardRouting failedShard : allocation.failedShards()) { for (ShardRouting failedShard : allocation.failedShards()) {
// this is an API allocation, ignore since we know there is no data... // this is an API allocation, ignore since we know there is no data...
if (!allocation.routingNodes().routingTable().index(failedShard.index()).shard(failedShard.id()).allocatedPostApi()) { if (!allocation.routingNodes().routingTable().index(failedShard.index()).shard(failedShard.id()).allocatedPostApi()) {
@ -90,9 +93,23 @@ public class LocalGatewayNodeAllocation extends NodeAllocation {
// we are still in the initial allocation, find another node with existing shards // we are still in the initial allocation, find another node with existing shards
// all primary are unassigned for the index, see if we can allocate it on existing nodes, if not, don't assign // all primary are unassigned for the index, see if we can allocate it on existing nodes, if not, don't assign
Set<String> nodesIds = Sets.newHashSet(); if (nodesState == null) {
nodesIds.addAll(allocation.nodes().dataNodes().keySet()); Set<String> nodesIds = Sets.newHashSet();
TransportNodesListGatewayStartedShards.NodesLocalGatewayStartedShards nodesState = listGatewayStartedShards.list(nodesIds, null).actionGet(); nodesIds.addAll(allocation.nodes().dataNodes().keySet());
nodesState = listGatewayStartedShards.list(nodesIds, null).actionGet();
if (nodesState.failures().length > 0) {
StringBuilder sb = new StringBuilder("failures when trying to list started shards on nodes:");
for (int i = 0; i < nodesState.failures().length; i++) {
Throwable cause = ExceptionsHelper.unwrapCause(nodesState.failures()[i]);
if (cause instanceof ConnectTransportException) {
continue;
}
sb.append("\n -> ").append(nodesState.failures()[i].getDetailedMessage());
}
logger.warn(sb.toString());
}
}
// make a list of ShardId to Node, each one from the latest version // make a list of ShardId to Node, each one from the latest version
Tuple<DiscoveryNode, Long> t = null; Tuple<DiscoveryNode, Long> t = null;
@ -163,6 +180,18 @@ public class LocalGatewayNodeAllocation extends NodeAllocation {
Set<String> nodesIds = Sets.newHashSet(); Set<String> nodesIds = Sets.newHashSet();
nodesIds.addAll(nodes.dataNodes().keySet()); nodesIds.addAll(nodes.dataNodes().keySet());
nodesState = listGatewayStartedShards.list(nodesIds, null).actionGet(); nodesState = listGatewayStartedShards.list(nodesIds, null).actionGet();
if (nodesState.failures().length > 0) {
StringBuilder sb = new StringBuilder("failures when trying to list started shards on nodes:");
for (int i = 0; i < nodesState.failures().length; i++) {
Throwable cause = ExceptionsHelper.unwrapCause(nodesState.failures()[i]);
if (cause instanceof ConnectTransportException) {
continue;
}
sb.append("\n -> ").append(nodesState.failures()[i].getDetailedMessage());
}
logger.warn(sb.toString());
}
} }
int numberOfAllocationsFound = 0; int numberOfAllocationsFound = 0;