当前位置: 首页>>代码示例>>Java>>正文


Java NodeStats.getProcess方法代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.cluster.node.stats.NodeStats.getProcess方法的典型用法代码示例。如果您正苦于以下问题:Java NodeStats.getProcess方法的具体用法?Java NodeStats.getProcess怎么用?Java NodeStats.getProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.action.admin.cluster.node.stats.NodeStats的用法示例。


在下文中一共展示了NodeStats.getProcess方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addNodeStats

import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; //导入方法依赖的package包/类
public void addNodeStats(NodeStats nodeStats) {
    if (nodeStats.getProcess() == null) {
        return;
    }
    count++;
    if (nodeStats.getProcess().getCpu() != null) {
        cpuPercent += nodeStats.getProcess().getCpu().getPercent();
    }
    long fd = nodeStats.getProcess().getOpenFileDescriptors();
    if (fd > 0) {
        // fd can be -1 if not supported on platform
        totalOpenFileDescriptors += fd;
    }
    // we still do min max calc on -1, so we'll have an indication of it not being supported on one of the nodes.
    minOpenFileDescriptors = Math.min(minOpenFileDescriptors, fd);
    maxOpenFileDescriptors = Math.max(maxOpenFileDescriptors, fd);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:ClusterStatsNodes.java

示例2: ProcessStats

import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; //导入方法依赖的package包/类
/**
 * Build from looking at a list of node statistics.
 */
private ProcessStats(List<NodeStats> nodeStatsList) {
    int count = 0;
    int cpuPercent = 0;
    long totalOpenFileDescriptors = 0;
    long minOpenFileDescriptors = Long.MAX_VALUE;
    long maxOpenFileDescriptors = Long.MIN_VALUE;
    for (NodeStats nodeStats : nodeStatsList) {
        if (nodeStats.getProcess() == null) {
            continue;
        }
        count++;
        if (nodeStats.getProcess().getCpu() != null) {
            cpuPercent += nodeStats.getProcess().getCpu().getPercent();
        }
        long fd = nodeStats.getProcess().getOpenFileDescriptors();
        if (fd > 0) {
            // fd can be -1 if not supported on platform
            totalOpenFileDescriptors += fd;
        }
        // we still do min max calc on -1, so we'll have an indication of it not being supported on one of the nodes.
        minOpenFileDescriptors = Math.min(minOpenFileDescriptors, fd);
        maxOpenFileDescriptors = Math.max(maxOpenFileDescriptors, fd);
    }
    this.count = count;
    this.cpuPercent = cpuPercent;
    this.totalOpenFileDescriptors = totalOpenFileDescriptors;
    this.minOpenFileDescriptors = minOpenFileDescriptors;
    this.maxOpenFileDescriptors = maxOpenFileDescriptors;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:ClusterStatsNodes.java

示例3: execute

import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; //导入方法依赖的package包/类
@Override
public void execute() throws Exception {
    // Only start monitoring if Elasticsearch is started
    if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) {
        String exceptionMsg = "Elasticsearch is not yet started, check back again later";
        logger.info(exceptionMsg);
        return;
    }

    ProcessStatsBean processStatsBean = new ProcessStatsBean();

    try {
        NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config);
        NodeStats nodeStats = null;

        List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes();

        if (nodeStatsList.size() > 0) {
            nodeStats = nodeStatsList.get(0);
        }

        if (nodeStats == null) {
            logger.info("Process stats are not available (node stats is not available)");
            return;
        }

        ProcessStats processStats = nodeStats.getProcess();
        if (processStats == null) {
            logger.info("Process stats are not available");
            return;
        }

        //Memory
        processStatsBean.totalVirtualInBytes = processStats.getMem().getTotalVirtual().getBytes();

        //CPU
        processStatsBean.cpuPercent = processStats.getCpu().getPercent();
        processStatsBean.totalInMillis = processStats.getCpu().getTotal().getMillis();

        //Open file descriptors
        processStatsBean.openFileDescriptors = processStats.getOpenFileDescriptors();

        //Timestamp
        processStatsBean.cpuTimestamp = processStats.getTimestamp();
    } catch (Exception e) {
        logger.warn("Failed to load process stats data", e);
    }

    processStatsReporter.processStatsBean.set(processStatsBean);
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:51,代码来源:ProcessStatsMonitor.java


注:本文中的org.elasticsearch.action.admin.cluster.node.stats.NodeStats.getProcess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。