Merge pull request #13906 from Mpdreamz/fix/remove-deprecated-get-alias-api

Remove deprecated indices.get_aliases
This commit is contained in:
Martijn Laarman 2016-03-31 15:57:03 +02:00
commit 7de2377d38
5 changed files with 7 additions and 361 deletions

View File

@ -64,7 +64,6 @@ import org.elasticsearch.rest.action.admin.cluster.tasks.RestPendingClusterTasks
import org.elasticsearch.rest.action.admin.indices.alias.RestIndicesAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.delete.RestIndexDeleteAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.get.RestGetAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.get.RestGetIndicesAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.head.RestAliasesExistAction;
import org.elasticsearch.rest.action.admin.indices.alias.put.RestIndexPutAliasAction;
import org.elasticsearch.rest.action.admin.indices.analyze.RestAnalyzeAction;
@ -202,7 +201,6 @@ public class NetworkModule extends AbstractModule {
RestIndexDeleteAliasesAction.class,
RestIndexPutAliasAction.class,
RestIndicesAliasesAction.class,
RestGetIndicesAliasesAction.class,
RestCreateIndexAction.class,
RestDeleteIndexAction.class,
RestCloseIndexAction.class,

View File

@ -1,97 +0,0 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.rest.action.admin.indices.alias.get;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.action.support.RestBuilderListener;
import static org.elasticsearch.common.Strings.isAllOrWildcard;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.OK;
/**
*/
@Deprecated
public class RestGetIndicesAliasesAction extends BaseRestHandler {
@Inject
public RestGetIndicesAliasesAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(GET, "/{index}/_aliases/{name}", this);
controller.registerHandler(GET, "/_aliases/{name}", this);
}
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final String[] aliases = Strings.splitStringByCommaToArray(request.param("name"));
ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest()
.routingTable(false)
.nodes(false)
.indices(indices);
clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
client.admin().cluster().state(clusterStateRequest, new RestBuilderListener<ClusterStateResponse>(channel) {
@Override
public RestResponse buildResponse(ClusterStateResponse response, XContentBuilder builder) throws Exception {
MetaData metaData = response.getState().metaData();
builder.startObject();
final boolean isAllAliasesRequested = isAllOrWildcard(aliases);
for (IndexMetaData indexMetaData : metaData) {
builder.startObject(indexMetaData.getIndex().getName(), XContentBuilder.FieldCaseConversion.NONE);
builder.startObject("aliases");
for (ObjectCursor<AliasMetaData> cursor : indexMetaData.getAliases().values()) {
if (isAllAliasesRequested || Regex.simpleMatch(aliases, cursor.value.alias())) {
AliasMetaData.Builder.toXContent(cursor.value, builder, ToXContent.EMPTY_PARAMS);
}
}
builder.endObject();
builder.endObject();
}
builder.endObject();
return new BytesRestResponse(OK, builder);
}
});
}
}

View File

@ -1,31 +0,0 @@
{
"indices.get_aliases": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html",
"methods": ["GET"],
"url": {
"path": "/_aliases",
"paths": ["/_aliases", "/{index}/_aliases", "/{index}/_aliases/{name}", "/_aliases/{name}" ],
"parts": {
"index": {
"type" : "list",
"description" : "A comma-separated list of index names to filter aliases"
},
"name": {
"type" : "list",
"description" : "A comma-separated list of alias names to filter"
}
},
"params": {
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
},
"local": {
"type": "boolean",
"description": "Return local information, do not retrieve the state from master node (default: false)"
}
}
},
"body": null
}
}

View File

@ -1,224 +0,0 @@
---
setup:
- do:
indices.create:
index: test_index
- do:
indices.create:
index: test_index_2
- do:
indices.put_alias:
index: test_index
name: test_alias
- do:
indices.put_alias:
index: test_index
name: test_blias
- do:
indices.put_alias:
index: test_index_2
name: test_alias
- do:
indices.put_alias:
index: test_index_2
name: test_blias
---
"Get all aliases via /_aliases":
- do:
indices.get_aliases: {}
- match: {test_index.aliases.test_alias: {}}
- match: {test_index.aliases.test_blias: {}}
- match: {test_index_2.aliases.test_alias: {}}
- match: {test_index_2.aliases.test_blias: {}}
---
"Get all aliases via /{index}/_aliases/":
- do:
indices.get_aliases:
index: test_index
- match: {test_index.aliases.test_alias: {}}
- match: {test_index.aliases.test_blias: {}}
- is_false: test_index_2
---
"Get specific alias via /{index}/_aliases/{name}":
- do:
indices.get_aliases:
index: test_index
name: test_alias
- match: {test_index.aliases.test_alias: {}}
- is_false: test_index.aliases.test_blias
- is_false: test_index_2
---
"Get aliases via /{index}/_aliases/_all":
- do:
indices.get_aliases:
index: test_index
name: _all
- match: {test_index.aliases.test_alias: {}}
- match: {test_index.aliases.test_blias: {}}
- is_false: test_index_2
---
"Get aliases via /{index}/_aliases/*":
- do:
indices.get_aliases:
index: test_index
name: '*'
- match: {test_index.aliases.test_alias: {}}
- match: {test_index.aliases.test_blias: {}}
- is_false: test_index_2
---
"Get aliases via /{index}/_aliases/prefix*":
- do:
indices.get_aliases:
index: test_index
name: 'test_a*'
- match: {test_index.aliases.test_alias: {}}
- is_false: test_index.aliases.test_blias
- is_false: test_index_2
---
"Get aliases via /{index}/_aliases/name,name":
- do:
indices.get_aliases:
index: test_index
name: 'test_alias,test_blias'
- match: {test_index.aliases.test_alias: {}}
- match: {test_index.aliases.test_blias: {}}
- is_false: test_index_2
---
"Get aliases via /_aliases/{name}":
- do:
indices.get_aliases:
name: test_alias
- match: {test_index.aliases.test_alias: {}}
- match: {test_index_2.aliases.test_alias: {}}
- is_false: test_index.aliases.test_blias
- is_false: test_index_2.aliases.test_blias
---
"Get aliases via /_all/_aliases/{name}":
- do:
indices.get_aliases:
index: _all
name: test_alias
- match: {test_index.aliases.test_alias: {}}
- match: {test_index_2.aliases.test_alias: {}}
- is_false: test_index.aliases.test_blias
- is_false: test_index_2.aliases.test_blias
---
"Get aliases via /*/_aliases/{name}":
- do:
indices.get_aliases:
index: '*'
name: test_alias
- match: {test_index.aliases.test_alias: {}}
- match: {test_index_2.aliases.test_alias: {}}
- is_false: test_index.aliases.test_blias
- is_false: test_index_2.aliases.test_blias
---
"Get aliases via /pref*/_aliases/{name}":
- do:
indices.get_aliases:
index: '*2'
name: test_alias
- match: {test_index_2.aliases.test_alias: {}}
- is_false: test_index.aliases.test_alias
- is_false: test_index.aliases.test_blias
- is_false: test_index_2.aliases.test_blias
---
"Get aliases via /name,name/_aliases/{name}":
- do:
indices.get_aliases:
index: test_index,test_index_2
name: test_alias
- match: {test_index.aliases.test_alias: {}}
- match: {test_index_2.aliases.test_alias: {}}
- is_false: test_index.aliases.test_blias
- is_false: test_index_2.aliases.test_blias
---
"Non-existent alias on an existing index returns matching indcies":
- do:
indices.get_aliases:
index: test_index
name: non-existent
- match: { test_index.aliases: {}}
---
"Existent and non-existent alias returns just the existing":
- do:
indices.get_aliases:
index: test_index
name: test_alias,non-existent
- match: {test_index.aliases.test_alias: {}}
- is_false: test_index.aliases.non-existent
---
"Getting alias on an non-existent index should return 404":
- skip:
version: "1.0.0.Beta1 - "
reason: not implemented yet
- do:
catch: missing
indices.get_aliases:
index: non-existent
name: foo
---
"Get aliases with local flag":
- do:
indices.get_aliases:
local: true
- is_true: test_index
- is_true: test_index_2

View File

@ -16,7 +16,7 @@ setup:
routing: routing
- do:
indices.get_aliases:
indices.get_alias:
index: test_index
- match: {test_index.aliases.test_alias: {'index_routing': 'routing', 'search_routing': 'routing'}}
@ -34,7 +34,7 @@ setup:
index_routing: index_routing
- do:
indices.get_aliases:
indices.get_alias:
index: test_index
- match: {test_index.aliases.test_alias: {'index_routing': 'index_routing'}}
@ -52,7 +52,7 @@ setup:
search_routing: search_routing
- do:
indices.get_aliases:
indices.get_alias:
index: test_index
- match: {test_index.aliases.test_alias: {'search_routing': 'search_routing'}}
@ -71,7 +71,7 @@ setup:
routing: routing
- do:
indices.get_aliases:
indices.get_alias:
index: test_index
- match: {test_index.aliases.test_alias: {'index_routing': 'index_routing', 'search_routing': 'routing'}}
@ -90,7 +90,7 @@ setup:
routing: routing
- do:
indices.get_aliases:
indices.get_alias:
index: test_index
- match: {test_index.aliases.test_alias: {'index_routing': 'routing', 'search_routing': 'search_routing'}}
@ -110,7 +110,7 @@ setup:
routing: routing
- do:
indices.get_aliases:
indices.get_alias:
index: test_index
- match: {test_index.aliases.test_alias: {'index_routing': 'index_routing', 'search_routing': 'search_routing'}}
@ -128,7 +128,7 @@ setup:
routing: 5
- do:
indices.get_aliases:
indices.get_alias:
index: test_index
- match: {test_index.aliases.test_alias: {'index_routing': '5', 'search_routing': '5'}}