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"));
}
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());
}
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));
}
}
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();
}
}
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;
}
Aggregations