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())); } } }
private DocsStats docsStats(final SegmentInfos lastCommittedSegmentInfos) { long numDocs = 0; long numDeletedDocs = 0; long sizeInBytes = 0; if (lastCommittedSegmentInfos != null) { for (SegmentCommitInfo segmentCommitInfo : lastCommittedSegmentInfos) { numDocs += segmentCommitInfo.info.maxDoc() - segmentCommitInfo.getDelCount() - segmentCommitInfo.getSoftDelCount(); numDeletedDocs += segmentCommitInfo.getDelCount() + segmentCommitInfo.getSoftDelCount(); try { sizeInBytes += segmentCommitInfo.sizeInBytes(); } catch (IOException e) { throw new UncheckedIOException("Failed to get size for [" + segmentCommitInfo.info.name + "]", e); } } } return new DocsStats(numDocs, numDeletedDocs, sizeInBytes); }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field(Fields.COUNT, indexCount); shards.toXContent(builder, params); docs.toXContent(builder, params); store.toXContent(builder, params); fieldData.toXContent(builder, params); queryCache.toXContent(builder, params); completion.toXContent(builder, params); segments.toXContent(builder, params); return builder; }
static Map<String, Boolean> evaluateConditions(final Collection<Condition> conditions, final DocsStats docsStats, final IndexMetaData metaData) { final long numDocs = docsStats == null ? 0 : docsStats.getCount(); final long indexSize = docsStats == null ? 0 : docsStats.getTotalSizeInBytes(); final Condition.Stats stats = new Condition.Stats(numDocs, metaData.getCreationDate(), new ByteSizeValue(indexSize)); return conditions.stream() .map(condition -> condition.evaluate(stats)) .collect(Collectors.toMap(result -> result.condition.toString(), result -> result.matched)); }
private void sendDocsStats(String name, DocsStats docsStats) { sendInt(name, "count", docsStats.getCount()); sendInt(name, "deleted", docsStats.getDeleted()); }
private void updateStoreDocs(NodeIndicesStatsBean nodeIndicesStatsBean, NodeIndicesStats nodeIndicesStats) { nodeIndicesStatsBean.storeSize = nodeIndicesStats.getStore().getSizeInBytes(); nodeIndicesStatsBean.storeThrottleTime = nodeIndicesStats.getStore().getThrottleTime().millis(); nodeIndicesStatsBean.docsCount = nodeIndicesStats.getDocs().getCount(); nodeIndicesStatsBean.docsDeleted = nodeIndicesStats.getDocs().getDeleted(); }
static Map<String, Boolean> evaluateConditions(final Collection<Condition> conditions, final DocsStats docsStats, final IndexMetaData metaData) { final long numDocs = docsStats == null ? 0 : docsStats.getCount(); final long indexSize = docsStats == null ? 0 : docsStats.getTotalSizeInBytes(); final Condition.Stats stats = new Condition.Stats(numDocs, metaData.getCreationDate(), new ByteSizeValue(indexSize)); return conditions.stream() .map(condition -> condition.evaluate(stats)) .collect(Collectors.toMap(result -> result.condition.toString(), result -> result.matched)); }
/** * Creates a new search index statistics objects per specified parameters. * * @param settings the search index settings * @param docsStats the search index docs stats * @param indexCount the count of index * * @return the newly created search index statistics object */ protected SearchIndexStatistics createSearchIndexStatistics(Settings settings, DocsStats docsStats, long indexCount) { SearchIndexStatistics searchIndexStatistics = new SearchIndexStatistics(); Long creationDate = settings.getAsLong(IndexMetaData.SETTING_CREATION_DATE, -1L); if (creationDate.longValue() != -1L) { DateTime creationDateTime = new DateTime(creationDate, DateTimeZone.UTC); searchIndexStatistics.setIndexCreationDate(HerdDateUtils.getXMLGregorianCalendarValue(creationDateTime.toDate())); } searchIndexStatistics.setIndexNumberOfActiveDocuments(docsStats.getCount()); searchIndexStatistics.setIndexNumberOfDeletedDocuments(docsStats.getDeleted()); searchIndexStatistics.setIndexUuid(settings.get(IndexMetaData.SETTING_INDEX_UUID)); searchIndexStatistics.setIndexCount(indexCount); return searchIndexStatistics; }
DocsStats docsStats = perShardDocStats.apply(id.id()); if (docsStats != null) { count += docsStats.getCount();
final long numDocs = docsStats == null ? 0 : docsStats.getCount(); final long indexSize = docsStats == null ? 0 : docsStats.getTotalSizeInBytes(); final Condition.Stats stats = new Condition.Stats(numDocs, metaData.getCreationDate(), new ByteSizeValue(indexSize)); return conditions.stream()
protected final DocsStats docsStats(IndexReader indexReader) { long numDocs = 0; long numDeletedDocs = 0; long sizeInBytes = 0; // we don't wait for a pending refreshes here since it's a stats call instead we mark it as accessed only which will cause // the next scheduled refresh to go through and refresh the stats as well for (LeafReaderContext readerContext : indexReader.leaves()) { // we go on the segment level here to get accurate numbers final SegmentReader segmentReader = Lucene.segmentReader(readerContext.reader()); SegmentCommitInfo info = segmentReader.getSegmentInfo(); numDocs += readerContext.reader().numDocs(); numDeletedDocs += readerContext.reader().numDeletedDocs(); try { sizeInBytes += info.sizeInBytes(); } catch (IOException e) { logger.trace(() -> new ParameterizedMessage("failed to get size for [{}]", info.info.name), e); } } return new DocsStats(numDocs, numDeletedDocs, sizeInBytes); }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field(Fields.COUNT, indexCount); shards.toXContent(builder, params); docs.toXContent(builder, params); store.toXContent(builder, params); fieldData.toXContent(builder, params); queryCache.toXContent(builder, params); completion.toXContent(builder, params); segments.toXContent(builder, params); return builder; }
/** * Creates a new search index statistics objects per specified parameters. * * @param settings the search index settings * @param docsStats the search index docs stats * @param indexCount the count of index * * @return the newly created search index statistics object */ protected SearchIndexStatistics createSearchIndexStatistics(Settings settings, DocsStats docsStats, long indexCount) { SearchIndexStatistics searchIndexStatistics = new SearchIndexStatistics(); Long creationDate = settings.getAsLong(IndexMetaData.SETTING_CREATION_DATE, -1L); if (creationDate.longValue() != -1L) { DateTime creationDateTime = new DateTime(creationDate, DateTimeZone.UTC); searchIndexStatistics.setIndexCreationDate(HerdDateUtils.getXMLGregorianCalendarValue(creationDateTime.toDate())); } searchIndexStatistics.setIndexNumberOfActiveDocuments(docsStats.getCount()); searchIndexStatistics.setIndexNumberOfDeletedDocuments(docsStats.getDeleted()); searchIndexStatistics.setIndexUuid(settings.get(IndexMetaData.SETTING_INDEX_UUID)); searchIndexStatistics.setIndexCount(indexCount); return searchIndexStatistics; }
static Set<Condition.Result> evaluateConditions(final Set<Condition> conditions, final DocsStats docsStats, final IndexMetaData metaData) { final long numDocs = docsStats == null ? 0 : docsStats.getCount(); final Condition.Stats stats = new Condition.Stats(numDocs, metaData.getCreationDate()); return conditions.stream() .map(condition -> condition.evaluate(stats)) .collect(Collectors.toSet()); }
switch (flag) { case Docs: docs = new DocsStats(); break; case Store: