validate when setting aliases that index routing does not resolve into several routing values

This commit is contained in:
kimchy 2011-06-13 01:21:03 +03:00
parent fbdf11d3f1
commit adbe0565f1
2 changed files with 5 additions and 7 deletions

View File

@ -73,6 +73,10 @@ public class MetaDataIndexAliasesService extends AbstractComponent {
listener.onFailure(new InvalidAliasNameException(new Index(aliasAction.index()), aliasAction.alias(), "an index exists with the same name as the alias"));
return currentState;
}
if (aliasAction.indexRouting() != null && aliasAction.indexRouting().indexOf(',') != -1) {
listener.onFailure(new ElasticSearchIllegalArgumentException("alias [" + aliasAction.alias() + "] has several routing values associated with it"));
return currentState;
}
}
List<String> indicesToClose = Lists.newArrayList();

View File

@ -74,7 +74,7 @@ public class AliasResolveRoutingTests extends AbstractNodesTests {
client.admin().indices().prepareAliases().addAliasAction(newAddAliasAction("test1", "alias")).execute().actionGet();
client.admin().indices().prepareAliases().addAliasAction(newAddAliasAction("test1", "alias10").routing("0")).execute().actionGet();
client.admin().indices().prepareAliases().addAliasAction(newAddAliasAction("test1", "alias110").routing("1,0")).execute().actionGet();
client.admin().indices().prepareAliases().addAliasAction(newAddAliasAction("test1", "alias110").searchRouting("1,0")).execute().actionGet();
client.admin().indices().prepareAliases().addAliasAction(newAddAliasAction("test1", "alias12").routing("2")).execute().actionGet();
client.admin().indices().prepareAliases().addAliasAction(newAddAliasAction("test2", "alias20").routing("0")).execute().actionGet();
client.admin().indices().prepareAliases().addAliasAction(newAddAliasAction("test2", "alias21").routing("1")).execute().actionGet();
@ -97,12 +97,6 @@ public class AliasResolveRoutingTests extends AbstractNodesTests {
} catch (ElasticSearchIllegalArgumentException e) {
// all is well, we can't have two mappings, one provided, and one in the alias
}
try {
clusterService.state().metaData().resolveIndexRouting(null, "alias110");
assert false : "should fail";
} catch (ElasticSearchIllegalArgumentException e) {
// all is well, we can't have two mappings, one provided, and one in the alias
}
try {
clusterService.state().metaData().resolveIndexRouting(null, "alias0");