sririshindra commented on code in PR #4225:
URL: https://github.com/apache/polaris/pull/4225#discussion_r3231018644
##########
runtime/service/src/main/java/org/apache/polaris/service/events/listeners/PolarisPersistenceEventListener.java:
##########
@@ -19,75 +19,31 @@
package org.apache.polaris.service.events.listeners;
-import com.google.common.collect.ImmutableMap;
import java.util.Map;
-import org.apache.iceberg.TableMetadata;
-import org.apache.iceberg.TableMetadataParser;
-import org.apache.iceberg.catalog.Namespace;
-import org.apache.iceberg.catalog.TableIdentifier;
-import org.apache.iceberg.rest.responses.LoadTableResponse;
-import org.apache.polaris.core.admin.model.Catalog;
-import org.apache.polaris.core.auth.PolarisPrincipal;
-import org.apache.polaris.service.events.EventAttributes;
+import java.util.Objects;
import org.apache.polaris.service.events.PolarisEvent;
+import org.apache.polaris.service.events.PolarisEventType;
public abstract class PolarisPersistenceEventListener implements
PolarisEventListener {
- @Override
- public void onEvent(PolarisEvent event) {
- switch (event.type()) {
- case AFTER_CREATE_TABLE -> handleAfterCreateTable(event);
- case AFTER_CREATE_CATALOG -> handleAfterCreateCatalog(event);
- default -> {
- // Other events not handled by this listener
- }
- }
- }
+ private final PersistenceEventHandler defaultHandler;
+ private final Map<PolarisEventType, PersistenceEventHandler>
eventTypeHandlers;
- private void handleAfterCreateTable(PolarisEvent event) {
- LoadTableResponse loadTableResponse =
- event.attributes().getRequired(EventAttributes.LOAD_TABLE_RESPONSE);
- TableMetadata tableMetadata = loadTableResponse.tableMetadata();
- String catalogName =
event.attributes().getRequired(EventAttributes.CATALOG_NAME);
- Namespace namespace =
event.attributes().getRequired(EventAttributes.NAMESPACE);
- String tableName =
event.attributes().getRequired(EventAttributes.TABLE_NAME);
+ protected PolarisPersistenceEventListener() {
Review Comment:
Removed the handler registry entirely. The universal approach (single
listener handling all events via category() switch + allowlist) eliminates the
need for per-event-type handlers. The filter and pruner are now CDI beans
(@ApplicationScoped @DefaultBean), so operators can provide alternative
implementations via standard CDI mechanisms.
--
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]