diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/Pong.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/Pong.java | 31 |
1 files changed, 29 insertions, 2 deletions
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..a6bc3e7975d 100644 --- a/container-search/src/main/java/com/yahoo/prelude/Pong.java +++ b/container-search/src/main/java/com/yahoo/prelude/Pong.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude; +import com.yahoo.fs4.PongPacket; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.statistics.ElapsedTime; @@ -18,19 +19,28 @@ public class Pong { private String pingInfo=""; private final List<ErrorMessage> errors = new ArrayList<>(1); + private final Optional<PongPacket> pongPacket; private ElapsedTime elapsed = new ElapsedTime(); private final Optional<Long> activeDocuments; public Pong() { + this.pongPacket = Optional.empty(); this.activeDocuments = Optional.empty(); } public Pong(ErrorMessage error) { errors.add(error); + this.pongPacket = Optional.empty(); + this.activeDocuments = Optional.empty(); + } + + public Pong(PongPacket pongPacket) { + this.pongPacket = Optional.of(pongPacket); this.activeDocuments = Optional.empty(); } public Pong(long activeDocuments) { + this.pongPacket = Optional.empty(); this.activeDocuments = Optional.of(activeDocuments); } @@ -42,14 +52,21 @@ public class Pong { return errors.get(i); } + public int getErrorSize() { + return errors.size(); + } + /** Returns the number of active documents in the backend responding in this Pong, if available */ public Optional<Long> activeDocuments() { - return activeDocuments; + if (activeDocuments.isPresent()) return activeDocuments; + if ( ! pongPacket.isPresent()) return Optional.empty(); + return pongPacket.get().getActiveDocuments(); } /** Returns the number of nodes which responded to this Pong, if available */ public Optional<Integer> activeNodes() { - return Optional.empty(); + if ( ! pongPacket.isPresent()) return Optional.empty(); + return pongPacket.get().getActiveNodes(); } public List<ErrorMessage> getErrors() { @@ -61,6 +78,16 @@ public class Pong { return ! errors.isEmpty(); } + /** Sets information about the ping used to produce this. This is included when returning the tostring of this. */ + public void setPingInfo(String pingInfo) { + if (pingInfo==null) + pingInfo=""; + this.pingInfo=pingInfo; + } + + /** Returns information about the ping use, or "" (never null) if none */ + public String getPingInfo() { return pingInfo; } + public ElapsedTime getElapsedTime() { return elapsed; } |