本文整理汇总了Java中org.elasticsearch.cluster.metadata.AliasMetaData类的典型用法代码示例。如果您正苦于以下问题:Java AliasMetaData类的具体用法?Java AliasMetaData怎么用?Java AliasMetaData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AliasMetaData类属于org.elasticsearch.cluster.metadata包,在下文中一共展示了AliasMetaData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTable
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
private Table buildTable(RestRequest request, GetAliasesResponse response) {
Table table = getTableWithHeader(request);
for (ObjectObjectCursor<String, List<AliasMetaData>> cursor : response.getAliases()) {
String indexName = cursor.key;
for (AliasMetaData aliasMetaData : cursor.value) {
table.startRow();
table.addCell(aliasMetaData.alias());
table.addCell(indexName);
table.addCell(aliasMetaData.filteringRequired() ? "*" : "-");
String indexRouting = Strings.hasLength(aliasMetaData.indexRouting()) ? aliasMetaData.indexRouting() : "-";
table.addCell(indexRouting);
String searchRouting = Strings.hasLength(aliasMetaData.searchRouting()) ? aliasMetaData.searchRouting() : "-";
table.addCell(searchRouting);
table.endRow();
}
}
return table;
}
示例2: readFrom
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliasesBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < size; i++) {
String key = in.readString();
int valueSize = in.readVInt();
List<AliasMetaData> value = new ArrayList<>(valueSize);
for (int j = 0; j < valueSize; j++) {
value.add(new AliasMetaData(in));
}
aliasesBuilder.put(key, Collections.unmodifiableList(value));
}
aliases = aliasesBuilder.build();
}
示例3: concreteAliases
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
public String[] concreteAliases(MetaData metaData, String concreteIndex) {
if (expandAliasesWildcards()) {
//for DELETE we expand the aliases
String[] indexAsArray = {concreteIndex};
ImmutableOpenMap<String, List<AliasMetaData>> aliasMetaData = metaData.findAliases(aliases, indexAsArray);
List<String> finalAliases = new ArrayList<>();
for (ObjectCursor<List<AliasMetaData>> curAliases : aliasMetaData.values()) {
for (AliasMetaData aliasMeta: curAliases.value) {
finalAliases.add(aliasMeta.alias());
}
}
return finalAliases.toArray(new String[finalAliases.size()]);
} else {
//for add we just return the current aliases
return aliases;
}
}
示例4: checkAliases
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
private void checkAliases() {
GetAliasesResponse getAliasesResponse = admin().indices().prepareGetAliases("alias1").get();
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
AliasMetaData aliasMetaData = getAliasesResponse.getAliases().get("test").get(0);
assertThat(aliasMetaData.alias(), equalTo("alias1"));
assertThat(aliasMetaData.filter(), nullValue());
assertThat(aliasMetaData.indexRouting(), nullValue());
assertThat(aliasMetaData.searchRouting(), nullValue());
getAliasesResponse = admin().indices().prepareGetAliases("alias2").get();
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
aliasMetaData = getAliasesResponse.getAliases().get("test").get(0);
assertThat(aliasMetaData.alias(), equalTo("alias2"));
assertThat(aliasMetaData.filter(), notNullValue());
assertThat(aliasMetaData.indexRouting(), nullValue());
assertThat(aliasMetaData.searchRouting(), nullValue());
getAliasesResponse = admin().indices().prepareGetAliases("alias3").get();
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
aliasMetaData = getAliasesResponse.getAliases().get("test").get(0);
assertThat(aliasMetaData.alias(), equalTo("alias3"));
assertThat(aliasMetaData.filter(), nullValue());
assertThat(aliasMetaData.indexRouting(), equalTo("index"));
assertThat(aliasMetaData.searchRouting(), equalTo("search"));
}
示例5: readFrom
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliasesBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < size; i++) {
String key = in.readString();
int valueSize = in.readVInt();
List<AliasMetaData> value = new ArrayList<>(valueSize);
for (int j = 0; j < valueSize; j++) {
value.add(AliasMetaData.Builder.readFrom(in));
}
aliasesBuilder.put(key, Collections.unmodifiableList(value));
}
aliases = aliasesBuilder.build();
}
示例6: GetIndexResponse
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
GetIndexResponse(String[] indices, ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> warmers,
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings,
ImmutableOpenMap<String, List<AliasMetaData>> aliases, ImmutableOpenMap<String, Settings> settings) {
this.indices = indices;
if (warmers != null) {
this.warmers = warmers;
}
if (mappings != null) {
this.mappings = mappings;
}
if (aliases != null) {
this.aliases = aliases;
}
if (settings != null) {
this.settings = settings;
}
}
示例7: queryForAlias
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Override
public List<AliasMetaData> queryForAlias(String indexName) {
GetAliases getAliases = new GetAliases.Builder().addIndex(indexName).build();
JestResult result = execute(getAliases);
if (!result.isSucceeded()) {
return Collections.emptyList();
}
Set<Map.Entry<String, JsonElement>> entries = result.getJsonObject().getAsJsonObject(indexName).getAsJsonObject("aliases").entrySet();
List<AliasMetaData> aliases = new ArrayList<>(entries.size());
for (Map.Entry<String, JsonElement> entry : entries) {
aliases.add(AliasMetaData.newAliasMetaDataBuilder(entry.getKey()).build());
}
return aliases;
}
示例8: doParse
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@VisibleForTesting
protected GetAliasesResponse doParse(BytesReference bytesReference) {
try (XContentParser parser = XContentHelper.createParser(bytesReference)) {
ListMultimap<String, AliasMetaData> metaDatas = ArrayListMultimap.create();
XContentParser.Token token;
String currentFieldName = null;
while ((token = parser.nextToken()) != END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == START_OBJECT) {
if (currentFieldName != null) { // we are at an index metadata start
List<AliasMetaData> aliasMetaDatas = parseAliases(parser);
metaDatas.putAll(currentFieldName, aliasMetaDatas);
}
}
}
Map<String, List<AliasMetaData>> map = Multimaps.asMap(metaDatas);
aliases = ImmutableOpenMap.<String, List<AliasMetaData>>builder().putAll(map).build();
return this;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例9: parseAliases
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@VisibleForTesting
protected static List<AliasMetaData> parseAliases(XContentParser parser) {
assert parser.currentToken() == START_OBJECT;
try {
List<AliasMetaData> result = new ArrayList<>();
XContentParser.Token token;
String currentFieldName = null;
while ((token = parser.nextToken()) != END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == START_OBJECT) {
if ("aliases".equals(currentFieldName)) {
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
AliasMetaData metaData = parseAlias(parser);
result.add(metaData);
}
}
}
}
return result;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例10: should_parse_response
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Test
public void should_parse_response() throws Exception {
String json = TestFilesUtils.readFromClasspath("com/github/obourgain/elasticsearch/http/response/admin/indices/aliases/response.json");
GetAliasesResponse aliasesResponse = new GetAliasesResponse().doParse(new BytesArray(json));
ImmutableOpenMap<String, List<AliasMetaData>> aliases = aliasesResponse.getAliases();
assertThat(aliases).hasSize(2);
assertThat(aliases.containsKey("users1")).isTrue();
List<AliasMetaData> alias1 = aliases.get("users1");
assertThat(alias1).hasSize(1);
assertThat(aliases.containsKey("users2")).isTrue();
List<AliasMetaData> alias2 = aliases.get("users2");
assertThat(alias2).hasSize(1);
}
示例11: should_parse_aliases
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Test
public void should_parse_aliases() throws Exception {
String json = TestFilesUtils.readFromClasspath("com/github/obourgain/elasticsearch/http/response/admin/indices/aliases/index_alias_infos.json");
XContentParser parser = XContentHelper.createParser(json.getBytes(), 0, json.length());
parser.nextToken();
List<AliasMetaData> metaDatas = GetAliasesResponse.parseAliases(parser);
assertThat(metaDatas).hasSize(1);
AliasMetaData metaData = metaDatas.get(0);
assertThat(metaData.filteringRequired()).isTrue();
assertThat(metaData.indexRouting()).isEqualTo("foo");
assertThat(metaData.searchRouting()).isEqualTo("foo");
assertThat(metaData.filter().string()).contains("term");
assertThat(metaData.filter().string()).contains("key");
assertThat(metaData.filter().string()).contains("value");
}
示例12: should_parse_alias
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Test
public void should_parse_alias() throws Exception {
String json = TestFilesUtils.readFromClasspath("com/github/obourgain/elasticsearch/http/response/admin/indices/aliases/alias_infos.json");
XContentParser parser = XContentHelper.createParser(json.getBytes(), 0, json.length());
// skip start object and field name
parser.nextToken();
parser.nextToken();
AliasMetaData metaData = GetAliasesResponse.parseAlias(parser);
assertThat(metaData.filteringRequired()).isTrue();
assertThat(metaData.indexRouting()).isEqualTo("foo");
assertThat(metaData.searchRouting()).isEqualTo("foo");
assertThat(metaData.filter().string()).contains("term");
assertThat(metaData.filter().string()).contains("key");
assertThat(metaData.filter().string()).contains("value");
}
示例13: testGetIndexAliases
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Test
public void testGetIndexAliases(){
//Create index
final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
@SuppressWarnings ("unused")
CreateIndexResponse createIndexResponse = createIndexRequestBuilder.execute().actionGet();
//Put the alias
String alias = "test_alias";
IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().addAlias (indexName, alias);
IndicesAliasesResponse response = builder.execute ().actionGet ();
assertTrue(response.isAcknowledged ());
IndexAdminHelper helper = new IndexAdminHelperImpl (client);
List<AliasMetaData> aliases = helper.getIndexAliases (indexName);
if(log.isDebugEnabled ())
for(AliasMetaData aliasMetaData : aliases)
log.debug(String.format("***** Internal Index Name: %s", aliasMetaData.alias ()));
assertEquals (1, aliases.size ());
assertEquals (alias, aliases.get (0).alias ());
}
示例14: testPutIndexAlias
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Test
public void testPutIndexAlias(){
//Create index
final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
@SuppressWarnings ("unused")
CreateIndexResponse createIndexResponse = createIndexRequestBuilder.execute().actionGet();
//Put the alias
String alias = "test_alias";
IndexAdminHelper helper = new IndexAdminHelperImpl (client);
IndicesAliasesResponse response = helper.putIndexAlias (indexName, alias);
assertTrue(response.isAcknowledged ());
GetAliasesRequestBuilder aliasesRequestBuilder = client.admin ().indices ().prepareGetAliases ();
GetAliasesResponse getAliasesResponse = aliasesRequestBuilder.execute ().actionGet ();
List<AliasMetaData> aliases = getAliasesResponse.getAliases ().get (indexName);
if(log.isDebugEnabled ())
for(AliasMetaData aliasMetaData : aliases)
log.debug(String.format("***** Internal Index Name: %s", aliasMetaData.alias ()));
assertEquals (1, aliases.size ());
assertEquals (alias, aliases.get (0).alias ());
}
示例15: toXContent
import org.elasticsearch.cluster.metadata.AliasMetaData; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(ClusterStateRequest request, ClusterStateResponse response, XContentBuilder builder) throws IOException {
MetaData metaData = response.getState().metaData();
builder.startObject();
for (IndexMetaData indexMetaData : metaData) {
builder.startObject(indexMetaData.index(), XContentBuilder.FieldCaseConversion.NONE);
builder.startObject("aliases");
for (AliasMetaData alias : indexMetaData.aliases().values()) {
AliasMetaData.Builder.toXContent(alias, builder, ToXContent.EMPTY_PARAMS);
}
builder.endObject();
builder.endObject();
}
builder.endObject();
return builder;
}