-
Notifications
You must be signed in to change notification settings - Fork 136
IGNITE-27381 Support MessageService metrics #7488
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
base: main
Are you sure you want to change the base?
Changes from all commits
e0d49a1
5f728a8
04e952c
51ddd76
bdf9a97
dd02706
2e4ba6e
971b305
45b012a
1d7a41e
eaca885
a1e7856
148d3c3
081976a
d01b243
cad0848
3f21c8e
0af060d
bd28a13
46d0000
74780d5
a8b5d2c
cbfdc52
e3188df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,11 @@ | |
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import org.apache.ignite.internal.close.ManuallyCloseable; | ||
| import org.apache.ignite.internal.logger.IgniteLogger; | ||
| import org.apache.ignite.internal.metrics.MetricManager; | ||
| import org.apache.ignite.internal.thread.StripedExecutor; | ||
| import org.apache.ignite.internal.worker.CriticalWorker; | ||
| import org.apache.ignite.internal.worker.CriticalWorkerRegistry; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Collection of {@link StripedExecutor executors} for the network based on {@link ChannelType#id()}. | ||
|
|
@@ -51,11 +53,15 @@ class CriticalStripedExecutors implements ManuallyCloseable { | |
| String poolNamePrefix, | ||
| CriticalWorkerRegistry workerRegistry, | ||
| ChannelTypeRegistry channelTypeRegistry, | ||
| IgniteLogger log | ||
| IgniteLogger log, | ||
| @Nullable MetricManager metricManager, | ||
|
Contributor
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. Why are they nullable?
Contributor
Author
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.
|
||
| @Nullable String metricNamePrefix, | ||
| @Nullable String metricDescription | ||
| ) { | ||
| this.workerRegistry = workerRegistry; | ||
|
|
||
| var factory = new CriticalStripedThreadPoolExecutorFactory(nodeName, poolNamePrefix, log, workerRegistry, registeredWorkers); | ||
| var factory = new CriticalStripedThreadPoolExecutorFactory(nodeName, poolNamePrefix, log, workerRegistry, registeredWorkers, | ||
| metricManager, metricNamePrefix, metricDescription); | ||
|
|
||
| executorByChannelTypeId = StripedExecutorByChannelTypeId.of(channelTypeRegistry, factory); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,9 +21,11 @@ | |
|
|
||
| import java.util.List; | ||
| import org.apache.ignite.internal.logger.IgniteLogger; | ||
| import org.apache.ignite.internal.metrics.MetricManager; | ||
| import org.apache.ignite.internal.worker.CriticalStripedThreadPoolExecutor; | ||
| import org.apache.ignite.internal.worker.CriticalWorker; | ||
| import org.apache.ignite.internal.worker.CriticalWorkerRegistry; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** Factory for creating {@link CriticalStripedThreadPoolExecutor}. */ | ||
| class CriticalStripedThreadPoolExecutorFactory { | ||
|
|
@@ -43,18 +45,45 @@ class CriticalStripedThreadPoolExecutorFactory { | |
|
|
||
| private final List<CriticalWorker> registeredWorkers; | ||
|
|
||
| @Nullable | ||
| private final MetricManager metricManager; | ||
|
|
||
| @Nullable | ||
| private final String metricNamePrefix; | ||
|
|
||
| @Nullable | ||
| private final String metricDescription; | ||
|
Comment on lines
+48
to
+55
Contributor
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. Why are they nullable?
Contributor
Author
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. For similar reasons as decsribed here. |
||
|
|
||
| @SuppressWarnings("unused") | ||
|
Contributor
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. Why is this suppression needed?
Contributor
Author
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. I added a new constructor to pass metrics-related params, but wanted to preserve the old constructor for potential use in places where metrics are deemed unnecessary. Since the old constructor is not used anywhere after the changes in this PR (but I still considered it worthwhile to preserve it), I added the suppression. |
||
| CriticalStripedThreadPoolExecutorFactory( | ||
| String nodeName, | ||
| String poolNamePrefix, | ||
| IgniteLogger log, | ||
| CriticalWorkerRegistry workerRegistry, | ||
| List<CriticalWorker> registeredWorkers | ||
| ) { | ||
| this(nodeName, poolNamePrefix, log, workerRegistry, registeredWorkers, null, null, null); | ||
| } | ||
|
|
||
| CriticalStripedThreadPoolExecutorFactory( | ||
| String nodeName, | ||
| String poolNamePrefix, | ||
| IgniteLogger log, | ||
| CriticalWorkerRegistry workerRegistry, | ||
| List<CriticalWorker> registeredWorkers, | ||
| @Nullable MetricManager metricManager, | ||
| @Nullable String metricNamePrefix, | ||
| @Nullable String metricDescription | ||
| ) { | ||
| this.nodeName = nodeName; | ||
| this.poolNamePrefix = poolNamePrefix; | ||
| this.log = log; | ||
| this.workerRegistry = workerRegistry; | ||
| this.registeredWorkers = registeredWorkers; | ||
|
|
||
| this.metricManager = metricManager; | ||
| this.metricNamePrefix = metricNamePrefix; | ||
| this.metricDescription = metricDescription; | ||
| } | ||
|
|
||
| CriticalStripedThreadPoolExecutor create(ChannelType channelType) { | ||
|
|
@@ -64,6 +93,12 @@ CriticalStripedThreadPoolExecutor create(ChannelType channelType) { | |
| var threadFactory = IgniteMessageServiceThreadFactory.create(nodeName, poolName, log, NOTHING_ALLOWED); | ||
| var executor = new CriticalStripedThreadPoolExecutor(stripeCountForIndex(channelTypeId), threadFactory, false, 0); | ||
|
|
||
| if (metricManager != null && metricNamePrefix != null) { | ||
| String metricName = String.format("%s.%s", metricNamePrefix, channelType.name()); | ||
|
|
||
| executor.initMetricSource(metricManager, metricName, metricDescription); | ||
|
Contributor
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. Can we init metric source on executor creation (in its constructor)?
Contributor
Author
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. We can, but that would require either passing nullable metrics params to the constructor or have two different constructors. I can make the change using the former approach, since it is already used above in
Contributor
Author
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. However, if we stick with the nullable metric-related parameters, I think it is better to use the current approach of null-checks followed by init. |
||
| } | ||
|
|
||
| for (CriticalWorker worker : executor.workers()) { | ||
| workerRegistry.register(worker); | ||
| registeredWorkers.add(worker); | ||
|
|
||
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.
This pattern doesn't look very beautiful, and there is also duplication on top. Let's discuss it higher first and come back here after we are done there