本文整理了Java中org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder
类的一些代码示例,展示了IndicesStatsRequestBuilder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IndicesStatsRequestBuilder
类的具体详情如下:
包路径:org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder
类名称:IndicesStatsRequestBuilder
[英]A request to get indices level stats. Allow to enable different stats to be returned.
By default, the #setDocs(boolean), #setStore(boolean), #setIndexing(boolean)are enabled. Other stats can be enabled as well.
All the stats to be returned can be cleared using #clear(), at which point, specific stats can be enabled.
[中]获取索引级别统计信息的请求。允许允许返回不同的统计信息。
默认情况下,将启用#setDocs(布尔值)、#setStore(布尔值)、#setindex(布尔值)。也可以启用其他统计信息。
可以使用#clear()清除要返回的所有统计信息,此时可以启用特定的统计信息。
代码示例来源:origin: SonarSource/sonarqube
@Override
public IndicesStatsResponse get() {
Profiler profiler = Profiler.createIfTrace(EsClient.LOGGER).start();
try {
return super.execute().actionGet();
} catch (Exception e) {
throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
} finally {
if (profiler.isTraceEnabled()) {
profiler.stopTrace(toString());
}
}
}
代码示例来源:origin: SonarSource/sonarqube
private void completeIndexAttributes(ProtobufSystemInfo.Section.Builder protobuf) {
IndicesStatsResponse indicesStats = esClient.prepareStats().all().get();
for (Map.Entry<String, IndexStats> indexStats : indicesStats.getIndices().entrySet()) {
String prefix = "Index " + indexStats.getKey() + " - ";
setAttribute(protobuf, prefix + "Docs", indexStats.getValue().getPrimaries().getDocs().getCount());
setAttribute(protobuf, prefix + "Shards", indexStats.getValue().getShards().length);
setAttribute(protobuf, prefix + "Store Size", byteCountToDisplaySize(indexStats.getValue().getPrimaries().getStore().getSizeInBytes()));
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public IndicesStatsRequestBuilder prepareStats(String... indices) {
return new IndicesStatsRequestBuilder(this, IndicesStatsAction.INSTANCE).setIndices(indices);
}
代码示例来源:origin: apache/usergrid
private long getIndexSize(){
long indexSize = 0L;
final String indexName = indexLocationStrategy.getIndexInitialName();
try {
final IndicesStatsResponse statsResponse = esProvider.getClient()
.admin()
.indices()
.prepareStats(indexName)
.all()
.execute()
.actionGet();
final CommonStats indexStats = statsResponse.getIndex(indexName).getTotal();
indexSize = indexStats.getStore().getSizeInBytes();
} catch (IndexMissingException e) {
// if for some reason the index size does not exist,
// log an error and we can assume size is 0 as it doesn't exist
logger.error("Unable to get size for index {} due to IndexMissingException for app {}",
indexName, indexLocationStrategy.getApplicationScope().getApplication().getUuid());
}
return indexSize;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected void masterOperation(final ResizeRequest resizeRequest, final ClusterState state,
final ActionListener<ResizeResponse> listener) {
// there is no need to fetch docs stats for split but we keep it simple and do it anyway for simplicity of the code
final String sourceIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getSourceIndex());
final String targetIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getTargetIndexRequest().index());
client.admin().indices().prepareStats(sourceIndex).clear().setDocs(true).execute(new ActionListener<IndicesStatsResponse>() {
@Override
public void onResponse(IndicesStatsResponse indicesStatsResponse) {
CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(resizeRequest, state,
(i) -> {
IndexShardStats shard = indicesStatsResponse.getIndex(sourceIndex).getIndexShards().get(i);
return shard == null ? null : shard.getPrimary().getDocs();
}, sourceIndex, targetIndex);
createIndexService.createIndex(
updateRequest,
ActionListener.wrap(response ->
listener.onResponse(new ResizeResponse(response.isAcknowledged(), response.isShardsAcknowledged(),
updateRequest.index())), listener::onFailure
)
);
}
@Override
public void onFailure(Exception e) {
listener.onFailure(e);
}
});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void fail_to_stats() {
try {
es.client().prepareStats("unknown").get();
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(IllegalStateException.class);
assertThat(e.getMessage()).contains("Fail to execute ES indices stats request on indices 'unknown'");
}
}
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
protected void assertSeqNos() throws Exception {
assertBusy(() -> {
IndicesStatsResponse stats = client().admin().indices().prepareStats().clear().get();
for (IndexStats indexStats : stats.getIndices().values()) {
for (IndexShardStats indexShardStats : indexStats.getIndexShards().values()) {
代码示例来源:origin: sirensolutions/siren-join
private QueryCacheStats getQueryCacheStats(String index) {
IndicesStatsResponse statsResponse = client().admin().indices().prepareStats(index).setQueryCache(true).setRefresh(true).get();
return statsResponse.getIndex(index).getTotal().getQueryCache();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public IndicesStatsRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new IndicesStatsRequestBuilder(client, this);
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void to_string() {
assertThat(es.client().prepareStats(FakeIndexDefinition.INDEX).setIndices("rules").toString()).isEqualTo("ES indices stats request on indices 'rules'");
assertThat(es.client().prepareStats().toString()).isEqualTo("ES indices stats request");
}
代码示例来源:origin: org.elasticsearch/elasticsearch
client.admin().indices().prepareStats(sourceIndexName).clear().setDocs(true).execute(
new ActionListener<IndicesStatsResponse>() {
@Override
代码示例来源:origin: SonarSource/sonarqube
@Test
public void get_with_string_timeout_is_not_yet_implemented() {
try {
es.client().prepareStats(FakeIndexDefinition.INDEX).get("1");
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
}
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
public IndicesStatsRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new IndicesStatsRequestBuilder(client, this);
}
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
protected void masterOperation(final ShrinkRequest shrinkRequest, final ClusterState state,
final ActionListener<ShrinkResponse> listener) {
final String sourceIndex = indexNameExpressionResolver.resolveDateMathExpression(shrinkRequest.getSourceIndex());
client.admin().indices().prepareStats(sourceIndex).clear().setDocs(true).execute(new ActionListener<IndicesStatsResponse>() {
@Override
public void onResponse(IndicesStatsResponse indicesStatsResponse) {
CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(shrinkRequest, state,
(i) -> {
IndexShardStats shard = indicesStatsResponse.getIndex(sourceIndex).getIndexShards().get(i);
return shard == null ? null : shard.getPrimary().getDocs();
}, indexNameExpressionResolver);
createIndexService.createIndex(updateRequest, ActionListener.wrap(response ->
listener.onResponse(new ShrinkResponse(response.isAcknowledged(), response.isShardsAcked())), listener::onFailure));
}
@Override
public void onFailure(Exception e) {
listener.onFailure(e);
}
});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void execute_should_throw_an_unsupported_operation_exception() {
try {
es.client().prepareStats(FakeIndexDefinition.INDEX).execute();
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
}
}
代码示例来源:origin: pinterest/soundwave
public Map<String, IndexStats> getIndexStats() throws Exception {
IndicesStatsResponse resp = esClient.admin().indices().prepareStats().all().get();
return resp.getIndices();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void get_with_time_value_timeout_is_not_yet_implemented() {
try {
es.client().prepareStats(FakeIndexDefinition.INDEX).get(TimeValue.timeValueMinutes(1));
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public IndicesStatsRequestBuilder prepareStats(String... indices) {
return new IndicesStatsRequestBuilder(this, IndicesStatsAction.INSTANCE).setIndices(indices);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public IndicesStatsRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new IndicesStatsRequestBuilder(client, this);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
protected void masterOperation(final ResizeRequest resizeRequest, final ClusterState state,
final ActionListener<ResizeResponse> listener) {
// there is no need to fetch docs stats for split but we keep it simple and do it anyway for simplicity of the code
final String sourceIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getSourceIndex());
final String targetIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getTargetIndexRequest().index());
client.admin().indices().prepareStats(sourceIndex).clear().setDocs(true).execute(new ActionListener<IndicesStatsResponse>() {
@Override
public void onResponse(IndicesStatsResponse indicesStatsResponse) {
CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(resizeRequest, state,
(i) -> {
IndexShardStats shard = indicesStatsResponse.getIndex(sourceIndex).getIndexShards().get(i);
return shard == null ? null : shard.getPrimary().getDocs();
}, sourceIndex, targetIndex);
createIndexService.createIndex(
updateRequest,
ActionListener.wrap(response ->
listener.onResponse(new ResizeResponse(response.isAcknowledged(), response.isShardsAcknowledged(),
updateRequest.index())), listener::onFailure
)
);
}
@Override
public void onFailure(Exception e) {
listener.onFailure(e);
}
});
}
内容来源于网络,如有侵权,请联系作者删除!