@Test public void metricsReporterFactoryShouldReturnUserDefinedReporter() { when(config.getMetricReporterClassName()).thenReturn(DummyMetricsReporter.class.getName()); Properties props = new Properties(); props.setProperty("testKey", "testValue"); when(config.getProps()).thenReturn(props); MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry); assertTrue(reporter instanceof AbstractUserDefinedMetricsReporter); assertEquals(props, ((DummyMetricsReporter) reporter).getProps()); assertEquals(registry, ((DummyMetricsReporter) reporter).getRegistry()); }
public static MetricsReporter createReporter(HoodieWriteConfig config, MetricRegistry registry) { MetricsReporterType type = config.getMetricsReporterType(); MetricsReporter reporter = null; if (!StringUtils.isNullOrEmpty(config.getMetricReporterClassName())) { Object instance = ReflectionUtils .loadClass(config.getMetricReporterClassName(), new Class<?>[] {Properties.class, MetricRegistry.class}, config.getProps(), registry); if (!(instance instanceof AbstractUserDefinedMetricsReporter)) { throw new HoodieException(config.getMetricReporterClassName() + " is not a subclass of AbstractUserDefinedMetricsReporter"); } return (MetricsReporter) instance; } switch (type) { case GRAPHITE: reporter = new MetricsGraphiteReporter(config, registry); break; case INMEMORY: reporter = new InMemoryMetricsReporter(); break; case JMX: reporter = new JmxMetricsReporter(config, registry); break; case DATADOG: reporter = new DatadogMetricsReporter(config, registry); break; case PROMETHEUS_PUSHGATEWAY: reporter = new PushGatewayMetricsReporter(config, registry); break; case PROMETHEUS: reporter = new PrometheusReporter(config, registry); break; case CONSOLE: reporter = new ConsoleMetricsReporter(registry); break; default: LOG.error("Reporter type[" + type + "] is not supported."); break; } return reporter; }
MetricsReporterFactory { public static MetricsReporter createReporter(HoodieWriteConfig config, MetricRegistry registry) { MetricsReporterType type = config.getMetricsReporterType(); MetricsReporter reporter = null; if (!StringUtils.isNullOrEmpty(config.getMetricReporterClassName())) { Object instance = ReflectionUtils .loadClass(config.getMetricReporterClassName(), new Class<?>[] {Properties.class, MetricRegistry.class}, config.getProps(), registry); if (!(instance instanceof AbstractUserDefinedMetricsReporter)) { throw new HoodieException(config.getMetricReporterClassName() + " is not a subclass of AbstractUserDefinedMetricsReporter"); } return (MetricsReporter) instance; } switch (type) { case GRAPHITE: reporter = new MetricsGraphiteReporter(config, registry); break; case INMEMORY: reporter = new InMemoryMetricsReporter(); break; case JMX: reporter = new JmxMetricsReporter(config, registry); break; case DATADOG: reporter = new DatadogMetricsReporter(config, registry); break; case PROMETHEUS_PUSHGATEWAY: reporter = new PushGatewayMetricsReporter(config, registry); break; case PROMETHEUS: reporter = new PrometheusReporter(config, registry); break; case CONSOLE: reporter = new ConsoleMetricsReporter(registry); break; default: LOG.error("Reporter type[" + type + "] is not supported."); break; } return reporter; } }
MetricsReporterFactory { public static MetricsReporter createReporter(HoodieWriteConfig config, MetricRegistry registry) { MetricsReporterType type = config.getMetricsReporterType(); MetricsReporter reporter = null; if (!StringUtils.isNullOrEmpty(config.getMetricReporterClassName())) { Object instance = ReflectionUtils .loadClass(config.getMetricReporterClassName(), new Class<?>[] {Properties.class, MetricRegistry.class}, config.getProps(), registry); if (!(instance instanceof AbstractUserDefinedMetricsReporter)) { throw new HoodieException(config.getMetricReporterClassName() + " is not a subclass of AbstractUserDefinedMetricsReporter"); } return (MetricsReporter) instance; } switch (type) { case GRAPHITE: reporter = new MetricsGraphiteReporter(config, registry); break; case INMEMORY: reporter = new InMemoryMetricsReporter(); break; case JMX: reporter = new JmxMetricsReporter(config, registry); break; case DATADOG: reporter = new DatadogMetricsReporter(config, registry); break; case PROMETHEUS_PUSHGATEWAY: reporter = new PushGatewayMetricsReporter(config, registry); break; case PROMETHEUS: reporter = new PrometheusReporter(config, registry); break; case CONSOLE: reporter = new ConsoleMetricsReporter(registry); break; default: LOG.error("Reporter type[" + type + "] is not supported."); break; } return reporter; }  }
MetricsReporterFactory { public static MetricsReporter createReporter(HoodieWriteConfig config, MetricRegistry registry) { MetricsReporterType type = config.getMetricsReporterType(); MetricsReporter reporter = null; if (!StringUtils.isNullOrEmpty(config.getMetricReporterClassName())) { Object instance = ReflectionUtils .loadClass(config.getMetricReporterClassName(), new Class<?>[] {Properties.class, MetricRegistry.class}, config.getProps(), registry); if (!(instance instanceof AbstractUserDefinedMetricsReporter)) { throw new HoodieException(config.getMetricReporterClassName() + " is not a subclass of AbstractUserDefinedMetricsReporter"); } return (MetricsReporter) instance; } switch (type) { case GRAPHITE: reporter = new MetricsGraphiteReporter(config, registry); break; case INMEMORY: reporter = new InMemoryMetricsReporter(); break; case JMX: reporter = new JmxMetricsReporter(config, registry); break; case DATADOG: reporter = new DatadogMetricsReporter(config, registry); break; case PROMETHEUS_PUSHGATEWAY: reporter = new PushGatewayMetricsReporter(config, registry); break; case PROMETHEUS: reporter = new PrometheusReporter(config, registry); break; case CONSOLE: reporter = new ConsoleMetricsReporter(registry); break; default: LOG.error("Reporter type[" + type + "] is not supported."); break; } return reporter; }  static MetricsReporter createReporter(HoodieWriteConfig config, MetricRegistry registry); }
MetricsReporterFactory { public static MetricsReporter createReporter(HoodieWriteConfig config, MetricRegistry registry) { MetricsReporterType type = config.getMetricsReporterType(); MetricsReporter reporter = null; if (!StringUtils.isNullOrEmpty(config.getMetricReporterClassName())) { Object instance = ReflectionUtils .loadClass(config.getMetricReporterClassName(), new Class<?>[] {Properties.class, MetricRegistry.class}, config.getProps(), registry); if (!(instance instanceof AbstractUserDefinedMetricsReporter)) { throw new HoodieException(config.getMetricReporterClassName() + " is not a subclass of AbstractUserDefinedMetricsReporter"); } return (MetricsReporter) instance; } switch (type) { case GRAPHITE: reporter = new MetricsGraphiteReporter(config, registry); break; case INMEMORY: reporter = new InMemoryMetricsReporter(); break; case JMX: reporter = new JmxMetricsReporter(config, registry); break; case DATADOG: reporter = new DatadogMetricsReporter(config, registry); break; case PROMETHEUS_PUSHGATEWAY: reporter = new PushGatewayMetricsReporter(config, registry); break; case PROMETHEUS: reporter = new PrometheusReporter(config, registry); break; case CONSOLE: reporter = new ConsoleMetricsReporter(registry); break; default: LOG.error("Reporter type[" + type + "] is not supported."); break; } return reporter; }  static MetricsReporter createReporter(HoodieWriteConfig config, MetricRegistry registry);  }