Search in sources :

Example 6 with FlushStats

use of org.opensearch.index.flush.FlushStats in project OpenSearch by opensearch-project.

the class TransportRolloverActionTests method randomIndicesStatsResponse.

public static IndicesStatsResponse randomIndicesStatsResponse(final IndexMetadata[] indices) {
    List<ShardStats> shardStats = new ArrayList<>();
    for (final IndexMetadata index : indices) {
        int numShards = randomIntBetween(1, 3);
        // -1 means there is no primary shard.
        int primaryIdx = randomIntBetween(-1, numShards - 1);
        for (int i = 0; i < numShards; i++) {
            ShardId shardId = new ShardId(index.getIndex(), i);
            boolean primary = (i == primaryIdx);
            Path path = createTempDir().resolve("indices").resolve(index.getIndexUUID()).resolve(String.valueOf(i));
            ShardRouting shardRouting = ShardRouting.newUnassigned(shardId, primary, primary ? RecoverySource.EmptyStoreRecoverySource.INSTANCE : RecoverySource.PeerRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
            shardRouting = shardRouting.initialize("node-0", null, ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE);
            shardRouting = shardRouting.moveToStarted();
            CommonStats stats = new CommonStats();
            stats.fieldData = new FieldDataStats();
            stats.queryCache = new QueryCacheStats();
            stats.docs = new DocsStats();
            stats.store = new StoreStats();
            stats.indexing = new IndexingStats();
            stats.search = new SearchStats();
            stats.segments = new SegmentsStats();
            stats.merge = new MergeStats();
            stats.refresh = new RefreshStats();
            stats.completion = new CompletionStats();
            stats.requestCache = new RequestCacheStats();
            stats.get = new GetStats();
            stats.flush = new FlushStats();
            stats.warmer = new WarmerStats();
            shardStats.add(new ShardStats(shardRouting, new ShardPath(false, path, path, shardId), stats, null, null, null));
        }
    }
    return IndicesStatsTests.newIndicesStatsResponse(shardStats.toArray(new ShardStats[shardStats.size()]), shardStats.size(), shardStats.size(), 0, emptyList());
}
Also used : StoreStats(org.opensearch.index.store.StoreStats) UnassignedInfo(org.opensearch.cluster.routing.UnassignedInfo) RefreshStats(org.opensearch.index.refresh.RefreshStats) ArrayList(java.util.ArrayList) GetStats(org.opensearch.index.get.GetStats) SegmentsStats(org.opensearch.index.engine.SegmentsStats) ShardId(org.opensearch.index.shard.ShardId) CommonStats(org.opensearch.action.admin.indices.stats.CommonStats) FlushStats(org.opensearch.index.flush.FlushStats) ShardPath(org.opensearch.index.shard.ShardPath) QueryCacheStats(org.opensearch.index.cache.query.QueryCacheStats) DocsStats(org.opensearch.index.shard.DocsStats) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) FieldDataStats(org.opensearch.index.fielddata.FieldDataStats) ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) Path(java.nio.file.Path) ShardPath(org.opensearch.index.shard.ShardPath) IndexingStats(org.opensearch.index.shard.IndexingStats) WarmerStats(org.opensearch.index.warmer.WarmerStats) SearchStats(org.opensearch.index.search.stats.SearchStats) MergeStats(org.opensearch.index.merge.MergeStats) ShardRouting(org.opensearch.cluster.routing.ShardRouting) RequestCacheStats(org.opensearch.index.cache.request.RequestCacheStats) CompletionStats(org.opensearch.search.suggest.completion.CompletionStats)

Example 7 with FlushStats

use of org.opensearch.index.flush.FlushStats in project OpenSearch by opensearch-project.

the class RestNodesAction method buildTable.

Table buildTable(boolean fullId, RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) {
    DiscoveryNodes nodes = state.getState().nodes();
    String clusterManagerId = nodes.getMasterNodeId();
    Table table = getTableWithHeader(req);
    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        NodeStats stats = nodesStats.getNodesMap().get(node.getId());
        JvmInfo jvmInfo = info == null ? null : info.getInfo(JvmInfo.class);
        JvmStats jvmStats = stats == null ? null : stats.getJvm();
        FsInfo fsInfo = stats == null ? null : stats.getFs();
        OsStats osStats = stats == null ? null : stats.getOs();
        ProcessStats processStats = stats == null ? null : stats.getProcess();
        NodeIndicesStats indicesStats = stats == null ? null : stats.getIndices();
        table.startRow();
        table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
        table.addCell(info == null ? null : info.getInfo(ProcessInfo.class).getId());
        table.addCell(node.getHostAddress());
        table.addCell(node.getAddress().address().getPort());
        final HttpInfo httpInfo = info == null ? null : info.getInfo(HttpInfo.class);
        if (httpInfo != null) {
            TransportAddress transportAddress = httpInfo.getAddress().publishAddress();
            table.addCell(NetworkAddress.format(transportAddress.address()));
        } else {
            table.addCell("-");
        }
        table.addCell(node.getVersion().toString());
        table.addCell(info == null ? null : info.getBuild().type().displayName());
        table.addCell(info == null ? null : info.getBuild().hash());
        table.addCell(jvmInfo == null ? null : jvmInfo.version());
        ByteSizeValue diskTotal = null;
        ByteSizeValue diskUsed = null;
        ByteSizeValue diskAvailable = null;
        String diskUsedPercent = null;
        if (fsInfo != null) {
            diskTotal = fsInfo.getTotal().getTotal();
            diskAvailable = fsInfo.getTotal().getAvailable();
            diskUsed = new ByteSizeValue(diskTotal.getBytes() - diskAvailable.getBytes());
            double diskUsedRatio = diskTotal.getBytes() == 0 ? 1.0 : (double) diskUsed.getBytes() / diskTotal.getBytes();
            diskUsedPercent = String.format(Locale.ROOT, "%.2f", 100.0 * diskUsedRatio);
        }
        table.addCell(diskTotal);
        table.addCell(diskUsed);
        table.addCell(diskAvailable);
        table.addCell(diskUsedPercent);
        table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsed());
        table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsedPercent());
        table.addCell(jvmInfo == null ? null : jvmInfo.getMem().getHeapMax());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getUsed());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getUsedPercent());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getTotal());
        table.addCell(processStats == null ? null : processStats.getOpenFileDescriptors());
        table.addCell(processStats == null ? null : calculatePercentage(processStats.getOpenFileDescriptors(), processStats.getMaxFileDescriptors()));
        table.addCell(processStats == null ? null : processStats.getMaxFileDescriptors());
        table.addCell(osStats == null ? null : Short.toString(osStats.getCpu().getPercent()));
        boolean hasLoadAverage = osStats != null && osStats.getCpu().getLoadAverage() != null;
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[0] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[0]));
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[1] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[1]));
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[2] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[2]));
        table.addCell(jvmStats == null ? null : jvmStats.getUptime());
        final String roles;
        if (node.getRoles().isEmpty()) {
            roles = "-";
        } else {
            roles = node.getRoles().stream().map(DiscoveryNodeRole::roleNameAbbreviation).sorted().collect(Collectors.joining());
        }
        table.addCell(roles);
        table.addCell(clusterManagerId == null ? "x" : clusterManagerId.equals(node.getId()) ? "*" : "-");
        table.addCell(node.getName());
        CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion();
        table.addCell(completionStats == null ? null : completionStats.getSize());
        FieldDataStats fdStats = indicesStats == null ? null : stats.getIndices().getFieldData();
        table.addCell(fdStats == null ? null : fdStats.getMemorySize());
        table.addCell(fdStats == null ? null : fdStats.getEvictions());
        QueryCacheStats fcStats = indicesStats == null ? null : indicesStats.getQueryCache();
        table.addCell(fcStats == null ? null : fcStats.getMemorySize());
        table.addCell(fcStats == null ? null : fcStats.getEvictions());
        table.addCell(fcStats == null ? null : fcStats.getHitCount());
        table.addCell(fcStats == null ? null : fcStats.getMissCount());
        RequestCacheStats qcStats = indicesStats == null ? null : indicesStats.getRequestCache();
        table.addCell(qcStats == null ? null : qcStats.getMemorySize());
        table.addCell(qcStats == null ? null : qcStats.getEvictions());
        table.addCell(qcStats == null ? null : qcStats.getHitCount());
        table.addCell(qcStats == null ? null : qcStats.getMissCount());
        FlushStats flushStats = indicesStats == null ? null : indicesStats.getFlush();
        table.addCell(flushStats == null ? null : flushStats.getTotal());
        table.addCell(flushStats == null ? null : flushStats.getTotalTime());
        GetStats getStats = indicesStats == null ? null : indicesStats.getGet();
        table.addCell(getStats == null ? null : getStats.current());
        table.addCell(getStats == null ? null : getStats.getTime());
        table.addCell(getStats == null ? null : getStats.getCount());
        table.addCell(getStats == null ? null : getStats.getExistsTime());
        table.addCell(getStats == null ? null : getStats.getExistsCount());
        table.addCell(getStats == null ? null : getStats.getMissingTime());
        table.addCell(getStats == null ? null : getStats.getMissingCount());
        IndexingStats indexingStats = indicesStats == null ? null : indicesStats.getIndexing();
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteCurrent());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteTime());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteCount());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexCurrent());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexTime());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexCount());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexFailedCount());
        MergeStats mergeStats = indicesStats == null ? null : indicesStats.getMerge();
        table.addCell(mergeStats == null ? null : mergeStats.getCurrent());
        table.addCell(mergeStats == null ? null : mergeStats.getCurrentNumDocs());
        table.addCell(mergeStats == null ? null : mergeStats.getCurrentSize());
        table.addCell(mergeStats == null ? null : mergeStats.getTotal());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalNumDocs());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalSize());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalTime());
        RefreshStats refreshStats = indicesStats == null ? null : indicesStats.getRefresh();
        table.addCell(refreshStats == null ? null : refreshStats.getTotal());
        table.addCell(refreshStats == null ? null : refreshStats.getTotalTime());
        table.addCell(refreshStats == null ? null : refreshStats.getExternalTotal());
        table.addCell(refreshStats == null ? null : refreshStats.getExternalTotalTime());
        table.addCell(refreshStats == null ? null : refreshStats.getListeners());
        ScriptStats scriptStats = stats == null ? null : stats.getScriptStats();
        table.addCell(scriptStats == null ? null : scriptStats.getCompilations());
        table.addCell(scriptStats == null ? null : scriptStats.getCacheEvictions());
        table.addCell(scriptStats == null ? null : scriptStats.getCompilationLimitTriggered());
        SearchStats searchStats = indicesStats == null ? null : indicesStats.getSearch();
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchCount());
        table.addCell(searchStats == null ? null : searchStats.getOpenContexts());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryCount());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollCount());
        SegmentsStats segmentsStats = indicesStats == null ? null : indicesStats.getSegments();
        table.addCell(segmentsStats == null ? null : segmentsStats.getCount());
        table.addCell(segmentsStats == null ? null : segmentsStats.getZeroMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getIndexWriterMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getVersionMapMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getBitsetMemory());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestCount());
        table.endRow();
    }
    return table;
}
Also used : DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) JvmInfo(org.opensearch.monitor.jvm.JvmInfo) RefreshStats(org.opensearch.index.refresh.RefreshStats) TransportAddress(org.opensearch.common.transport.TransportAddress) ByteSizeValue(org.opensearch.common.unit.ByteSizeValue) GetStats(org.opensearch.index.get.GetStats) SegmentsStats(org.opensearch.index.engine.SegmentsStats) HttpInfo(org.opensearch.http.HttpInfo) NodeStats(org.opensearch.action.admin.cluster.node.stats.NodeStats) FsInfo(org.opensearch.monitor.fs.FsInfo) FlushStats(org.opensearch.index.flush.FlushStats) QueryCacheStats(org.opensearch.index.cache.query.QueryCacheStats) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) FieldDataStats(org.opensearch.index.fielddata.FieldDataStats) JvmStats(org.opensearch.monitor.jvm.JvmStats) ScriptStats(org.opensearch.script.ScriptStats) ProcessStats(org.opensearch.monitor.process.ProcessStats) Table(org.opensearch.common.Table) IndexingStats(org.opensearch.index.shard.IndexingStats) OsStats(org.opensearch.monitor.os.OsStats) ProcessInfo(org.opensearch.monitor.process.ProcessInfo) SearchStats(org.opensearch.index.search.stats.SearchStats) NodeInfo(org.opensearch.action.admin.cluster.node.info.NodeInfo) MergeStats(org.opensearch.index.merge.MergeStats) NodeIndicesStats(org.opensearch.indices.NodeIndicesStats) RequestCacheStats(org.opensearch.index.cache.request.RequestCacheStats) CompletionStats(org.opensearch.search.suggest.completion.CompletionStats)

Example 8 with FlushStats

use of org.opensearch.index.flush.FlushStats in project OpenSearch by opensearch-project.

the class IndexShardIT method testFlushStats.

public void testFlushStats() throws Exception {
    final IndexService indexService = createIndex("test");
    ensureGreen();
    Settings settings = Settings.builder().put("index.translog.flush_threshold_size", "" + between(200, 300) + "b").build();
    client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
    final int numDocs = between(10, 100);
    for (int i = 0; i < numDocs; i++) {
        client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get();
    }
    // A flush stats may include the new total count but the old period count - assert eventually.
    assertBusy(() -> {
        final FlushStats flushStats = client().admin().indices().prepareStats("test").clear().setFlush(true).get().getTotal().flush;
        assertThat(flushStats.getPeriodic(), allOf(equalTo(flushStats.getTotal()), greaterThan(0L)));
    });
    assertBusy(() -> assertThat(indexService.getShard(0).shouldPeriodicallyFlush(), equalTo(false)));
    settings = Settings.builder().put("index.translog.flush_threshold_size", (String) null).build();
    client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
    client().prepareIndex("test").setId(UUIDs.randomBase64UUID()).setSource("{}", XContentType.JSON).get();
    client().admin().indices().prepareFlush("test").setForce(randomBoolean()).setWaitIfOngoing(true).get();
    final FlushStats flushStats = client().admin().indices().prepareStats("test").clear().setFlush(true).get().getTotal().flush;
    assertThat(flushStats.getTotal(), greaterThan(flushStats.getPeriodic()));
}
Also used : FlushStats(org.opensearch.index.flush.FlushStats) IndexService(org.opensearch.index.IndexService) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings)

Aggregations

FlushStats (org.opensearch.index.flush.FlushStats)8 QueryCacheStats (org.opensearch.index.cache.query.QueryCacheStats)5 SegmentsStats (org.opensearch.index.engine.SegmentsStats)5 FieldDataStats (org.opensearch.index.fielddata.FieldDataStats)5 GetStats (org.opensearch.index.get.GetStats)5 MergeStats (org.opensearch.index.merge.MergeStats)5 RefreshStats (org.opensearch.index.refresh.RefreshStats)5 SearchStats (org.opensearch.index.search.stats.SearchStats)5 CompletionStats (org.opensearch.search.suggest.completion.CompletionStats)5 RequestCacheStats (org.opensearch.index.cache.request.RequestCacheStats)4 DocsStats (org.opensearch.index.shard.DocsStats)4 IndexingStats (org.opensearch.index.shard.IndexingStats)4 StoreStats (org.opensearch.index.store.StoreStats)4 WarmerStats (org.opensearch.index.warmer.WarmerStats)4 CommonStats (org.opensearch.action.admin.indices.stats.CommonStats)3 IndexService (org.opensearch.index.IndexService)3 TranslogStats (org.opensearch.index.translog.TranslogStats)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ShardStats (org.opensearch.action.admin.indices.stats.ShardStats)2