use of org.elasticsearch.action.admin.indices.stats.ShardStats in project elasticsearch by elastic.
the class IndexStatsIT method assertCumulativeQueryCacheStats.
private void assertCumulativeQueryCacheStats(IndicesStatsResponse response) {
assertAllSuccessful(response);
QueryCacheStats total = response.getTotal().queryCache;
QueryCacheStats indexTotal = new QueryCacheStats();
QueryCacheStats shardTotal = new QueryCacheStats();
for (IndexStats indexStats : response.getIndices().values()) {
indexTotal.add(indexStats.getTotal().queryCache);
for (ShardStats shardStats : response.getShards()) {
shardTotal.add(shardStats.getStats().queryCache);
}
}
assertEquals(total, indexTotal);
assertEquals(total, shardTotal);
}
use of org.elasticsearch.action.admin.indices.stats.ShardStats in project elasticsearch by elastic.
the class FlushIT method testSyncedFlushWithConcurrentIndexing.
public void testSyncedFlushWithConcurrentIndexing() throws Exception {
internalCluster().ensureAtLeastNumDataNodes(3);
createIndex("test");
client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(1, ByteSizeUnit.PB)).put("index.refresh_interval", -1).put("index.number_of_replicas", internalCluster().numDataNodes() - 1)).get();
ensureGreen();
final AtomicBoolean stop = new AtomicBoolean(false);
final AtomicInteger numDocs = new AtomicInteger(0);
Thread indexingThread = new Thread() {
@Override
public void run() {
while (stop.get() == false) {
client().prepareIndex().setIndex("test").setType("doc").setSource("{}", XContentType.JSON).get();
numDocs.incrementAndGet();
}
}
};
indexingThread.start();
IndexStats indexStats = client().admin().indices().prepareStats("test").get().getIndex("test");
for (ShardStats shardStats : indexStats.getShards()) {
assertNull(shardStats.getCommitStats().getUserData().get(Engine.SYNC_COMMIT_ID));
}
logger.info("--> trying sync flush");
SyncedFlushResponse syncedFlushResult = client().admin().indices().prepareSyncedFlush("test").get();
logger.info("--> sync flush done");
stop.set(true);
indexingThread.join();
indexStats = client().admin().indices().prepareStats("test").get().getIndex("test");
assertFlushResponseEqualsShardStats(indexStats.getShards(), syncedFlushResult.getShardsResultPerIndex().get("test"));
refresh();
assertThat(client().prepareSearch().setSize(0).get().getHits().getTotalHits(), equalTo((long) numDocs.get()));
logger.info("indexed {} docs", client().prepareSearch().setSize(0).get().getHits().getTotalHits());
logClusterState();
internalCluster().fullRestart();
ensureGreen();
assertThat(client().prepareSearch().setSize(0).get().getHits().getTotalHits(), equalTo((long) numDocs.get()));
}
use of org.elasticsearch.action.admin.indices.stats.ShardStats in project elasticsearch by elastic.
the class InternalClusterInfoService method buildShardLevelInfo.
static void buildShardLevelInfo(Logger logger, ShardStats[] stats, ImmutableOpenMap.Builder<String, Long> newShardSizes, ImmutableOpenMap.Builder<ShardRouting, String> newShardRoutingToDataPath, ClusterState state) {
MetaData meta = state.getMetaData();
for (ShardStats s : stats) {
IndexMetaData indexMeta = meta.index(s.getShardRouting().index());
newShardRoutingToDataPath.put(s.getShardRouting(), s.getDataPath());
long size = s.getStats().getStore().sizeInBytes();
String sid = ClusterInfo.shardIdentifierFromRouting(s.getShardRouting());
if (logger.isTraceEnabled()) {
logger.trace("shard: {} size: {}", sid, size);
}
if (indexMeta != null && indexMeta.isIndexUsingShadowReplicas()) {
// Shards on a shared filesystem should be considered of size 0
if (logger.isTraceEnabled()) {
logger.trace("shard: {} is using shadow replicas and will be treated as size 0", sid);
}
size = 0;
}
newShardSizes.put(sid, size);
}
}
use of org.elasticsearch.action.admin.indices.stats.ShardStats in project graylog2-server by Graylog2.
the class Indices method getIndexStats.
@Nullable
public IndexStatistics getIndexStats(String index) {
final IndexStats indexStats;
try {
indexStats = indexStats(index);
} catch (ElasticsearchException e) {
return null;
}
if (indexStats == null) {
return null;
}
final ImmutableList.Builder<ShardRouting> shardRouting = ImmutableList.builder();
for (ShardStats shardStats : indexStats.getShards()) {
shardRouting.add(shardStats.getShardRouting());
}
return IndexStatistics.create(indexStats.getIndex(), indexStats.getPrimaries(), indexStats.getTotal(), shardRouting.build());
}
Aggregations