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 class ClusterStateRequest extends MasterNodeOperationRequest<ClusterStateRequest> {
public final static String NONE = "_na";
private boolean filterRoutingTable = false; private boolean filterRoutingTable = false;
private boolean filterNodes = false; private boolean filterNodes = false;
@ -104,6 +106,11 @@ public class ClusterStateRequest extends MasterNodeOperationRequest<ClusterState
return filteredIndices; return filteredIndices;
} }
public ClusterStateRequest filterOutIndices() {
this.filteredIndices = new String[]{NONE};
return this;
}
public ClusterStateRequest filteredIndices(String... filteredIndices) { public ClusterStateRequest filteredIndices(String... filteredIndices) {
this.filteredIndices = filteredIndices; this.filteredIndices = filteredIndices;
return this; return this;

View File

@ -95,6 +95,7 @@ public class TransportClusterStateAction extends TransportMasterNodeOperationAct
} }
if (request.filteredIndices().length > 0) { if (request.filteredIndices().length > 0) {
if (!(request.filteredIndices().length == 1 && ClusterStateRequest.NONE.equals(request.filteredIndices()[0]))) {
String[] indices = currentState.metaData().concreteIndicesIgnoreMissing(request.filteredIndices()); String[] indices = currentState.metaData().concreteIndicesIgnoreMissing(request.filteredIndices());
for (String filteredIndex : indices) { for (String filteredIndex : indices) {
IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex); IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex);
@ -103,6 +104,7 @@ public class TransportClusterStateAction extends TransportMasterNodeOperationAct
} }
} }
} }
}
if (request.filteredIndexTemplates().length > 0) { if (request.filteredIndexTemplates().length > 0) {
for (String templateName : request.filteredIndexTemplates()) { for (String templateName : request.filteredIndexTemplates()) {

View File

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