Fix IndexMissingException in get template request

Fixes #2873
This commit is contained in:
Igor Motov 2013-04-04 15:53:50 -04:00
parent 3120457bfe
commit 2a588dc1f1
3 changed files with 15 additions and 6 deletions

View File

@ -32,6 +32,8 @@ import java.io.IOException;
*/
public class ClusterStateRequest extends MasterNodeOperationRequest<ClusterStateRequest> {
public final static String NONE = "_na";
private boolean filterRoutingTable = false;
private boolean filterNodes = false;
@ -104,6 +106,11 @@ public class ClusterStateRequest extends MasterNodeOperationRequest<ClusterState
return filteredIndices;
}
public ClusterStateRequest filterOutIndices() {
this.filteredIndices = new String[]{NONE};
return this;
}
public ClusterStateRequest filteredIndices(String... filteredIndices) {
this.filteredIndices = filteredIndices;
return this;

View File

@ -95,11 +95,13 @@ public class TransportClusterStateAction extends TransportMasterNodeOperationAct
}
if (request.filteredIndices().length > 0) {
String[] indices = currentState.metaData().concreteIndicesIgnoreMissing(request.filteredIndices());
for (String filteredIndex : indices) {
IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex);
if (indexMetaData != null) {
mdBuilder.put(indexMetaData, false);
if (!(request.filteredIndices().length == 1 && ClusterStateRequest.NONE.equals(request.filteredIndices()[0]))) {
String[] indices = currentState.metaData().concreteIndicesIgnoreMissing(request.filteredIndices());
for (String filteredIndex : indices) {
IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex);
if (indexMetaData != null) {
mdBuilder.put(indexMetaData, false);
}
}
}
}

View File

@ -64,7 +64,7 @@ public class RestGetIndexTemplateAction extends BaseRestHandler {
.filterRoutingTable(true)
.filterNodes(true)
.filteredIndexTemplates(request.param("name"))
.filteredIndices("_na");
.filterOutIndices();
clusterStateRequest.listenerThreaded(false);