smarter handling of throttling when preferring allocating to an existing work location

This commit is contained in:
kimchy 2010-08-23 21:39:54 +03:00
parent 78b6879ecd
commit b52d854711
4 changed files with 16 additions and 2 deletions

View File

@ -118,7 +118,9 @@ public class BlobReuseExistingNodeAllocation extends NodeAllocation {
}
// check if we can allocate on that node...
if (!nodeAllocations.canAllocate(shard, node, routingNodes).allocate()) {
// we only check for NO, since if this node is THROTTLING and it has enough "same data"
// then we will try and assign it next time
if (nodeAllocations.canAllocate(shard, node, routingNodes) == Decision.NO) {
continue;
}

View File

@ -192,6 +192,11 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
} catch (IndexShardNotStartedException e) {
listener.onIgnoreRecovery("shard closed");
} catch (Exception e) {
if (indexShard.state() == IndexShardState.CLOSED) {
// got closed on us, just ignore this recovery
listener.onIgnoreRecovery("shard closed");
return;
}
listener.onRecoveryFailed(new IndexShardGatewayRecoveryException(shardId, "failed recovery", e));
}
}

View File

@ -220,6 +220,10 @@ public abstract class AbstractSimpleIndexGatewayTests extends AbstractNodesTests
testLoad(false);
}
protected boolean isPersistentStorage() {
return true;
}
private void testLoad(boolean fullRecovery) {
startNode("server1");
@ -265,7 +269,7 @@ public abstract class AbstractSimpleIndexGatewayTests extends AbstractNodesTests
for (IndexShardStatus indexShardStatus : statusResponse.index("test")) {
for (ShardStatus shardStatus : indexShardStatus) {
if (shardStatus.shardRouting().primary()) {
if (fullRecovery) {
if (fullRecovery || !isPersistentStorage()) {
assertThat(shardStatus.gatewayRecoveryStatus().reusedIndexSize().bytes(), equalTo(0l));
} else {
assertThat(shardStatus.gatewayRecoveryStatus().reusedIndexSize().bytes(), greaterThan(shardStatus.gatewayRecoveryStatus().indexSize().bytes() - 4098 /* segments file */));

View File

@ -26,4 +26,7 @@ import org.elasticsearch.test.integration.gateway.AbstractSimpleIndexGatewayTest
*/
public class SimpleFsIndexInRamIndexGatewayTests extends AbstractSimpleIndexGatewayTests {
@Override protected boolean isPersistentStorage() {
return false;
}
}