Java Code Examples for org.elasticsearch.index.shard.IndexShard#shardPath()
The following examples show how to use
org.elasticsearch.index.shard.IndexShard#shardPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransportIndexShardStatsAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override protected ShardStats shardOperation(IndexShardStatsRequest request, ShardRouting shardRouting) { IndexService indexService = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()); IndexShard indexShard = indexService.shardSafe(shardRouting.shardId().id()); // if we don't have the routing entry yet, we need it stats wise, we treat it as if the shard is not ready yet if (indexShard.routingEntry() == null) { throw new ShardNotFoundException(indexShard.shardId()); } if (!indexShard.state().equals(IndexShardState.STARTED)) { throw new ElasticsearchException(indexShard.shardId().toString() + " state is " + indexShard.state() + ", not started"); } CommonStatsFlags flags = new CommonStatsFlags().clear(); if (request.dl()) { flags.set(CommonStatsFlags.Flag.DL); } return new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indexShard, flags), indexShard.commitStats()); }
Example 2
Source File: IndicesService.java From Elasticsearch with Apache License 2.0 | 4 votes |
public NodeIndicesStats stats(boolean includePrevious, CommonStatsFlags flags) { CommonStats oldStats = new CommonStats(flags); if (includePrevious) { Flag[] setFlags = flags.getFlags(); for (Flag flag : setFlags) { switch (flag) { case Get: oldStats.get.add(oldShardsStats.getStats); break; case Indexing: oldStats.indexing.add(oldShardsStats.indexingStats); break; case Search: oldStats.search.add(oldShardsStats.searchStats); break; case Merge: oldStats.merge.add(oldShardsStats.mergeStats); break; case Refresh: oldStats.refresh.add(oldShardsStats.refreshStats); break; case Recovery: oldStats.recoveryStats.add(oldShardsStats.recoveryStats); break; case Flush: oldStats.flush.add(oldShardsStats.flushStats); break; } } } Map<Index, List<IndexShardStats>> statsByShard = Maps.newHashMap(); for (IndexServiceInjectorPair value : indices.values()) { IndexService indexService = value.getIndexService(); for (IndexShard indexShard : indexService) { try { if (indexShard.routingEntry() == null) { continue; } IndexShardStats indexShardStats = new IndexShardStats(indexShard.shardId(), new ShardStats[] { new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indexShard, flags), indexShard.commitStats()) }); if (!statsByShard.containsKey(indexService.index())) { statsByShard.put(indexService.index(), arrayAsArrayList(indexShardStats)); } else { statsByShard.get(indexService.index()).add(indexShardStats); } } catch (IllegalIndexShardStateException e) { // we can safely ignore illegal state on ones that are closing for example logger.trace("{} ignoring shard stats", e, indexShard.shardId()); } } } return new NodeIndicesStats(oldStats, statsByShard); }
Example 3
Source File: TransportIndicesStatsAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override protected ShardStats shardOperation(IndicesStatsRequest request, ShardRouting shardRouting) { IndexService indexService = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()); IndexShard indexShard = indexService.shardSafe(shardRouting.shardId().id()); // if we don't have the routing entry yet, we need it stats wise, we treat it as if the shard is not ready yet if (indexShard.routingEntry() == null) { throw new ShardNotFoundException(indexShard.shardId()); } CommonStatsFlags flags = new CommonStatsFlags().clear(); if (request.docs()) { flags.set(CommonStatsFlags.Flag.Docs); } if (request.store()) { flags.set(CommonStatsFlags.Flag.Store); } if (request.indexing()) { flags.set(CommonStatsFlags.Flag.Indexing); flags.types(request.types()); } if (request.get()) { flags.set(CommonStatsFlags.Flag.Get); } if (request.search()) { flags.set(CommonStatsFlags.Flag.Search); flags.groups(request.groups()); } if (request.merge()) { flags.set(CommonStatsFlags.Flag.Merge); } if (request.refresh()) { flags.set(CommonStatsFlags.Flag.Refresh); } if (request.flush()) { flags.set(CommonStatsFlags.Flag.Flush); } if (request.warmer()) { flags.set(CommonStatsFlags.Flag.Warmer); } if (request.queryCache()) { flags.set(CommonStatsFlags.Flag.QueryCache); } if (request.fieldData()) { flags.set(CommonStatsFlags.Flag.FieldData); flags.fieldDataFields(request.fieldDataFields()); } if (request.percolate()) { flags.set(CommonStatsFlags.Flag.Percolate); } if (request.segments()) { flags.set(CommonStatsFlags.Flag.Segments); } if (request.completion()) { flags.set(CommonStatsFlags.Flag.Completion); flags.completionDataFields(request.completionFields()); } if (request.translog()) { flags.set(CommonStatsFlags.Flag.Translog); } if (request.suggest()) { flags.set(CommonStatsFlags.Flag.Suggest); } if (request.requestCache()) { flags.set(CommonStatsFlags.Flag.RequestCache); } if (request.recovery()) { flags.set(CommonStatsFlags.Flag.Recovery); } if (request.dl()) { flags.set(CommonStatsFlags.Flag.DL); } if (request.reindex()) { flags.set(CommonStatsFlags.Flag.Reindex); } return new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indexShard, flags), indexShard.commitStats()); }
Example 4
Source File: TransportIndicesStatsAction.java From crate with Apache License 2.0 | 4 votes |
@Override protected ShardStats shardOperation(IndicesStatsRequest request, ShardRouting shardRouting) { IndexService indexService = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()); IndexShard indexShard = indexService.getShard(shardRouting.shardId().id()); // if we don't have the routing entry yet, we need it stats wise, we treat it as if the shard is not ready yet if (indexShard.routingEntry() == null) { throw new ShardNotFoundException(indexShard.shardId()); } CommonStatsFlags flags = new CommonStatsFlags().clear(); if (request.docs()) { flags.set(CommonStatsFlags.Flag.Docs); } if (request.store()) { flags.set(CommonStatsFlags.Flag.Store); } if (request.completion()) { flags.set(CommonStatsFlags.Flag.Completion); flags.completionDataFields(request.completionFields()); } CommitStats commitStats; SeqNoStats seqNoStats; try { commitStats = indexShard.commitStats(); seqNoStats = indexShard.seqNoStats(); } catch (AlreadyClosedException e) { // shard is closed - no stats is fine commitStats = null; seqNoStats = null; } return new ShardStats( indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indexShard, flags), commitStats, seqNoStats ); }