本文整理汇总了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);
}
示例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;
}
示例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);
}