use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class IndicesAdapterES7 method indexCreationDate.
@Override
public Optional<DateTime> indexCreationDate(String index) {
final GetSettingsRequest request = new GetSettingsRequest().indices(index).indicesOptions(IndicesOptions.fromOptions(true, true, true, false));
final GetSettingsResponse result = client.execute((c, requestOptions) -> c.indices().getSettings(request, requestOptions), "Couldn't read settings of index " + index);
final Optional<String> creationDate = Optional.ofNullable(result.getIndexToSettings().get(index)).map(indexSettings -> indexSettings.get("index.creation_date"));
return creationDate.map(Long::valueOf).map(instant -> new DateTime(instant, DateTimeZone.UTC));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class IndicesAdapterES7 method waitForRecovery.
@Override
public HealthStatus waitForRecovery(String index, int timeout) {
final ClusterHealthRequest clusterHealthRequest = new ClusterHealthRequest(index).timeout(TimeValue.timeValueSeconds(timeout));
clusterHealthRequest.waitForGreenStatus();
final ClusterHealthResponse result = client.execute((c, requestOptions) -> c.cluster().health(clusterHealthRequest, requestOptions));
return HealthStatus.fromString(result.getStatus().toString());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class IndicesAdapterES7 method ensureIndexTemplate.
@Override
public boolean ensureIndexTemplate(String templateName, Map<String, Object> template) {
final PutIndexTemplateRequest request = new PutIndexTemplateRequest(templateName).source(template);
final AcknowledgedResponse result = client.execute((c, requestOptions) -> c.indices().putTemplate(request, requestOptions), "Unable to create index template " + templateName);
return result.isAcknowledged();
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class IndicesAdapterES7 method aliases.
@Override
public Map<String, Set<String>> aliases(String indexPattern) {
final GetAliasesRequest request = new GetAliasesRequest().indices(indexPattern).indicesOptions(IndicesOptions.fromOptions(false, false, true, false));
final GetAliasesResponse result = client.execute((c, requestOptions) -> c.indices().getAlias(request, requestOptions), "Couldn't collect aliases for index pattern " + indexPattern);
return result.getAliases().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().stream().map(AliasMetadata::alias).collect(Collectors.toSet())));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class IndexToolsAdapterES7 method count.
@Override
public long count(Set<String> indices, Optional<Set<String>> includedStreams) {
final CountRequest request = new CountRequest(indices.toArray(new String[0]), buildStreamIdFilter(includedStreams)).indicesOptions(IndicesOptions.fromOptions(true, false, true, false));
final CountResponse result = client.execute((c, requestOptions) -> c.count(request, requestOptions), "Unable to count documents of index.");
return result.getCount();
}
Aggregations