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.
This commit is contained in:
Adrien Grand 2016-11-16 15:01:05 +01:00 committed by GitHub
parent 6796464f16
commit d7fa2eb155
3 changed files with 18 additions and 6 deletions

View File

@ -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 <code>true</code> 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 {

View File

@ -1224,6 +1224,12 @@ public class InternalEngine extends Engine {
}
}
@Override
public boolean isThrottled() {
return throttle.isThrottled();
}
@Override
public long getIndexThrottleTimeInMillis() {
return throttle.getThrottleTimeInMillis();
}

View File

@ -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");