From d7fa2eb15588ae11ef2e791cdd41a44a17f85633 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 16 Nov 2016 15:01:05 +0100 Subject: [PATCH] Fix `InternalEngine#isThrottled` to not always return `false`. (#21592) Currently it inherits from the default implementation which always returns `false`, even if indexing is being throttled. --- .../java/org/elasticsearch/index/engine/Engine.java | 8 ++------ .../org/elasticsearch/index/engine/InternalEngine.java | 6 ++++++ .../org/elasticsearch/index/engine/ShadowEngine.java | 10 ++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/engine/Engine.java b/core/src/main/java/org/elasticsearch/index/engine/Engine.java index 0da96def3ef..803187fbbd1 100644 --- a/core/src/main/java/org/elasticsearch/index/engine/Engine.java +++ b/core/src/main/java/org/elasticsearch/index/engine/Engine.java @@ -235,17 +235,13 @@ public abstract class Engine implements Closeable { /** * Returns the number of milliseconds this engine was under index throttling. */ - public long getIndexThrottleTimeInMillis() { - return 0; - } + public abstract long getIndexThrottleTimeInMillis(); /** * Returns the true iff this engine is currently under index throttling. * @see #getIndexThrottleTimeInMillis() */ - public boolean isThrottled() { - return false; - } + public abstract boolean isThrottled(); /** A Lock implementation that always allows the lock to be acquired */ protected static final class NoOpLock implements Lock { diff --git a/core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index 36d5f195905..588d4abe4b5 100644 --- a/core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -1224,6 +1224,12 @@ public class InternalEngine extends Engine { } } + @Override + public boolean isThrottled() { + return throttle.isThrottled(); + } + + @Override public long getIndexThrottleTimeInMillis() { return throttle.getThrottleTimeInMillis(); } diff --git a/core/src/main/java/org/elasticsearch/index/engine/ShadowEngine.java b/core/src/main/java/org/elasticsearch/index/engine/ShadowEngine.java index d84f03e83dd..454850b1e06 100644 --- a/core/src/main/java/org/elasticsearch/index/engine/ShadowEngine.java +++ b/core/src/main/java/org/elasticsearch/index/engine/ShadowEngine.java @@ -256,6 +256,16 @@ public class ShadowEngine extends Engine { throw new UnsupportedOperationException("ShadowEngine has no IndexWriter"); } + @Override + public boolean isThrottled() { + return false; + } + + @Override + public long getIndexThrottleTimeInMillis() { + return 0L; + } + @Override public Engine recoverFromTranslog() throws IOException { throw new UnsupportedOperationException("can't recover on a shadow engine");