本文整理汇总了Java中org.elasticsearch.cluster.metadata.AliasAction类的典型用法代码示例。如果您正苦于以下问题:Java AliasAction类的具体用法?Java AliasAction怎么用?Java AliasAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AliasAction类属于org.elasticsearch.cluster.metadata包,在下文中一共展示了AliasAction类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testCreateUpdateAliasRequest
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
public void testCreateUpdateAliasRequest() throws Exception {
String sourceAlias = randomAsciiOfLength(10);
String sourceIndex = randomAsciiOfLength(10);
String targetIndex = randomAsciiOfLength(10);
final RolloverRequest rolloverRequest = new RolloverRequest(sourceAlias, targetIndex);
final IndicesAliasesClusterStateUpdateRequest updateRequest =
TransportRolloverAction.prepareRolloverAliasesUpdateRequest(sourceIndex, targetIndex, rolloverRequest);
List<AliasAction> actions = updateRequest.actions();
assertThat(actions, hasSize(2));
boolean foundAdd = false;
boolean foundRemove = false;
for (AliasAction action : actions) {
if (action.getIndex().equals(targetIndex)) {
assertEquals(sourceAlias, ((AliasAction.Add) action).getAlias());
foundAdd = true;
} else if (action.getIndex().equals(sourceIndex)) {
assertEquals(sourceAlias, ((AliasAction.Remove) action).getAlias());
foundRemove = true;
} else {
throw new AssertionError("Unknow index [" + action.getIndex() + "]");
}
}
assertTrue(foundAdd);
assertTrue(foundRemove);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:TransportRolloverActionTests.java
示例2: aliasActionToJson
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
private void aliasActionToJson(IndicesAliasesRequest.AliasActions actions, String alias, String index, XContentBuilder builder) throws IOException {
String filter = actions.aliasAction().filter();
String indexRouting = actions.aliasAction().indexRouting();
String searchRouting = actions.aliasAction().searchRouting();
AliasAction.Type type = actions.aliasAction().actionType();
builder.startObject();
builder.startObject(type.name().toLowerCase());
if (alias != null) {
builder.field("alias", alias);
}
if (index != null) {
builder.field("index", index);
}
if (filter != null) {
builder.rawField("filter", filter.getBytes());
}
if (searchRouting != null) {
builder.field("search_routing", searchRouting);
}
if (indexRouting != null) {
builder.field("index_routing", indexRouting);
}
builder.endObject();
builder.endObject();
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:27,代码来源:IndicesAliasesActionHandler.java
示例3: should_create_alias_with_routing
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
@Test
public void should_create_alias_with_routing() throws Exception {
String index = "index_without_alias";
createIndex(index);
ensureGreen(index);
IndicesAliasesRequest request = new IndicesAliasesRequest();
request.addAliasAction(new AliasAction(AliasAction.Type.ADD).alias("the_alias").index(index).searchRouting("the_search_routing").indexRouting("the_index_routing"));
IndicesAliasesResponse response = httpClient.admin().indices().aliases(request).get();
Assertions.assertThat(response.isAcknowledged()).isTrue();
GetAliasesResponse finalState = transportClient.admin().indices().getAliases(new GetAliasesRequest()).actionGet();
Assertions.assertThat(finalState.getAliases().get(index)).hasSize(1);
Assertions.assertThat(finalState.getAliases().get(index).get(0).alias()).isEqualTo("the_alias");
Assertions.assertThat(finalState.getAliases().get(index).get(0).searchRouting()).isEqualTo("the_search_routing");
Assertions.assertThat(finalState.getAliases().get(index).get(0).indexRouting()).isEqualTo("the_index_routing");
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:20,代码来源:IndicesAliasesActionHandlerTest.java
示例4: ShellScope
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
/**
* Creates a new <code>ShellScope</code> given the actual scope object
* @param scope the actual scope object that depends on the engine in use
*/
ShellScope(Scope scope, ResourceRegistry resourceRegistry) {
this.scope = scope;
this.resourceRegistry = resourceRegistry;
registerJavaClass(Requests.class);
registerJavaClass(SearchSourceBuilder.class);
registerJavaClass(QueryBuilders.class);
registerJavaClass(FilterBuilders.class);
registerJavaClass(SortBuilders.class);
registerJavaClass(FacetBuilders.class);
registerJavaClass(RescoreBuilder.class);
registerJavaClass(SuggestBuilder.class);
registerJavaClass(AliasAction.class);
registerJavaClass(HttpParameters.class);
registerJavaClass(AllocateAllocationCommand.class);
registerJavaClass(CancelAllocationCommand.class);
registerJavaClass(MoveAllocationCommand.class);
registerJavaClass(ShardId.class);
}
开发者ID:javanna,项目名称:elasticshell,代码行数:23,代码来源:ShellScope.java
示例5: prepareRolloverAliasesUpdateRequest
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
static IndicesAliasesClusterStateUpdateRequest prepareRolloverAliasesUpdateRequest(String oldIndex, String newIndex,
RolloverRequest request) {
List<AliasAction> actions = unmodifiableList(Arrays.asList(
new AliasAction.Add(newIndex, request.getAlias(), null, null, null),
new AliasAction.Remove(oldIndex, request.getAlias())));
final IndicesAliasesClusterStateUpdateRequest updateRequest = new IndicesAliasesClusterStateUpdateRequest(actions)
.ackTimeout(request.ackTimeout())
.masterNodeTimeout(request.masterNodeTimeout());
return updateRequest;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:TransportRolloverAction.java
示例6: IndicesAliasesClusterStateUpdateRequest
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
public IndicesAliasesClusterStateUpdateRequest(List<AliasAction> actions) {
this.actions = actions;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:IndicesAliasesClusterStateUpdateRequest.java
示例7: actions
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
/**
* Returns the alias actions to be performed
*/
public List<AliasAction> actions() {
return actions;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:IndicesAliasesClusterStateUpdateRequest.java
示例8: handleRequest
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
String alias = request.param("name");
Map<String, Object> filter = null;
String routing = null;
String indexRouting = null;
String searchRouting = null;
if (request.hasContent()) {
try (XContentParser parser = XContentFactory.xContent(request.content()).createParser(request.content())) {
XContentParser.Token token = parser.nextToken();
if (token == null) {
throw new IllegalArgumentException("No index alias is specified");
}
String currentFieldName = null;
while ((token = parser.nextToken()) != null) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if ("index".equals(currentFieldName)) {
indices = Strings.splitStringByCommaToArray(parser.text());
} else if ("alias".equals(currentFieldName)) {
alias = parser.text();
} else if ("routing".equals(currentFieldName)) {
routing = parser.textOrNull();
} else if ("indexRouting".equals(currentFieldName) || "index-routing".equals(currentFieldName) || "index_routing".equals(currentFieldName)) {
indexRouting = parser.textOrNull();
} else if ("searchRouting".equals(currentFieldName) || "search-routing".equals(currentFieldName) || "search_routing".equals(currentFieldName)) {
searchRouting = parser.textOrNull();
}
} else if (token == XContentParser.Token.START_OBJECT) {
if ("filter".equals(currentFieldName)) {
filter = parser.mapOrdered();
}
}
}
}
}
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout()));
String[] aliases = new String[]{alias};
IndicesAliasesRequest.AliasActions aliasAction = new AliasActions(AliasAction.Type.ADD, indices, aliases);
indicesAliasesRequest.addAliasAction(aliasAction);
indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout()));
if (routing != null) {
aliasAction.routing(routing);
}
if (searchRouting != null) {
aliasAction.searchRouting(searchRouting);
}
if (indexRouting != null) {
aliasAction.indexRouting(indexRouting);
}
if (filter != null) {
aliasAction.filter(filter);
}
client.admin().indices().aliases(indicesAliasesRequest, new AcknowledgedRestListener<IndicesAliasesResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:63,代码来源:RestIndexPutAliasAction.java
示例9: actions
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
/**
* Returns the alias actions to be performed
*/
public AliasAction[] actions() {
return actions;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:IndicesAliasesClusterStateUpdateRequest.java
示例10: masterOperation
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
@Override
protected void masterOperation(final IndicesAliasesRequest request, final ClusterState state, final ActionListener<IndicesAliasesResponse> listener) {
//Expand the indices names
List<AliasActions> actions = request.aliasActions();
List<AliasAction> finalActions = new ArrayList<>();
boolean hasOnlyDeletesButNoneCanBeDone = true;
Set<String> aliases = new HashSet<>();
for (AliasActions action : actions) {
//expand indices
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request.indicesOptions(), action.indices());
//collect the aliases
Collections.addAll(aliases, action.aliases());
for (String index : concreteIndices) {
for (String alias : action.concreteAliases(state.metaData(), index)) {
AliasAction finalAction = new AliasAction(action.aliasAction());
finalAction.index(index);
finalAction.alias(alias);
finalActions.add(finalAction);
//if there is only delete requests, none will be added if the types do not map to any existing type
hasOnlyDeletesButNoneCanBeDone = false;
}
}
}
if (hasOnlyDeletesButNoneCanBeDone && actions.size() != 0) {
throw new AliasesNotFoundException(aliases.toArray(new String[aliases.size()]));
}
request.aliasActions().clear();
IndicesAliasesClusterStateUpdateRequest updateRequest = new IndicesAliasesClusterStateUpdateRequest()
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
.actions(finalActions.toArray(new AliasAction[finalActions.size()]));
indexAliasesService.indicesAliases(updateRequest, new ActionListener<ClusterStateUpdateResponse>() {
@Override
public void onResponse(ClusterStateUpdateResponse response) {
listener.onResponse(new IndicesAliasesResponse(response.isAcknowledged()));
}
@Override
public void onFailure(Throwable t) {
logger.debug("failed to perform aliases", t);
listener.onFailure(t);
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:46,代码来源:TransportIndicesAliasesAction.java
示例11: AliasActions
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
public AliasActions(AliasAction.Type type, String[] indices, String[] aliases) {
aliasAction = new AliasAction(type);
indices(indices);
aliases(aliases);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:IndicesAliasesRequest.java
示例12: aliasAction
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
public AliasAction aliasAction() {
return aliasAction;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:IndicesAliasesRequest.java
示例13: addAliasAction
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
public IndicesAliasesRequest addAliasAction(AliasAction action) {
addAliasAction(new AliasActions(action));
return this;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:IndicesAliasesRequest.java
示例14: addAliasAction
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
public UpdateIndicesAliasesRequestBuilder<JsonInput, JsonOutput> addAliasAction(AliasAction aliasAction) {
request.addAliasAction(aliasAction);
return this;
}
开发者ID:javanna,项目名称:elasticshell,代码行数:5,代码来源:UpdateIndicesAliasesRequestBuilder.java
示例15: addAlias
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
/**
* Adds an alias to the index.
*
* @param index The index
* @param alias The alias
* @param filter The filter
*/
public IndicesAliasesRequestBuilder addAlias(String index, String alias, String filter) {
AliasActions action = new AliasActions(AliasAction.Type.ADD, index, alias).filter(filter);
request.addAliasAction(action);
return this;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:IndicesAliasesRequestBuilder.java
示例16: addAliasAction
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
/**
* Adds an alias action to the request.
*
* @param aliasAction The alias action
*/
public IndicesAliasesRequestBuilder addAliasAction(AliasAction aliasAction) {
request.addAliasAction(aliasAction);
return this;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:IndicesAliasesRequestBuilder.java
示例17: addAlias
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
/**
* Adds an alias to the index.
* @param alias The alias
* @param indices The indices
*/
public IndicesAliasesRequest addAlias(String alias, String... indices) {
addAliasAction(new AliasActions(AliasAction.Type.ADD, indices, alias));
return this;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:IndicesAliasesRequest.java
示例18: removeAlias
import org.elasticsearch.cluster.metadata.AliasAction; //导入依赖的package包/类
/**
* Removes an alias to the index.
*
* @param indices The indices
* @param aliases The aliases
*/
public IndicesAliasesRequest removeAlias(String[] indices, String... aliases) {
addAliasAction(new AliasActions(AliasAction.Type.REMOVE, indices, aliases));
return this;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:IndicesAliasesRequest.java
注:本文中的org.elasticsearch.cluster.metadata.AliasAction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论