Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

package org.elasticsearch.action.admin.cluster.stats;

import com.carrotsearch.hppc.ObjectIntHashMap;
import com.carrotsearch.hppc.cursors.ObjectIntCursor;

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
Expand Down Expand Up @@ -239,32 +236,32 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
public static class OsStats implements ToXContentFragment {
final int availableProcessors;
final int allocatedProcessors;
final ObjectIntHashMap<String> names;
final ObjectIntHashMap<String> prettyNames;
final ObjectIntHashMap<String> architectures;
final Map<String, Integer> names;
final Map<String, Integer> prettyNames;
final Map<String, Integer> architectures;
final org.elasticsearch.monitor.os.OsStats.Mem mem;

/**
* Build the stats from information about each node.
*/
private OsStats(List<NodeInfo> nodeInfos, List<NodeStats> nodeStatsList) {
this.names = new ObjectIntHashMap<>();
this.prettyNames = new ObjectIntHashMap<>();
this.architectures = new ObjectIntHashMap<>();
this.names = new HashMap<>();
this.prettyNames = new HashMap<>();
this.architectures = new HashMap<>();
int availableProcessors = 0;
int allocatedProcessors = 0;
for (NodeInfo nodeInfo : nodeInfos) {
availableProcessors += nodeInfo.getInfo(OsInfo.class).getAvailableProcessors();
allocatedProcessors += nodeInfo.getInfo(OsInfo.class).getAllocatedProcessors();

if (nodeInfo.getInfo(OsInfo.class).getName() != null) {
names.addTo(nodeInfo.getInfo(OsInfo.class).getName(), 1);
names.merge(nodeInfo.getInfo(OsInfo.class).getName(), 1, Integer::sum);
}
if (nodeInfo.getInfo(OsInfo.class).getPrettyName() != null) {
prettyNames.addTo(nodeInfo.getInfo(OsInfo.class).getPrettyName(), 1);
prettyNames.merge(nodeInfo.getInfo(OsInfo.class).getPrettyName(), 1, Integer::sum);
}
if (nodeInfo.getInfo(OsInfo.class).getArch() != null) {
architectures.addTo(nodeInfo.getInfo(OsInfo.class).getArch(), 1);
architectures.merge(nodeInfo.getInfo(OsInfo.class).getArch(), 1, Integer::sum);
}
}
this.availableProcessors = availableProcessors;
Expand Down Expand Up @@ -323,35 +320,35 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field(Fields.ALLOCATED_PROCESSORS, allocatedProcessors);
builder.startArray(Fields.NAMES);
{
for (ObjectIntCursor<String> name : names) {
for (var name : names.entrySet()) {
builder.startObject();
{
builder.field(Fields.NAME, name.key);
builder.field(Fields.COUNT, name.value);
builder.field(Fields.NAME, name.getKey());
builder.field(Fields.COUNT, name.getValue());
}
builder.endObject();
}
}
builder.endArray();
builder.startArray(Fields.PRETTY_NAMES);
{
for (final ObjectIntCursor<String> prettyName : prettyNames) {
for (var prettyName : prettyNames.entrySet()) {
builder.startObject();
{
builder.field(Fields.PRETTY_NAME, prettyName.key);
builder.field(Fields.COUNT, prettyName.value);
builder.field(Fields.PRETTY_NAME, prettyName.getKey());
builder.field(Fields.COUNT, prettyName.getValue());
}
builder.endObject();
}
}
builder.endArray();
builder.startArray(Fields.ARCHITECTURES);
{
for (final ObjectIntCursor<String> arch : architectures) {
for (var arch : architectures.entrySet()) {
builder.startObject();
{
builder.field(Fields.ARCH, arch.key);
builder.field(Fields.COUNT, arch.value);
builder.field(Fields.ARCH, arch.getKey());
builder.field(Fields.COUNT, arch.getValue());
}
builder.endObject();
}
Expand Down Expand Up @@ -457,7 +454,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws

public static class JvmStats implements ToXContentFragment {

private final ObjectIntHashMap<JvmVersion> versions;
private final Map<JvmVersion, Integer> versions;
private final long threads;
private final long maxUptime;
private final long heapUsed;
Expand All @@ -467,13 +464,13 @@ public static class JvmStats implements ToXContentFragment {
* Build from lists of information about each node.
*/
private JvmStats(List<NodeInfo> nodeInfos, List<NodeStats> nodeStatsList) {
this.versions = new ObjectIntHashMap<>();
this.versions = new HashMap<>();
long threads = 0;
long maxUptime = 0;
long heapMax = 0;
long heapUsed = 0;
for (NodeInfo nodeInfo : nodeInfos) {
versions.addTo(new JvmVersion(nodeInfo.getInfo(JvmInfo.class)), 1);
versions.merge(new JvmVersion(nodeInfo.getInfo(JvmInfo.class)), 1, Integer::sum);
}

for (NodeStats nodeStats : nodeStatsList) {
Expand All @@ -496,7 +493,7 @@ private JvmStats(List<NodeInfo> nodeInfos, List<NodeStats> nodeStatsList) {
this.heapMax = heapMax;
}

public ObjectIntHashMap<JvmVersion> getVersions() {
public Map<JvmVersion, Integer> getVersions() {
return versions;
}

Expand Down Expand Up @@ -551,15 +548,15 @@ static final class Fields {
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.humanReadableField(Fields.MAX_UPTIME_IN_MILLIS, Fields.MAX_UPTIME, new TimeValue(maxUptime));
builder.startArray(Fields.VERSIONS);
for (ObjectIntCursor<JvmVersion> v : versions) {
for (var v : versions.entrySet()) {
builder.startObject();
builder.field(Fields.VERSION, v.key.version);
builder.field(Fields.VM_NAME, v.key.vmName);
builder.field(Fields.VM_VERSION, v.key.vmVersion);
builder.field(Fields.VM_VENDOR, v.key.vmVendor);
builder.field(Fields.BUNDLED_JDK, v.key.bundledJdk);
builder.field(Fields.USING_BUNDLED_JDK, v.key.usingBundledJdk);
builder.field(Fields.COUNT, v.value);
builder.field(Fields.VERSION, v.getKey().version);
builder.field(Fields.VM_NAME, v.getKey().vmName);
builder.field(Fields.VM_VERSION, v.getKey().vmVersion);
builder.field(Fields.VM_VENDOR, v.getKey().vmVendor);
builder.field(Fields.BUNDLED_JDK, v.getKey().bundledJdk);
builder.field(Fields.USING_BUNDLED_JDK, v.getKey().usingBundledJdk);
builder.field(Fields.COUNT, v.getValue());
builder.endObject();
}
builder.endArray();
Expand Down