mchades commented on code in PR #13367:
URL: https://github.com/apache/gravitino/pull/13367#discussion_r4059809276
##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -229,24 +230,39 @@ public static GravitinoEnv getInstance() {
*/
public void initializeBaseComponents(Config config) {
LOG.info("Initializing Gravitino base environment...");
- this.config = config;
- FileFetcher.get().initialize(config.get(Configs.BLOCK_UNSAFE_REMOTE_URI));
- SecretPropertyUtils.configureSensitiveKeyKeywords(config);
+ initializeConfig(config);
this.manageFullComponents = false;
initBaseComponents();
LOG.info("Gravitino base environment is initialized.");
}
+ /**
+ * Initialize metadata access components without server-side integrations.
+ *
+ * <p>This profile provides storage, normalized metadata dispatchers,
governance, configured
+ * authorization, statistics, locking, secrets, and metrics. It excludes
hooks, event and audit
+ * dispatch, auxiliary services, and the job subsystem. It is intended for
processes that need
+ * direct metadata access without hosting the Gravitino server runtime.
+ *
+ * @param config The configuration object to initialize the environment.
+ */
+ public void initializeMetadataComponents(Config config) {
Review Comment:
Updated in `178321cea9`. The method now documents and enforces the singleton
contract with `Preconditions.checkState(this == getInstance(), ...)`. The
positive test uses `GravitinoEnv.getInstance()`, and a negative test verifies
that initialization on a non-singleton fails immediately. Making the existing
metadata dependencies instance-safe is outside this refactor.
##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -427,6 +443,17 @@ public PartitionDispatcher partitionDispatcher() {
return partitionDispatcher;
}
+ /**
+ * Get the internal PartitionDispatcher associated with the Gravitino
environment.
+ *
+ * <p>The internal dispatcher preserves normalization but skips event
emission.
+ *
+ * @return The internal PartitionDispatcher instance.
+ */
+ public PartitionDispatcher internalPartitionDispatcher() {
Review Comment:
Updated in `178321cea9`. The internal partition dispatcher remains part of
the normalized metadata profile, and the full profile now passes that same
instance directly to `PartitionEventDispatcher`. This removes the second
`PartitionNormalizeDispatcher`; the full chain is `Event -> internal Normalize
-> Operation`, and `MetadataOperations` no longer carries the partition
operation dispatcher.
##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -1045,4 +1046,125 @@ private void initGravitinoServerComponents() {
new BuiltInJobTemplateEventListener(jobManager, entityStore,
idGenerator);
eventListenerManager.addEventListener("builtin-job-template",
builtInJobTemplateListener);
}
+
+ private void initPublicMetadataDispatchers(MetadataOperations
metadataOperations) {
+ // Create and initialize metalake related modules, the operation chain is:
+ // MetalakeEventDispatcher -> MetalakeNormalizeDispatcher ->
MetalakeHookDispatcher ->
+ // MetalakeManager
+ MetalakeHookDispatcher metalakeHookDispatcher = new
MetalakeHookDispatcher(metalakeManager);
+ MetalakeNormalizeDispatcher metalakeNormalizeDispatcher =
+ new MetalakeNormalizeDispatcher(metalakeHookDispatcher);
+ this.metalakeDispatcher = new MetalakeEventDispatcher(eventBus,
metalakeNormalizeDispatcher);
+
+ // CatalogEventDispatcher -> CatalogNormalizeDispatcher ->
CatalogHookDispatcher ->
+ // CatalogManager
+ CatalogHookDispatcher catalogHookDispatcher = new
CatalogHookDispatcher(catalogManager);
+ CatalogNormalizeDispatcher catalogNormalizeDispatcher =
+ new CatalogNormalizeDispatcher(catalogHookDispatcher);
+ this.catalogDispatcher = new CatalogEventDispatcher(eventBus,
catalogNormalizeDispatcher);
+
+ FilesetHookDispatcher filesetHookDispatcher =
+ new
FilesetHookDispatcher(metadataOperations.filesetOperationDispatcher);
+ FilesetNormalizeDispatcher filesetNormalizeDispatcher =
+ new FilesetNormalizeDispatcher(filesetHookDispatcher, catalogManager);
+ this.filesetDispatcher = new FilesetEventDispatcher(eventBus,
filesetNormalizeDispatcher);
+
+ SchemaHookDispatcher schemaHookDispatcher =
+ new SchemaHookDispatcher(metadataOperations.schemaOperationDispatcher);
+ SchemaNormalizeDispatcher schemaNormalizeDispatcher =
+ new SchemaNormalizeDispatcher(schemaHookDispatcher, catalogManager);
+ this.schemaDispatcher = new SchemaEventDispatcher(eventBus,
schemaNormalizeDispatcher);
+
+ TableOperationDispatcher tableOperationDispatcher =
+ new TableOperationDispatcher(catalogManager, entityStore, idGenerator,
secretManager);
+ TableHookDispatcher tableHookDispatcher =
+ new TableHookDispatcher(tableOperationDispatcher,
this::internalOwnerDispatcher);
+ TableNormalizeDispatcher tableNormalizeDispatcher =
+ new TableNormalizeDispatcher(tableHookDispatcher, catalogManager);
+ this.tableDispatcher = new TableEventDispatcher(eventBus,
tableNormalizeDispatcher);
+
+ // TODO: We can install hooks when we need, we only supports ownership
post hook,
+ // partition doesn't have ownership, so we don't need it now.
+ PartitionNormalizeDispatcher partitionNormalizeDispatcher =
+ new PartitionNormalizeDispatcher(
+ metadataOperations.partitionOperationDispatcher, catalogManager);
+ this.partitionDispatcher = new PartitionEventDispatcher(eventBus,
partitionNormalizeDispatcher);
+
+ TopicHookDispatcher topicHookDispatcher =
+ new TopicHookDispatcher(metadataOperations.topicOperationDispatcher);
+ TopicNormalizeDispatcher topicNormalizeDispatcher =
+ new TopicNormalizeDispatcher(topicHookDispatcher, catalogManager);
+ this.topicDispatcher = new TopicEventDispatcher(eventBus,
topicNormalizeDispatcher);
+
+ ModelHookDispatcher modelHookDispatcher =
+ new ModelHookDispatcher(metadataOperations.modelOperationDispatcher);
+ ModelNormalizeDispatcher modelNormalizeDispatcher =
+ new ModelNormalizeDispatcher(modelHookDispatcher, catalogManager);
+ this.modelDispatcher = new ModelEventDispatcher(eventBus,
modelNormalizeDispatcher);
+
+ // Create and initialize Function related modules, the operation chain is:
+ // FunctionEventDispatcher -> FunctionNormalizeDispatcher ->
FunctionHookDispatcher ->
+ // FunctionOperationDispatcher
+ FunctionHookDispatcher functionHookDispatcher =
+ new FunctionHookDispatcher(
+ metadataOperations.functionOperationDispatcher,
this::internalOwnerDispatcher);
+ FunctionNormalizeDispatcher functionNormalizeDispatcher =
+ new FunctionNormalizeDispatcher(functionHookDispatcher,
catalogManager);
+ this.functionDispatcher = new FunctionEventDispatcher(eventBus,
functionNormalizeDispatcher);
+
+ // View operation chain: ViewEventDispatcher -> ViewNormalizeDispatcher ->
ViewHookDispatcher
+ // -> ViewOperationDispatcher.
+ ViewOperationDispatcher viewOperationDispatcher =
+ new ViewOperationDispatcher(catalogManager, entityStore, idGenerator,
secretManager);
+ ViewHookDispatcher viewHookDispatcher =
+ new ViewHookDispatcher(viewOperationDispatcher,
this::internalOwnerDispatcher);
+ ViewNormalizeDispatcher viewNormalizeDispatcher =
+ new ViewNormalizeDispatcher(viewHookDispatcher, catalogManager);
+ this.viewDispatcher = new ViewEventDispatcher(eventBus,
viewNormalizeDispatcher);
+
+ this.statisticDispatcher = new StatisticEventDispatcher(eventBus,
statisticDispatcher);
Review Comment:
Updated in `178321cea9`. Added a separate `internalStatisticDispatcher`
backed by `StatisticManager`. The metadata profile leaves the public statistic
dispatcher unset, while the full profile wraps the internal dispatcher with
`StatisticEventDispatcher`. Shutdown closes the public wrapper when present,
otherwise the internal dispatcher.
--
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]