prashantwason commented on code in PR #18179:
URL: https://github.com/apache/hudi/pull/18179#discussion_r2914894854
##########
hudi-io/src/main/java/org/apache/hudi/common/metrics/Registry.java:
##########
@@ -18,45 +18,95 @@
package org.apache.hudi.common.metrics;
+import org.apache.hudi.common.util.Option;
import org.apache.hudi.common.util.ReflectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.Serializable;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
- * Interface which defines a lightweight Metrics Registry to track Hudi events.
+ * Interface which defines a lightweight Metrics Registry to track Hudi
metrics.
+ *
+ * Registries can be used to track related metrics under a common name - e.g.
metrics for Metadata Table.
*/
public interface Registry extends Serializable {
+ Logger LOG = LoggerFactory.getLogger(Registry.class);
+
+ /**
+ * Separator used for compound registry keys (tableName + registryName).
+ */
+ String KEY_SEPARATOR = "::";
+ /**
+ * Map of all registries that have been created.
+ * The key is a compound of table name and registry name in format
"tableName::registryName".
+ * For non-table specific registries (i.e. common for all tables) the
tableName would be empty.
+ */
ConcurrentHashMap<String, Registry> REGISTRY_MAP = new ConcurrentHashMap<>();
/**
- * Get (or create) the registry for a provided name.
- *
- * This function creates a {@code LocalRegistry}.
+ * Creates a compound key from tableName and registryName.
+ */
+ static String makeKey(String tableName, String registryName) {
+ return tableName + KEY_SEPARATOR + registryName;
Review Comment:
Good catch. While `::` in table names is uncommon, it's better to be safe.
Updated `getRegistryNameFromKey()` to use `lastIndexOf` instead of `indexOf` so
that even if the table name contains `::`, the registry name (which is a
well-known constant like `HoodieWrapperFileSystem`) is correctly extracted from
the end of the compound key.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]