use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.metadata.AliasMetadata in project elasticsearch by elastic.
the class GetAliasesResponse method readFrom.
@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();
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.metadata.AliasMetadata in project elasticsearch by elastic.
the class GetIndexIT method assertAliases.
private void assertAliases(GetIndexResponse response, String indexName) {
ImmutableOpenMap<String, List<AliasMetaData>> aliases = response.aliases();
assertThat(aliases, notNullValue());
assertThat(aliases.size(), equalTo(1));
List<AliasMetaData> indexAliases = aliases.get(indexName);
assertThat(indexAliases, notNullValue());
assertThat(indexAliases.size(), equalTo(1));
AliasMetaData alias = indexAliases.get(0);
assertThat(alias, notNullValue());
assertThat(alias.alias(), equalTo("alias_idx"));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.metadata.AliasMetadata in project elasticsearch by elastic.
the class AckIT method testIndicesAliasesAcknowledgement.
public void testIndicesAliasesAcknowledgement() {
createIndex("test");
//as the previous operation was acknowledged
for (int i = 0; i < 2; i++) {
assertAcked(client().admin().indices().prepareAliases().addAlias("test", "alias"));
for (Client client : clients()) {
AliasMetaData aliasMetaData = ((AliasOrIndex.Alias) getLocalClusterState(client).metaData().getAliasAndIndexLookup().get("alias")).getFirstAliasMetaData();
assertThat(aliasMetaData.alias(), equalTo("alias"));
}
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.metadata.AliasMetadata in project elasticsearch by elastic.
the class IndexAliasesIT method testSameAlias.
public void testSameAlias() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type", "name", "type=text"));
ensureGreen();
logger.info("--> creating alias1 ");
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1")));
TimeValue timeout = TimeValue.timeValueSeconds(2);
logger.info("--> recreating alias1 ");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1").setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> modifying alias1 to have a filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "foo")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> recreating alias1 with the same filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "foo")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> recreating alias1 with a different filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "bar")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> verify that filter was updated");
AliasMetaData aliasMetaData = ((AliasOrIndex.Alias) internalCluster().clusterService().state().metaData().getAliasAndIndexLookup().get("alias1")).getFirstAliasMetaData();
assertThat(aliasMetaData.getFilter().toString(), equalTo("{\"term\":{\"name\":{\"value\":\"bar\",\"boost\":1.0}}}"));
logger.info("--> deleting alias1");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().removeAlias("test", "alias1").setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.metadata.AliasMetadata in project elasticsearch by elastic.
the class IndexAliasesIT method checkAliases.
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"));
}
Aggregations