Search in sources :

Example 1 with PushMetricsExporterAdapter

use of org.apache.ignite.internal.processors.metric.PushMetricsExporterAdapter in project ignite by apache.

the class ReadMetricsOnNodeStartupTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setGridLogger(listeningLog);
    PushMetricsExporterAdapter adapter = new PushMetricsExporterAdapter() {

        @Override
        public void export() {
            try {
                mreg.forEach(metrics -> {
                    // Read metric value.
                    metrics.forEach(Metric::getAsString);
                });
            } catch (Throwable e) {
                log.error("Exception on metric export", e);
                throw e;
            }
            exportLatch.countDown();
        }
    };
    adapter.setPeriod(EXPORT_TIMEOUT);
    cfg.setMetricExporterSpi(adapter);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Metric(org.apache.ignite.spi.metric.Metric) PushMetricsExporterAdapter(org.apache.ignite.internal.processors.metric.PushMetricsExporterAdapter)

Aggregations

IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 PushMetricsExporterAdapter (org.apache.ignite.internal.processors.metric.PushMetricsExporterAdapter)1 Metric (org.apache.ignite.spi.metric.Metric)1