You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2020/03/05 14:03:23 UTC

[ignite] branch master updated: IGNITE-12748 Export scheduling is moved to onContextInitialized in PushMetricsExporterAdapter

This is an automated email from the ASF dual-hosted git repository.

agura pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new e94df82  IGNITE-12748 Export scheduling is moved to onContextInitialized in PushMetricsExporterAdapter
e94df82 is described below

commit e94df82642f7cc49f3918a9e55b31ac957b17a66
Author: Andrey Gura <ag...@apache.org>
AuthorDate: Wed Mar 4 17:59:55 2020 +0300

    IGNITE-12748 Export scheduling is moved to onContextInitialized in PushMetricsExporterAdapter
---
 .../metric/PushMetricsExporterAdapter.java         | 34 +++++++++++++---------
 .../opencensus/OpenCensusMetricExporterSpi.java    |  2 ++
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/metric/PushMetricsExporterAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/metric/PushMetricsExporterAdapter.java
index 411b405..a8fd532 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/metric/PushMetricsExporterAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/metric/PushMetricsExporterAdapter.java
@@ -22,6 +22,7 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.function.Predicate;
 import org.apache.ignite.spi.IgniteSpiAdapter;
+import org.apache.ignite.spi.IgniteSpiContext;
 import org.apache.ignite.spi.IgniteSpiException;
 import org.apache.ignite.spi.metric.MetricExporterSpi;
 import org.apache.ignite.spi.metric.ReadOnlyMetricRegistry;
@@ -51,19 +52,7 @@ public abstract class PushMetricsExporterAdapter extends IgniteSpiAdapter implem
 
     /** {@inheritDoc} */
     @Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
-        execSvc = Executors.newScheduledThreadPool(1);
-
-        fut = execSvc.scheduleWithFixedDelay(() -> {
-            try {
-                export();
-            }
-            catch (Exception e) {
-                log.error("Metrics export error. " +
-                    "This exporter will be stopped [spiClass=" + getClass() + ",name=" + getName() + ']', e);
-
-                throw e;
-            }
-        }, period, period, MILLISECONDS);
+        // No-op.
     }
 
     /** {@inheritDoc} */
@@ -102,4 +91,23 @@ public abstract class PushMetricsExporterAdapter extends IgniteSpiAdapter implem
     @Override public void setExportFilter(Predicate<ReadOnlyMetricRegistry> filter) {
         this.filter = filter;
     }
+
+    /** {@inheritDoc} */
+    @Override protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
+        super.onContextInitialized0(spiCtx);
+
+        execSvc = Executors.newScheduledThreadPool(1);
+
+        fut = execSvc.scheduleWithFixedDelay(() -> {
+            try {
+                export();
+            }
+            catch (Exception e) {
+                log.error("Metrics export error. " +
+                        "This exporter will be stopped [spiClass=" + getClass() + ",name=" + getName() + ']', e);
+
+                throw e;
+            }
+        }, period, period, MILLISECONDS);
+    }
 }
diff --git a/modules/opencensus/src/main/java/org/apache/ignite/spi/metric/opencensus/OpenCensusMetricExporterSpi.java b/modules/opencensus/src/main/java/org/apache/ignite/spi/metric/opencensus/OpenCensusMetricExporterSpi.java
index d5bfc97..a079e92 100644
--- a/modules/opencensus/src/main/java/org/apache/ignite/spi/metric/opencensus/OpenCensusMetricExporterSpi.java
+++ b/modules/opencensus/src/main/java/org/apache/ignite/spi/metric/opencensus/OpenCensusMetricExporterSpi.java
@@ -291,6 +291,8 @@ public class OpenCensusMetricExporterSpi extends PushMetricsExporterAdapter {
 
     /** {@inheritDoc} */
     @Override protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
+        super.onContextInitialized0(spiCtx);
+
         consistenIdValue = TagValue.create(
             ((IgniteEx)ignite()).context().discovery().localNode().consistentId().toString());
     }