Search in sources :

Example 1 with DistributedRegistry

use of org.apache.hudi.metrics.DistributedRegistry in project hudi by apache.

the class SparkHoodieBackedTableMetadataWriter method initialize.

@Override
protected <T extends SpecificRecordBase> void initialize(HoodieEngineContext engineContext, Option<T> actionMetadata, Option<String> inflightInstantTimestamp) {
    try {
        metrics.map(HoodieMetadataMetrics::registry).ifPresent(registry -> {
            if (registry instanceof DistributedRegistry) {
                HoodieSparkEngineContext sparkEngineContext = (HoodieSparkEngineContext) engineContext;
                ((DistributedRegistry) registry).register(sparkEngineContext.getJavaSparkContext());
            }
        });
        if (enabled) {
            initializeIfNeeded(dataMetaClient, actionMetadata, inflightInstantTimestamp);
        }
    } catch (IOException e) {
        LOG.error("Failed to initialize metadata table. Disabling the writer.", e);
        enabled = false;
    }
}
Also used : DistributedRegistry(org.apache.hudi.metrics.DistributedRegistry) HoodieSparkEngineContext(org.apache.hudi.client.common.HoodieSparkEngineContext) IOException(java.io.IOException)

Example 2 with DistributedRegistry

use of org.apache.hudi.metrics.DistributedRegistry in project hudi by apache.

the class SparkRDDWriteClient method initWrapperFSMetrics.

@Override
protected void initWrapperFSMetrics() {
    if (config.isMetricsOn()) {
        Registry registry;
        Registry registryMeta;
        JavaSparkContext jsc = ((HoodieSparkEngineContext) context).getJavaSparkContext();
        if (config.isExecutorMetricsEnabled()) {
            // Create a distributed registry for HoodieWrapperFileSystem
            registry = Registry.getRegistry(HoodieWrapperFileSystem.class.getSimpleName(), DistributedRegistry.class.getName());
            ((DistributedRegistry) registry).register(jsc);
            registryMeta = Registry.getRegistry(HoodieWrapperFileSystem.class.getSimpleName() + "MetaFolder", DistributedRegistry.class.getName());
            ((DistributedRegistry) registryMeta).register(jsc);
        } else {
            registry = Registry.getRegistry(HoodieWrapperFileSystem.class.getSimpleName());
            registryMeta = Registry.getRegistry(HoodieWrapperFileSystem.class.getSimpleName() + "MetaFolder");
        }
        HoodieWrapperFileSystem.setMetricsRegistry(registry, registryMeta);
    }
}
Also used : HoodieSparkEngineContext(org.apache.hudi.client.common.HoodieSparkEngineContext) DistributedRegistry(org.apache.hudi.metrics.DistributedRegistry) HoodieWrapperFileSystem(org.apache.hudi.common.fs.HoodieWrapperFileSystem) DistributedRegistry(org.apache.hudi.metrics.DistributedRegistry) Registry(org.apache.hudi.common.metrics.Registry) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext)

Aggregations

HoodieSparkEngineContext (org.apache.hudi.client.common.HoodieSparkEngineContext)2 DistributedRegistry (org.apache.hudi.metrics.DistributedRegistry)2 IOException (java.io.IOException)1 HoodieWrapperFileSystem (org.apache.hudi.common.fs.HoodieWrapperFileSystem)1 Registry (org.apache.hudi.common.metrics.Registry)1 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)1