Merge pull request #15252 from jasontedor/indexing-memory-controller-check-idle-simplification
Simplify IndexingMemoryController#checkIdle
This commit is contained in:
commit
3ab7451ca5
|
@ -286,33 +286,23 @@ public class IndexingMemoryController extends AbstractLifecycleComponent<Indexin
|
|||
return System.nanoTime();
|
||||
}
|
||||
|
||||
/** ask this shard to check now whether it is inactive, and reduces its indexing and translog buffers if so. returns Boolean.TRUE if
|
||||
* it did deactive, Boolean.FALSE if it did not, and null if the shard is unknown */
|
||||
protected Boolean checkIdle(IndexShard shard) {
|
||||
String ignoreReason = null; // eclipse compiler does not know it is really final
|
||||
if (shard != null) {
|
||||
/**
|
||||
* ask this shard to check now whether it is inactive, and reduces its indexing and translog buffers if so.
|
||||
* return false if the shard is not idle, otherwise true
|
||||
*/
|
||||
protected boolean checkIdle(IndexShard shard) {
|
||||
try {
|
||||
if (shard.checkIdle()) {
|
||||
boolean idle = shard.checkIdle();
|
||||
if (idle && logger.isDebugEnabled()) {
|
||||
logger.debug("marking shard {} as inactive (inactive_time[{}]) indexing wise",
|
||||
shard.shardId(),
|
||||
shard.getInactiveTime());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
} catch (EngineClosedException e) {
|
||||
// ignore
|
||||
ignoreReason = "EngineClosedException";
|
||||
} catch (FlushNotAllowedEngineException e) {
|
||||
// ignore
|
||||
ignoreReason = "FlushNotAllowedEngineException";
|
||||
return idle;
|
||||
} catch (EngineClosedException | FlushNotAllowedEngineException e) {
|
||||
logger.trace("ignore [{}] while marking shard {} as inactive", e.getClass().getSimpleName(), shard.shardId());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ignoreReason = "shard not found";
|
||||
}
|
||||
if (ignoreReason != null) {
|
||||
logger.trace("ignore [{}] while marking shard {} as inactive", ignoreReason, shard.shardId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -93,11 +93,11 @@ public class IndexingMemoryControllerTests extends ESSingleNodeTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Boolean checkIdle(IndexShard shard) {
|
||||
protected boolean checkIdle(IndexShard shard) {
|
||||
final TimeValue inactiveTime = settings.getAsTime(IndexShard.INDEX_SHARD_INACTIVE_TIME_SETTING, TimeValue.timeValueMinutes(5));
|
||||
Long ns = lastIndexTimeNanos.get(shard);
|
||||
if (ns == null) {
|
||||
return null;
|
||||
return true;
|
||||
} else if (currentTimeInNanos() - ns >= inactiveTime.nanos()) {
|
||||
indexingBuffers.put(shard, INACTIVE);
|
||||
translogBuffers.put(shard, INACTIVE);
|
||||
|
|
Loading…
Reference in New Issue