Search in sources :

Example 1 with InstantiateViaFactory

use of org.apache.flink.metrics.reporter.InstantiateViaFactory in project flink by apache.

the class ReporterSetup method loadViaReflection.

private static Optional<MetricReporter> loadViaReflection(final String reporterClassName, final String reporterName, final Configuration reporterConfig, final Map<String, MetricReporterFactory> reporterFactories) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
    final Class<?> reporterClass = Class.forName(reporterClassName);
    final InstantiateViaFactory alternativeFactoryAnnotation = reporterClass.getAnnotation(InstantiateViaFactory.class);
    if (alternativeFactoryAnnotation != null) {
        final String alternativeFactoryClassName = alternativeFactoryAnnotation.factoryClassName();
        LOG.info("The reporter configuration of {} is out-dated (but still supported)." + " Please configure a factory class instead: '{}{}.{}: {}' to ensure that the configuration" + " continues to work with future versions.", reporterName, ConfigConstants.METRICS_REPORTER_PREFIX, reporterName, ConfigConstants.METRICS_REPORTER_FACTORY_CLASS_SUFFIX, alternativeFactoryClassName);
        return loadViaFactory(alternativeFactoryClassName, reporterName, reporterConfig, reporterFactories);
    }
    return Optional.of((MetricReporter) reporterClass.newInstance());
}
Also used : InstantiateViaFactory(org.apache.flink.metrics.reporter.InstantiateViaFactory)

Aggregations

InstantiateViaFactory (org.apache.flink.metrics.reporter.InstantiateViaFactory)1