-
Notifications
You must be signed in to change notification settings - Fork 25.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename the bulk thread pool to write thread pool #29593
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
package org.elasticsearch.threadpool; | ||
|
||
import org.elasticsearch.common.Booleans; | ||
import org.elasticsearch.common.settings.Setting; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.unit.SizeValue; | ||
|
@@ -38,7 +39,9 @@ | |
public final class FixedExecutorBuilder extends ExecutorBuilder<FixedExecutorBuilder.FixedExecutorSettings> { | ||
|
||
private final Setting<Integer> sizeSetting; | ||
private final Setting<Integer> fallbackSizeSetting; | ||
private final Setting<Integer> queueSizeSetting; | ||
private final Setting<Integer> fallbackQueueSizeSetting; | ||
|
||
/** | ||
* Construct a fixed executor builder; the settings will have the key prefix "thread_pool." followed by the executor name. | ||
|
@@ -52,6 +55,19 @@ public final class FixedExecutorBuilder extends ExecutorBuilder<FixedExecutorBui | |
this(settings, name, size, queueSize, false); | ||
} | ||
|
||
/** | ||
* Construct a fixed executor builder; the settings will have the key prefix "thread_pool." followed by the executor name. | ||
* | ||
* @param settings the node-level settings | ||
* @param name the name of the executor | ||
* @param fallbackName the fallback name of the executor (used for transitioning the name of a setting) | ||
* @param size the fixed number of threads | ||
* @param queueSize the size of the backing queue, -1 for unbounded | ||
*/ | ||
FixedExecutorBuilder(final Settings settings, final String name, final String fallbackName, final int size, final int queueSize) { | ||
this(settings, name, fallbackName, size, queueSize, "thread_pool." + name, "thread_pool." + fallbackName, false); | ||
} | ||
|
||
/** | ||
* Construct a fixed executor builder; the settings will have the key prefix "thread_pool." followed by the executor name. | ||
* | ||
|
@@ -62,7 +78,7 @@ public final class FixedExecutorBuilder extends ExecutorBuilder<FixedExecutorBui | |
* @param deprecated whether or not the thread pool is deprecated | ||
*/ | ||
FixedExecutorBuilder(final Settings settings, final String name, final int size, final int queueSize, final boolean deprecated) { | ||
this(settings, name, size, queueSize, "thread_pool." + name, deprecated); | ||
this(settings, name, null, size, queueSize, "thread_pool." + name, null, deprecated); | ||
} | ||
|
||
/** | ||
|
@@ -75,7 +91,7 @@ public final class FixedExecutorBuilder extends ExecutorBuilder<FixedExecutorBui | |
* @param prefix the prefix for the settings keys | ||
*/ | ||
public FixedExecutorBuilder(final Settings settings, final String name, final int size, final int queueSize, final String prefix) { | ||
this(settings, name, size, queueSize, prefix, false); | ||
this(settings, name, null, size, queueSize, prefix, null, false); | ||
} | ||
|
||
/** | ||
|
@@ -90,31 +106,73 @@ public FixedExecutorBuilder(final Settings settings, final String name, final in | |
private FixedExecutorBuilder( | ||
final Settings settings, | ||
final String name, | ||
final String fallbackName, | ||
final int size, | ||
final int queueSize, | ||
final String prefix, | ||
final String fallbackPrefix, | ||
final boolean deprecated) { | ||
super(name); | ||
final String sizeKey = settingsKey(prefix, "size"); | ||
final Setting.Property[] properties; | ||
if (deprecated) { | ||
properties = new Setting.Property[]{Setting.Property.NodeScope, Setting.Property.Deprecated}; | ||
final String queueSizeKey = settingsKey(prefix, "queue_size"); | ||
if (fallbackName == null) { | ||
final Setting.Property[] properties; | ||
if (deprecated) { | ||
properties = new Setting.Property[]{Setting.Property.NodeScope, Setting.Property.Deprecated}; | ||
} else { | ||
properties = new Setting.Property[]{Setting.Property.NodeScope}; | ||
} | ||
assert fallbackPrefix == null; | ||
this.sizeSetting = sizeSetting(settings, name, size, prefix, properties); | ||
this.fallbackSizeSetting = null; | ||
this.queueSizeSetting = queueSizeSetting(prefix, queueSize, properties); | ||
this.fallbackQueueSizeSetting = null; | ||
} else { | ||
properties = new Setting.Property[]{Setting.Property.NodeScope}; | ||
assert fallbackPrefix != null; | ||
assert deprecated == false; | ||
final Setting.Property[] properties = { Setting.Property.NodeScope }; | ||
final Setting.Property[] fallbackProperties = { Setting.Property.NodeScope, Setting.Property.Deprecated }; | ||
final Setting<Integer> fallbackSizeSetting = sizeSetting(settings, fallbackName, size, fallbackPrefix, fallbackProperties); | ||
this.sizeSetting = | ||
new Setting<>( | ||
new Setting.SimpleKey(sizeKey), | ||
fallbackSizeSetting, | ||
s -> Setting.parseInt(s, 1, applyHardSizeLimit(settings, name), sizeKey), | ||
properties); | ||
this.fallbackSizeSetting = fallbackSizeSetting; | ||
final Setting<Integer> fallbackQueueSizeSetting = queueSizeSetting(fallbackPrefix, queueSize, fallbackProperties); | ||
this.queueSizeSetting = | ||
new Setting<>( | ||
new Setting.SimpleKey(queueSizeKey), | ||
fallbackQueueSizeSetting, | ||
s -> Setting.parseInt(s, Integer.MIN_VALUE, queueSizeKey), | ||
properties); | ||
this.fallbackQueueSizeSetting = fallbackQueueSizeSetting; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
} | ||
this.sizeSetting = | ||
new Setting<>( | ||
sizeKey, | ||
s -> Integer.toString(size), | ||
s -> Setting.parseInt(s, 1, applyHardSizeLimit(settings, name), sizeKey), | ||
properties); | ||
final String queueSizeKey = settingsKey(prefix, "queue_size"); | ||
this.queueSizeSetting = Setting.intSetting(queueSizeKey, queueSize, properties); | ||
} | ||
|
||
private Setting<Integer> sizeSetting( | ||
final Settings settings, final String name, final int size, final String prefix, final Setting.Property[] properties) { | ||
final String sizeKey = settingsKey(prefix, "size"); | ||
return new Setting<>( | ||
sizeKey, | ||
s -> Integer.toString(size), | ||
s -> Setting.parseInt(s, 1, applyHardSizeLimit(settings, name), sizeKey), | ||
properties); | ||
} | ||
|
||
private Setting<Integer> queueSizeSetting(final String prefix, final int queueSize, final Setting.Property[] properties) { | ||
return Setting.intSetting(settingsKey(prefix, "queue_size"), queueSize, properties); | ||
} | ||
|
||
@Override | ||
public List<Setting<?>> getRegisteredSettings() { | ||
return Arrays.asList(sizeSetting, queueSizeSetting); | ||
if (fallbackSizeSetting == null && fallbackQueueSizeSetting == null) { | ||
return Arrays.asList(sizeSetting, queueSizeSetting); | ||
} else { | ||
assert fallbackSizeSetting != null && fallbackQueueSizeSetting != null; | ||
return Arrays.asList(sizeSetting, fallbackSizeSetting, queueSizeSetting, fallbackQueueSizeSetting); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -132,8 +190,14 @@ ThreadPool.ExecutorHolder build(final FixedExecutorSettings settings, final Thre | |
final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(EsExecutors.threadName(settings.nodeName, name())); | ||
final ExecutorService executor = | ||
EsExecutors.newFixed(settings.nodeName + "/" + name(), size, queueSize, threadFactory, threadContext); | ||
final String name; | ||
if ("write".equals(name()) && Booleans.parseBoolean(System.getProperty("es.thread_pool.write.use_bulk_as_display_name", "false"))) { | ||
name = "bulk"; | ||
} else { | ||
name = name(); | ||
} | ||
final ThreadPool.Info info = | ||
new ThreadPool.Info(name(), ThreadPool.ThreadPoolType.FIXED, size, size, null, queueSize < 0 ? null : new SizeValue(queueSize)); | ||
new ThreadPool.Info(name, ThreadPool.ThreadPoolType.FIXED, size, size, null, queueSize < 0 ? null : new SizeValue(queueSize)); | ||
return new ThreadPool.ExecutorHolder(executor, info); | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this could be set above instead of creating a local?