less streams more loops
This commit is contained in:
parent
8034e13365
commit
66a8e4efeb
|
@ -32,7 +32,6 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -86,8 +85,11 @@ public class NodesInfoResponse extends BaseNodesResponse<NodeInfo> implements To
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.array("roles", nodeInfo.getNode().getRoles().stream().map(DiscoveryNode.Role::getRoleName)
|
builder.startArray("roles");
|
||||||
.collect(Collectors.toList()).toArray());
|
for (DiscoveryNode.Role role : nodeInfo.getNode().getRoles()) {
|
||||||
|
builder.value(role.getRoleName());
|
||||||
|
}
|
||||||
|
builder.endArray();
|
||||||
|
|
||||||
if (!nodeInfo.getNode().attributes().isEmpty()) {
|
if (!nodeInfo.getNode().attributes().isEmpty()) {
|
||||||
builder.startObject("attributes");
|
builder.startObject("attributes");
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.elasticsearch.threadpool.ThreadPoolStats;
|
||||||
import org.elasticsearch.transport.TransportStats;
|
import org.elasticsearch.transport.TransportStats;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node statistics (dynamic, changes depending on when created).
|
* Node statistics (dynamic, changes depending on when created).
|
||||||
|
@ -305,8 +304,11 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
||||||
builder.field("host", getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("host", getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE);
|
||||||
builder.field("ip", getNode().getAddress(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("ip", getNode().getAddress(), XContentBuilder.FieldCaseConversion.NONE);
|
||||||
|
|
||||||
builder.array("roles", getNode().getRoles().stream().map(DiscoveryNode.Role::getRoleName)
|
builder.startArray("roles");
|
||||||
.collect(Collectors.toList()).toArray());
|
for (DiscoveryNode.Role role : getNode().getRoles()) {
|
||||||
|
builder.value(role.getRoleName());
|
||||||
|
}
|
||||||
|
builder.endArray();
|
||||||
|
|
||||||
if (!getNode().attributes().isEmpty()) {
|
if (!getNode().attributes().isEmpty()) {
|
||||||
builder.startObject("attributes");
|
builder.startObject("attributes");
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.elasticsearch.action.admin.cluster.node.tasks.list;
|
package org.elasticsearch.action.admin.cluster.node.tasks.list;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||||
|
|
||||||
import org.elasticsearch.action.FailedNodeException;
|
import org.elasticsearch.action.FailedNodeException;
|
||||||
import org.elasticsearch.action.TaskOperationFailure;
|
import org.elasticsearch.action.TaskOperationFailure;
|
||||||
import org.elasticsearch.action.support.tasks.BaseTasksResponse;
|
import org.elasticsearch.action.support.tasks.BaseTasksResponse;
|
||||||
|
@ -39,7 +38,6 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of tasks currently running on the nodes
|
* Returns the list of tasks currently running on the nodes
|
||||||
|
@ -132,8 +130,11 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent {
|
||||||
builder.field("host", node.getHostName());
|
builder.field("host", node.getHostName());
|
||||||
builder.field("ip", node.getAddress());
|
builder.field("ip", node.getAddress());
|
||||||
|
|
||||||
builder.array("roles", node.getRoles().stream().map(DiscoveryNode.Role::getRoleName)
|
builder.startArray("roles");
|
||||||
.collect(Collectors.toList()).toArray());
|
for (DiscoveryNode.Role role : node.getRoles()) {
|
||||||
|
builder.value(role.getRoleName());
|
||||||
|
}
|
||||||
|
builder.endArray();
|
||||||
|
|
||||||
if (!node.attributes().isEmpty()) {
|
if (!node.attributes().isEmpty()) {
|
||||||
builder.startObject("attributes");
|
builder.startObject("attributes");
|
||||||
|
|
Loading…
Reference in New Issue