diff options
21 files changed, 144 insertions, 101 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsNodesConfigGenerator.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsNodesConfigGenerator.java index 32ecc6e36ba..21fa05ceeab 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsNodesConfigGenerator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsNodesConfigGenerator.java @@ -22,7 +22,7 @@ public class MetricsNodesConfigGenerator { private static MetricsNodesConfig.Node.Builder toNodeBuilder(MetricsProxyContainer container) { var builder = new MetricsNodesConfig.Node.Builder() - .nodeId(container.getHost().getConfigId()) + .role(container.getHost().getConfigId()) .hostname(container.getHostName()) .metricsPort(MetricsProxyContainer.BASEPORT) .metricsPath(MetricsV1Handler.VALUES_PATH); @@ -30,7 +30,7 @@ public class MetricsNodesConfigGenerator { if (container.isHostedVespa) container.getHostResource().spec().membership() .map(ClusterMembership::stringValue) - .ifPresent(builder::nodeId); + .ifPresent(builder::role); return builder; } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java index 3d43f8921a3..6fe69ac5c64 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java @@ -307,7 +307,7 @@ public class MetricsProxyContainerClusterTest { } private void assertNodeConfig(MetricsNodesConfig.Node node) { - assertTrue(node.nodeId().startsWith("container/foo/0/")); + assertTrue(node.role().startsWith("container/foo/0/")); assertTrue(node.hostname().startsWith("node-1-3-9-")); assertEquals(MetricsProxyContainer.BASEPORT, node.metricsPort()); assertEquals(MetricsV1Handler.VALUES_PATH, node.metricsPath()); diff --git a/container-search/src/main/java/com/yahoo/prelude/Ping.java b/container-search/src/main/java/com/yahoo/prelude/Ping.java index dd14e150d95..1d5d4c92827 100644 --- a/container-search/src/main/java/com/yahoo/prelude/Ping.java +++ b/container-search/src/main/java/com/yahoo/prelude/Ping.java @@ -4,7 +4,7 @@ package com.yahoo.prelude; /** * A ping, typically to ask whether backend is alive. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ public class Ping { diff --git a/container-search/src/main/java/com/yahoo/prelude/Pong.java b/container-search/src/main/java/com/yahoo/prelude/Pong.java index a60fba9a4f7..1e5513f1274 100644 --- a/container-search/src/main/java/com/yahoo/prelude/Pong.java +++ b/container-search/src/main/java/com/yahoo/prelude/Pong.java @@ -4,82 +4,102 @@ package com.yahoo.prelude; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.statistics.ElapsedTime; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; /** * An answer from Ping. * - * @author Steinar Knutsen + * @author bratseth */ public class Pong { - private String pingInfo=""; - private final List<ErrorMessage> errors = new ArrayList<>(1); - private ElapsedTime elapsed = new ElapsedTime(); + private final ElapsedTime elapsed = new ElapsedTime(); private final Optional<Long> activeDocuments; + private final boolean isBlockingWrites; + private final Optional<ErrorMessage> error; public Pong() { - this.activeDocuments = Optional.empty(); + this(Optional.empty(), false, Optional.empty()); } public Pong(ErrorMessage error) { - errors.add(error); - this.activeDocuments = Optional.empty(); + this(Optional.empty(), false, Optional.of(error)); } public Pong(long activeDocuments) { - this.activeDocuments = Optional.of(activeDocuments); + this(Optional.of(activeDocuments), false, Optional.empty()); } - public void addError(ErrorMessage error) { - errors.add(error); + public Pong(long activeDocuments, boolean isBlockingWrites) { + this(Optional.of(activeDocuments), isBlockingWrites, Optional.empty()); } - public ErrorMessage getError(int i) { - return errors.get(i); + private Pong(Optional<Long> activeDocuments, boolean isBlockingWrites, Optional<ErrorMessage> error) { + this.activeDocuments = activeDocuments; + this.isBlockingWrites = isBlockingWrites; + this.error = error; } - /** Returns the number of active documents in the backend responding in this Pong, if available */ - public Optional<Long> activeDocuments() { - return activeDocuments; + /** + * @deprecated do not use. Additional errors are ignored. + */ + @Deprecated + public void addError(ErrorMessage error) { } + + /** + * @deprecated use error() instead + */ + @Deprecated + public ErrorMessage getError(int i) { + if (i > 1) throw new IllegalArgumentException("No error at position " + i); + if (i == 0 && error.isEmpty()) throw new IllegalArgumentException("No error at position " + i); + return error.get(); } - /** Returns the number of nodes which responded to this Pong, if available */ + public Optional<ErrorMessage> error() { return error; } + + /** Returns the number of active documents in the backend responding in this Pong, if available */ + public Optional<Long> activeDocuments() { return activeDocuments; } + + /** Returns true if the pinged node is currently blocking write operations due to being full */ + public boolean isBlockingWrites() { return isBlockingWrites; } + + /** + * Returns Optional.empty() + * + * @return empty + * @deprecated do not use. There is always one pong per node. + */ + @Deprecated public Optional<Integer> activeNodes() { return Optional.empty(); } + /** + * Returns a list containing 0 or 1 errors + * + * @deprecated use error() instead + */ + @Deprecated public List<ErrorMessage> getErrors() { - return Collections.unmodifiableList(errors); + return error.stream().collect(Collectors.toList()); } /** Returns whether there is an error or not */ - public boolean badResponse() { - return ! errors.isEmpty(); - } + public boolean badResponse() { return error.isPresent(); } - public ElapsedTime getElapsedTime() { - return elapsed; - } + public ElapsedTime getElapsedTime() { return elapsed; } /** Returns a string which included the ping info (if any) and any errors added to this */ @Override public String toString() { - StringBuilder m = new StringBuilder("Result of pinging"); - if (pingInfo.length() > 0) { - m.append(" using "); - m.append(pingInfo); - } - if (errors.size() > 0) - m.append(" "); - for (int i = 0; i < errors.size(); i++) { - m.append(errors.get(i).toString()); - if ( i <errors.size()-1) - m.append(", "); - } + StringBuilder m = new StringBuilder("Ping result"); + activeDocuments.ifPresent(docCount -> m.append(" active docs: ").append(docCount)); + if (isBlockingWrites) + m.append(" blocking writes: true"); + error.ifPresent(e -> m.append(" error: ").append(error)); return m.toString(); } diff --git a/container-search/src/main/java/com/yahoo/prelude/query/NearItem.java b/container-search/src/main/java/com/yahoo/prelude/query/NearItem.java index 153606e6d99..69131b6c690 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/NearItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/NearItem.java @@ -8,7 +8,7 @@ import java.nio.ByteBuffer; /** - * <p>A set of terms which must be near each other to match.</p> + * A set of terms which must be near each other to match. * * @author bratseth * @author havardpe @@ -18,7 +18,7 @@ public class NearItem extends CompositeItem { protected int distance; /** The default distance used if none is specified: 2 */ - public static final int defaultDistance=2; + public static final int defaultDistance = 2; /** Creates a NEAR item with distance 2 */ public NearItem() { @@ -26,8 +26,7 @@ public class NearItem extends CompositeItem { } /** - * Creates a <i>near</i> item with a limit to the distance - * between the words. + * Creates a <i>near</i> item with a limit to the distance between the words. * * @param distance the number of word position which may separate * the words for this near item to match @@ -47,14 +46,17 @@ public class NearItem extends CompositeItem { return distance; } + @Override public ItemType getItemType() { return ItemType.NEAR; } + @Override public String getName() { return "NEAR"; } + @Override protected void encodeThis(ByteBuffer buffer) { super.encodeThis(buffer); IntegerCompressor.putCompressedPositiveNumber(distance, buffer); @@ -67,6 +69,7 @@ public class NearItem extends CompositeItem { } /** Appends the heading of this string - <code>[getName()]([limit]) </code> */ + @Override protected void appendHeadingString(StringBuilder buffer) { buffer.append(getName()); buffer.append("("); @@ -75,6 +78,7 @@ public class NearItem extends CompositeItem { buffer.append(" "); } + @Override public int hashCode() { return super.hashCode() + 23* distance; } @@ -83,10 +87,11 @@ public class NearItem extends CompositeItem { * Returns whether this item is of the same class and * contains the same state as the given item */ + @Override public boolean equals(Object object) { if (!super.equals(object)) return false; NearItem other = (NearItem) object; // Ensured by superclass - if (this.distance !=other.distance) return false; + if (this.distance != other.distance) return false; return true; } diff --git a/container-search/src/main/java/com/yahoo/prelude/query/ONearItem.java b/container-search/src/main/java/com/yahoo/prelude/query/ONearItem.java index 84e93d5de8f..88982195af6 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/ONearItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/ONearItem.java @@ -25,10 +25,12 @@ public class ONearItem extends NearItem { super(distance); } + @Override public ItemType getItemType() { return ItemType.ONEAR; } + @Override public String getName() { return "ONEAR"; } diff --git a/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java index 06cbf9a9706..20f56c86f7b 100644 --- a/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java @@ -96,7 +96,7 @@ public abstract class ClusterSearcher<T> extends PingableSearcher implements Nod future.cancel(true); if (pong.badResponse()) { - monitor.failed(p, pong.getError(0)); + monitor.failed(p, pong.error().get()); log(LogLevel.FINE, "Failed ping - ", pong); } else { monitor.responded(p); diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/Client.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/Client.java index e54e2187818..bc0a38617ee 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/Client.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/Client.java @@ -13,6 +13,7 @@ import java.util.Optional; * @author bratseth */ interface Client { + /** Creates a connection to a particular node in this */ NodeConnection createConnection(String hostname, int port); @@ -21,6 +22,7 @@ interface Client { } class ResponseOrError<T> { + final Optional<T> response; final Optional<String> error; @@ -93,6 +95,7 @@ interface Client { } class ProtobufResponse { + private final byte compression; private final int uncompressedSize; private final byte[] compressedPayload; @@ -114,6 +117,7 @@ interface Client { public byte[] compressedPayload() { return compressedPayload; } + } } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcPing.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcPing.java index f2e22ba86dc..e0f1dc5e675 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcPing.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcPing.java @@ -18,6 +18,7 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; public class RpcPing implements Callable<Pong> { + private static final String RPC_METHOD = "vespa.searchprotocol.ping"; private static final CompressionType PING_COMPRESSION = CompressionType.NONE; @@ -57,8 +58,7 @@ public class RpcPing implements Callable<Pong> { var ping = SearchProtocol.MonitorRequest.newBuilder().build().toByteArray(); double timeoutSeconds = ((double) clusterMonitor.getConfiguration().getRequestTimeout()) / 1000.0; Compressor.Compression compressionResult = resourcePool.compressor().compress(PING_COMPRESSION, ping); - connection.request(RPC_METHOD, compressionResult.type(), ping.length, compressionResult.data(), rsp -> queue.add(rsp), - timeoutSeconds); + connection.request(RPC_METHOD, compressionResult.type(), ping.length, compressionResult.data(), rsp -> queue.add(rsp), timeoutSeconds); } private Pong decodeReply(ProtobufResponse response) throws InvalidProtocolBufferException { @@ -67,12 +67,13 @@ public class RpcPing implements Callable<Pong> { var reply = SearchProtocol.MonitorReply.parseFrom(responseBytes); if (reply.getDistributionKey() != node.key()) { - return new Pong(ErrorMessage.createBackendCommunicationError( - "Expected pong from node id " + node.key() + ", response is from id " + reply.getDistributionKey())); + return new Pong(ErrorMessage.createBackendCommunicationError("Expected pong from node id " + node.key() + + ", response is from id " + reply.getDistributionKey())); } else if (!reply.getOnline()) { return new Pong(ErrorMessage.createBackendCommunicationError("Node id " + node.key() + " reports being offline")); } else { - return new Pong(reply.getActiveDocs()); + return new Pong(reply.getActiveDocs(), reply.getIsBlockingWrites()); } } + } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java index eff6ae26816..5f211c37917 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java @@ -274,7 +274,7 @@ public class SearchCluster implements NodeManager<Node> { futurePong.cancel(true); if (pong.badResponse()) { - clusterMonitor.failed(node, pong.getError(0)); + clusterMonitor.failed(node, pong.error().get()); } else { if (pong.activeDocuments().isPresent()) { node.setActiveDocuments(pong.activeDocuments().get()); diff --git a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java index 2992d8ab896..8dcc25e4b3b 100644 --- a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java @@ -56,11 +56,10 @@ public class ClusterSearcherTestCase { @Override public Pong ping(Ping ping, Execution execution) { - Pong pong = new Pong(); - if (isBlocking()) { - pong.addError(ErrorMessage.createTimeout("Dummy timeout")); - } - return new Pong(); + if (isBlocking()) + return new Pong(ErrorMessage.createTimeout("Dummy timeout")); + else + return new Pong(); } public boolean isBlocking() { diff --git a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java index c90d2774bd1..a824edd1996 100644 --- a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java @@ -182,10 +182,10 @@ public class ClusteredConnectionTestCase { @Override public Pong ping(Ping ping,Connection connection) { - Pong pong = new Pong(); - if (connection.getResponse() == null) - pong.addError(ErrorMessage.createBackendCommunicationError("No ping response from '" + connection + "'")); - return pong; + if (connection.getResponse() != null) + return new Pong(); + else + return new Pong(ErrorMessage.createBackendCommunicationError("No ping response from '" + connection + "'")); } } diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/Node.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/Node.java index 07070027f96..c8a8e65be5d 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/Node.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/Node.java @@ -13,31 +13,27 @@ import java.util.Objects; */ public class Node { - final String nodeId; - final String host; - final int port; - final String path; + public final String role; + public final String hostname; + private final int port; + private final String path; private final String metricsUriBase; public Node(MetricsNodesConfig.Node nodeConfig) { - this(nodeConfig.nodeId(), nodeConfig.hostname(), nodeConfig.metricsPort() , nodeConfig.metricsPath()); + this(nodeConfig.role(), nodeConfig.hostname(), nodeConfig.metricsPort() , nodeConfig.metricsPath()); } - public Node(String nodeId, String host, int port, String path) { - Objects.requireNonNull(nodeId, "Null configId is not allowed"); - Objects.requireNonNull(host, "Null host is not allowed"); + public Node(String role, String hostname, int port, String path) { + Objects.requireNonNull(role, "Null configId is not allowed"); + Objects.requireNonNull(hostname, "Null hostname is not allowed"); Objects.requireNonNull(path, "Null path is not allowed"); - this.nodeId = nodeId; - this.host = host; + this.role = role; + this.hostname = hostname; this.port = port; this.path = path; - metricsUriBase = "http://" + host + ":" + port + path; - } - - public String getName() { - return nodeId; + metricsUriBase = "http://" + hostname + ":" + port + path; } URI metricsUri(ConsumerId consumer) { @@ -50,12 +46,13 @@ public class Node { if (o == null || getClass() != o.getClass()) return false; Node node = (Node) o; return port == node.port && - nodeId.equals(node.nodeId) && - host.equals(node.host); + path.equals(node.path) && + role.equals(node.role) && + hostname.equals(node.hostname); } @Override public int hashCode() { - return Objects.hash(nodeId, host, port); + return Objects.hash(role, hostname, port, path); } } diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonModel.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonModel.java index bd17a238607..b7abb2c0349 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonModel.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonModel.java @@ -19,11 +19,14 @@ import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_ABSENT; */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(NON_ABSENT) -@JsonPropertyOrder({ "name", "node", "services" }) +@JsonPropertyOrder({ "hostname", "role", "node", "services" }) public class GenericJsonModel { - @JsonProperty("name") - public String name; + @JsonProperty("hostname") + public String hostname; + + @JsonProperty("role") + public String role; @JsonProperty("node") public GenericNode node; diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonUtil.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonUtil.java index a2125abb6a9..e249338c318 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonUtil.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonUtil.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -42,7 +41,7 @@ public class GenericJsonUtil { var genericJsonModels = new ArrayList<GenericJsonModel>(); metricsByNode.forEach( - (node, metrics) -> genericJsonModels.add(toGenericJsonModel(metrics, node.getName()))); + (node, metrics) -> genericJsonModels.add(toGenericJsonModel(metrics, node))); applicationModel.nodes = genericJsonModels; return applicationModel; @@ -52,11 +51,16 @@ public class GenericJsonUtil { return toGenericJsonModel(metricsPackets, null); } - public static GenericJsonModel toGenericJsonModel(List<MetricsPacket> metricsPackets, String nodeName) { + public static GenericJsonModel toGenericJsonModel(List<MetricsPacket> metricsPackets, Node node) { Map<ServiceId, List<MetricsPacket>> packetsByService = metricsPackets.stream() .collect(Collectors.groupingBy(packet -> packet.service, LinkedHashMap::new, toList())); var jsonModel = new GenericJsonModel(); + if (node != null) { + jsonModel.hostname = node.hostname; + jsonModel.role = node.role; + } + var genericServices = new ArrayList<GenericService>(); packetsByService.forEach((serviceId, packets) -> { var genericMetricsList = packets.stream() @@ -72,7 +76,6 @@ public class GenericJsonUtil { .get(); if (VESPA_NODE_SERVICE_ID.equals(serviceId)) { jsonModel.node = new GenericNode(genericService.timestamp, genericService.metrics); - jsonModel.name = nodeName; } else { genericServices.add(genericService); diff --git a/metrics-proxy/src/main/resources/configdefinitions/metrics-nodes.def b/metrics-proxy/src/main/resources/configdefinitions/metrics-nodes.def index 0de2f21d972..ca06148638f 100644 --- a/metrics-proxy/src/main/resources/configdefinitions/metrics-nodes.def +++ b/metrics-proxy/src/main/resources/configdefinitions/metrics-nodes.def @@ -1,7 +1,10 @@ # Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package=ai.vespa.metricsproxy.http.application -node[].nodeId string +# TODO: remove, unused +node[].nodeId string default="" + node[].hostname string +node[].role string node[].metricsPort int node[].metricsPath string diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsHandlerTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsHandlerTest.java index d1224e79e45..074b7877430 100644 --- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsHandlerTest.java +++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsHandlerTest.java @@ -43,7 +43,8 @@ import static org.junit.Assert.fail; @SuppressWarnings("UnstableApiUsage") public class ApplicationMetricsHandlerTest { - private static final String URI_BASE = "http://localhost"; + private static final String HOST = "localhost"; + private static final String URI_BASE = "http://" + HOST; private static final String APP_METRICS_V1_URI = URI_BASE + V1_PATH; private static final String APP_METRICS_VALUES_URI = URI_BASE + VALUES_PATH; @@ -117,7 +118,8 @@ public class ApplicationMetricsHandlerTest { assertEquals(1, jsonModel.nodes.size()); GenericJsonModel nodeModel = jsonModel.nodes.get(0); - assertEquals(MOCK_METRICS_PATH, nodeModel.name); + assertEquals(HOST, nodeModel.hostname); + assertEquals(MOCK_METRICS_PATH, nodeModel.role); assertEquals(2, nodeModel.node.metrics.size()); assertEquals(16.222, nodeModel.node.metrics.get(0).values.get(CPU_METRIC), 0.0001d); } @@ -171,7 +173,7 @@ public class ApplicationMetricsHandlerTest { private MetricsNodesConfig.Node.Builder nodeConfig(String path) { return new MetricsNodesConfig.Node.Builder() - .nodeId(path) + .role(path) .hostname("localhost") .metricsPath(path) .metricsPort(port); diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetrieverTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetrieverTest.java index 5ff6b580988..1f2852e3526 100644 --- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetrieverTest.java +++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetrieverTest.java @@ -157,7 +157,7 @@ public class ApplicationMetricsRetrieverTest { private MetricsNodesConfig.Node.Builder nodeConfig(String path) { return new MetricsNodesConfig.Node.Builder() - .nodeId(path) + .role(path) .hostname(HOST) .metricsPath(path) .metricsPort(port); diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/json/GenericApplicationModelTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/json/GenericApplicationModelTest.java index c0abc3efb86..5a2d374af2e 100644 --- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/json/GenericApplicationModelTest.java +++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/metric/model/json/GenericApplicationModelTest.java @@ -33,7 +33,8 @@ public class GenericApplicationModelTest { // Do some sanity checking assertEquals(2, model.nodes.size()); GenericJsonModel node0Model = model.nodes.get(0); - assertEquals("node0", node0Model.name); + assertEquals("node0", node0Model.hostname); + assertEquals("role0", node0Model.role); assertEquals(1, node0Model.services.size()); GenericService service = node0Model.services.get(0); assertEquals(1, service.metrics.size()); @@ -41,7 +42,8 @@ public class GenericApplicationModelTest { GenericJsonModel node1Model = model.nodes.get(1); GenericNode node1 = node1Model.node; - assertEquals("node1", node1Model.name); + assertEquals("node1", node1Model.hostname); + assertEquals("role1", node1Model.role); assertEquals(32.444, node1.metrics.get(0).values.get("cpu.util"), 0.001d); assertThatSerializedModelEqualsTestFile(model); @@ -63,13 +65,15 @@ public class GenericApplicationModelTest { .build(); - var metricsByNode = Map.of(toNode("node0"), List.of(nodePacket, servicePacket)); + var metricsByNode = Map.of(new Node("my-role", "hostname", 0, "path"), + List.of(nodePacket, servicePacket)); GenericApplicationModel model = GenericJsonUtil.toGenericApplicationModel(metricsByNode); GenericJsonModel nodeModel = model.nodes.get(0); assertNotNull(nodeModel.node); - assertEquals("node0", nodeModel.name); + assertEquals("hostname", nodeModel.hostname); + assertEquals("my-role", nodeModel.role); assertEquals(1, nodeModel.node.metrics.size()); GenericMetrics nodeMetrics = nodeModel.node.metrics.get(0); assertEquals(1.234, nodeMetrics.values.get("node-metric"), 0.001d); @@ -112,7 +116,4 @@ public class GenericApplicationModelTest { return mapper.readValue(getFileContents(TEST_FILE), GenericApplicationModel.class); } - private static Node toNode(String name) { - return new Node(name, "host", 0, "path"); - } } diff --git a/metrics-proxy/src/test/resources/generic-application.json b/metrics-proxy/src/test/resources/generic-application.json index 5ddd11962be..ff529a240db 100644 --- a/metrics-proxy/src/test/resources/generic-application.json +++ b/metrics-proxy/src/test/resources/generic-application.json @@ -1,7 +1,8 @@ { "nodes": [ { - "name": "node0", + "hostname": "node0", + "role": "role0", "node": { "timestamp": 1234, "metrics": [ @@ -36,7 +37,8 @@ ] }, { - "name": "node1", + "hostname": "node1", + "role": "role1", "node": { "timestamp": 1234, "metrics": [ diff --git a/searchlib/src/protobuf/search_protocol.proto b/searchlib/src/protobuf/search_protocol.proto index 6a4d3cfb07a..ded19fe132f 100644 --- a/searchlib/src/protobuf/search_protocol.proto +++ b/searchlib/src/protobuf/search_protocol.proto @@ -88,4 +88,5 @@ message MonitorReply { bool online = 1; int64 active_docs = 2; int32 distribution_key = 3; + bool is_blocking_writes = 4; } |