summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-01-26 14:32:41 +0100
committerGitHub <noreply@github.com>2017-01-26 14:32:41 +0100
commitffe9587ddbd49e1bc797b20cbe886f4721157910 (patch)
tree4cf0662ccfbc1a01495be703cb72e074d150c5d5 /container-core
parent7c4f0c4cd53d142444e40d66c436da989f263bce (diff)
parent281d7ea9cbd545799afe6876862366e9c20f2fb9 (diff)
Merge pull request #1617 from yahoo/revert-1616-revert-1607-balder/return-timeout-information-up-4
Revert "Revert "Balder/return timeout information up 4""
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/container/handler/Coverage.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/Coverage.java b/container-core/src/main/java/com/yahoo/container/handler/Coverage.java
index fd3c8ed4c49..6c1cfb0fab3 100644
--- a/container-core/src/main/java/com/yahoo/container/handler/Coverage.java
+++ b/container-core/src/main/java/com/yahoo/container/handler/Coverage.java
@@ -12,6 +12,8 @@ public class Coverage {
protected long docs;
protected long active;
+ protected long soonActive;
+ protected int degradedReason;
protected int nodes;
protected int resultSets;
protected int fullResultSets;
@@ -23,6 +25,10 @@ public class Coverage {
EXPLICITLY_FULL, EXPLICITLY_INCOMPLETE, DOCUMENT_COUNT;
}
+ private final static int DEGRADED_BY_MATCH_PHASE = 1;
+ private final static int DEGRADED_BY_TIMEOUT = 2;
+ private final static int DEGRADED_BY_ADAPTIVE_TIMEOUT = 4;
+
/**
* Build an invalid instance to initiate manually.
*/
@@ -46,6 +52,8 @@ public class Coverage {
this.docs = docs;
this.nodes = nodes;
this.active = active;
+ this.soonActive = active;
+ this.degradedReason = 0;
this.resultSets = resultSets;
this.fullReason = fullReason;
this.fullResultSets = getFull() ? resultSets : 0;
@@ -58,6 +66,8 @@ public class Coverage {
docs += other.getDocs();
nodes += other.getNodes();
active += other.getActive();
+ soonActive += other.getSoonActive();
+ degradedReason |= other.degradedReason;
resultSets += other.getResultSets();
fullResultSets += other.getFullResultSets();
@@ -94,6 +104,18 @@ public class Coverage {
public long getActive() { return active; }
/**
+ * Total number of documents that will be searchable once redistribution has settled.
+ *
+ * @return Total number of documents that will soon be available.
+ */
+ public long getSoonActive() { return soonActive; }
+
+ public boolean isDegraded() { return degradedReason != 0; }
+ public boolean isDegradedByMatchPhase() { return (degradedReason & DEGRADED_BY_MATCH_PHASE) != 0; }
+ public boolean isDegradedByTimeout() { return (degradedReason & DEGRADED_BY_TIMEOUT) != 0; }
+ public boolean isDegradedByAdapativeTimeout() { return (degradedReason & DEGRADED_BY_ADAPTIVE_TIMEOUT) != 0; }
+
+ /**
* @return whether the search had full coverage or not
*/
public boolean getFull() {
@@ -151,7 +173,7 @@ public class Coverage {
return 0;
}
if (docs < active) {
- return (int) (docs * 100 / active);
+ return (int) Math.round(docs * 100.0d / active);
}
return getFullResultSets() * 100 / getResultSets();
}