Search in sources :

Example 1 with Registry

use of org.apache.hudi.common.metrics.Registry in project hudi by apache.

the class TestRegistry method testGetRegistry.

@Test
public void testGetRegistry() throws Exception {
    Registry r = Registry.getRegistry("testGetRegistry_1");
    assertEquals(r, Registry.getRegistry("testGetRegistry_1"));
}
Also used : Registry(org.apache.hudi.common.metrics.Registry) Test(org.junit.jupiter.api.Test)

Example 2 with Registry

use of org.apache.hudi.common.metrics.Registry in project hudi by apache.

the class TestRegistry method testCounts.

@Test
public void testCounts() throws Exception {
    Registry r = Registry.getRegistry("testCounts");
    Map<String, Long> countsMap = new HashMap<>();
    countsMap.put("one", 1L);
    countsMap.put("two", 2L);
    registerMetrics(countsMap, r);
    assertEquals(countsMap, r.getAllCounts());
}
Also used : HashMap(java.util.HashMap) Registry(org.apache.hudi.common.metrics.Registry) Test(org.junit.jupiter.api.Test)

Example 3 with Registry

use of org.apache.hudi.common.metrics.Registry in project hudi by apache.

the class TestHoodieBackedMetadata method testMetadataMetrics.

/**
 * Test various metrics published by metadata table.
 */
@Test
public void testMetadataMetrics() throws Exception {
    init(HoodieTableType.COPY_ON_WRITE, false);
    HoodieSparkEngineContext engineContext = new HoodieSparkEngineContext(jsc);
    try (SparkRDDWriteClient client = new SparkRDDWriteClient(engineContext, getWriteConfigBuilder(true, true, true).build())) {
        // Write
        String newCommitTime = HoodieActiveTimeline.createNewInstantTime();
        List<HoodieRecord> records = dataGen.generateInserts(newCommitTime, 20);
        client.startCommitWithTime(newCommitTime);
        List<WriteStatus> writeStatuses = client.insert(jsc.parallelize(records, 1), newCommitTime).collect();
        assertNoWriteErrors(writeStatuses);
        validateMetadata(client);
        Registry metricsRegistry = Registry.getRegistry("HoodieMetadata");
        assertTrue(metricsRegistry.getAllCounts().containsKey(HoodieMetadataMetrics.INITIALIZE_STR + ".count"));
        assertTrue(metricsRegistry.getAllCounts().containsKey(HoodieMetadataMetrics.INITIALIZE_STR + ".totalDuration"));
        assertTrue(metricsRegistry.getAllCounts().get(HoodieMetadataMetrics.INITIALIZE_STR + ".count") >= 1L);
        final String prefix = MetadataPartitionType.FILES.getPartitionPath() + ".";
        assertTrue(metricsRegistry.getAllCounts().containsKey(prefix + HoodieMetadataMetrics.STAT_COUNT_BASE_FILES));
        assertTrue(metricsRegistry.getAllCounts().containsKey(prefix + HoodieMetadataMetrics.STAT_COUNT_LOG_FILES));
        assertTrue(metricsRegistry.getAllCounts().containsKey(prefix + HoodieMetadataMetrics.STAT_TOTAL_BASE_FILE_SIZE));
        assertTrue(metricsRegistry.getAllCounts().containsKey(prefix + HoodieMetadataMetrics.STAT_TOTAL_LOG_FILE_SIZE));
    }
}
Also used : HoodieSparkEngineContext(org.apache.hudi.client.common.HoodieSparkEngineContext) SparkRDDWriteClient(org.apache.hudi.client.SparkRDDWriteClient) HoodieRecord(org.apache.hudi.common.model.HoodieRecord) Registry(org.apache.hudi.common.metrics.Registry) MetadataMergeWriteStatus(org.apache.hudi.testutils.MetadataMergeWriteStatus) WriteStatus(org.apache.hudi.client.WriteStatus) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 4 with Registry

use of org.apache.hudi.common.metrics.Registry in project hudi by apache.

the class SparkHoodieBackedTableMetadataWriter method initRegistry.

@Override
protected void initRegistry() {
    if (metadataWriteConfig.isMetricsOn()) {
        Registry registry;
        if (metadataWriteConfig.isExecutorMetricsEnabled()) {
            registry = Registry.getRegistry("HoodieMetadata", DistributedRegistry.class.getName());
        } else {
            registry = Registry.getRegistry("HoodieMetadata");
        }
        this.metrics = Option.of(new HoodieMetadataMetrics(registry));
    } else {
        this.metrics = Option.empty();
    }
}
Also used : DistributedRegistry(org.apache.hudi.metrics.DistributedRegistry) Registry(org.apache.hudi.common.metrics.Registry)

Example 5 with Registry

use of org.apache.hudi.common.metrics.Registry in project hudi by apache.

the class HoodieWrapperFileSystem method executeFuncWithTimeMetrics.

protected static <R> R executeFuncWithTimeMetrics(String metricName, Path p, CheckedFunction<R> func) throws IOException {
    HoodieTimer timer = new HoodieTimer().startTimer();
    R res = func.get();
    Registry registry = getMetricRegistryForPath(p);
    if (registry != null) {
        registry.increment(metricName);
        registry.add(metricName + ".totalDuration", timer.endTimer());
    }
    return res;
}
Also used : HoodieTimer(org.apache.hudi.common.util.HoodieTimer) Registry(org.apache.hudi.common.metrics.Registry)

Aggregations

Registry (org.apache.hudi.common.metrics.Registry)8 Test (org.junit.jupiter.api.Test)4 HashMap (java.util.HashMap)2 HoodieSparkEngineContext (org.apache.hudi.client.common.HoodieSparkEngineContext)2 DistributedRegistry (org.apache.hudi.metrics.DistributedRegistry)2 SparkRDDWriteClient (org.apache.hudi.client.SparkRDDWriteClient)1 WriteStatus (org.apache.hudi.client.WriteStatus)1 HoodieWrapperFileSystem (org.apache.hudi.common.fs.HoodieWrapperFileSystem)1 HoodieRecord (org.apache.hudi.common.model.HoodieRecord)1 HoodieTimer (org.apache.hudi.common.util.HoodieTimer)1 MetadataMergeWriteStatus (org.apache.hudi.testutils.MetadataMergeWriteStatus)1 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1