This is an automated email from the ASF dual-hosted git repository.

emaynard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new d7ec8f276 Add Events for Generic Table APIs (#2481)
d7ec8f276 is described below

commit d7ec8f27688ba8e8fef567a16a73fb0b34778f91
Author: Adnan Hemani <adna...@berkeley.edu>
AuthorDate: Thu Sep 4 11:08:15 2025 -0700

    Add Events for Generic Table APIs (#2481)
    
    
    This PR adds the Events instrumentation for the Generic Tables Service 
APIs, surrounding the default delegated call to the business logic APIs.
---
 .../CatalogGenericTableEventServiceDelegator.java  | 54 ++++++++++++++++++----
 .../events/CatalogGenericTableServiceEvents.java   | 47 +++++++++++++++++++
 .../events/listeners/PolarisEventListener.java     | 33 +++++++++++++
 3 files changed, 126 insertions(+), 8 deletions(-)

diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/CatalogGenericTableEventServiceDelegator.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/CatalogGenericTableEventServiceDelegator.java
index 0db2a4257..e7bb6d925 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/CatalogGenericTableEventServiceDelegator.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/CatalogGenericTableEventServiceDelegator.java
@@ -26,9 +26,13 @@ import jakarta.inject.Inject;
 import jakarta.ws.rs.core.Response;
 import jakarta.ws.rs.core.SecurityContext;
 import org.apache.polaris.core.context.RealmContext;
+import org.apache.polaris.service.catalog.CatalogPrefixParser;
 import 
org.apache.polaris.service.catalog.api.PolarisCatalogGenericTableApiService;
 import org.apache.polaris.service.catalog.common.CatalogAdapter;
+import org.apache.polaris.service.events.CatalogGenericTableServiceEvents;
+import org.apache.polaris.service.events.listeners.PolarisEventListener;
 import org.apache.polaris.service.types.CreateGenericTableRequest;
+import org.apache.polaris.service.types.LoadGenericTableResponse;
 
 @Decorator
 @Priority(1000)
@@ -36,6 +40,8 @@ public class CatalogGenericTableEventServiceDelegator
     implements PolarisCatalogGenericTableApiService, CatalogAdapter {
 
   @Inject @Delegate GenericTableCatalogAdapter delegate;
+  @Inject PolarisEventListener polarisEventListener;
+  @Inject CatalogPrefixParser prefixParser;
 
   @Override
   public Response createGenericTable(
@@ -44,8 +50,17 @@ public class CatalogGenericTableEventServiceDelegator
       CreateGenericTableRequest createGenericTableRequest,
       RealmContext realmContext,
       SecurityContext securityContext) {
-    return delegate.createGenericTable(
-        prefix, namespace, createGenericTableRequest, realmContext, 
securityContext);
+    String catalogName = prefixParser.prefixToCatalogName(realmContext, 
prefix);
+    polarisEventListener.onBeforeCreateGenericTable(
+        new CatalogGenericTableServiceEvents.BeforeCreateGenericTableEvent(
+            catalogName, namespace, createGenericTableRequest));
+    Response resp =
+        delegate.createGenericTable(
+            prefix, namespace, createGenericTableRequest, realmContext, 
securityContext);
+    polarisEventListener.onAfterCreateGenericTable(
+        new CatalogGenericTableServiceEvents.AfterCreateGenericTableEvent(
+            catalogName, namespace, ((LoadGenericTableResponse) 
resp.getEntity()).getTable()));
+    return resp;
   }
 
   @Override
@@ -55,8 +70,16 @@ public class CatalogGenericTableEventServiceDelegator
       String genericTable,
       RealmContext realmContext,
       SecurityContext securityContext) {
-    return delegate.dropGenericTable(
-        prefix, namespace, genericTable, realmContext, securityContext);
+    String catalogName = prefixParser.prefixToCatalogName(realmContext, 
prefix);
+    polarisEventListener.onBeforeDropGenericTable(
+        new CatalogGenericTableServiceEvents.BeforeDropGenericTableEvent(
+            catalogName, namespace, genericTable));
+    Response resp =
+        delegate.dropGenericTable(prefix, namespace, genericTable, 
realmContext, securityContext);
+    polarisEventListener.onAfterDropGenericTable(
+        new CatalogGenericTableServiceEvents.AfterDropGenericTableEvent(
+            catalogName, namespace, genericTable));
+    return resp;
   }
 
   @Override
@@ -67,8 +90,15 @@ public class CatalogGenericTableEventServiceDelegator
       Integer pageSize,
       RealmContext realmContext,
       SecurityContext securityContext) {
-    return delegate.listGenericTables(
-        prefix, namespace, pageToken, pageSize, realmContext, securityContext);
+    String catalogName = prefixParser.prefixToCatalogName(realmContext, 
prefix);
+    polarisEventListener.onBeforeListGenericTables(
+        new 
CatalogGenericTableServiceEvents.BeforeListGenericTablesEvent(catalogName, 
namespace));
+    Response resp =
+        delegate.listGenericTables(
+            prefix, namespace, pageToken, pageSize, realmContext, 
securityContext);
+    polarisEventListener.onAfterListGenericTables(
+        new 
CatalogGenericTableServiceEvents.AfterListGenericTablesEvent(catalogName, 
namespace));
+    return resp;
   }
 
   @Override
@@ -78,7 +108,15 @@ public class CatalogGenericTableEventServiceDelegator
       String genericTable,
       RealmContext realmContext,
       SecurityContext securityContext) {
-    return delegate.loadGenericTable(
-        prefix, namespace, genericTable, realmContext, securityContext);
+    String catalogName = prefixParser.prefixToCatalogName(realmContext, 
prefix);
+    polarisEventListener.onBeforeLoadGenericTable(
+        new CatalogGenericTableServiceEvents.BeforeLoadGenericTableEvent(
+            catalogName, namespace, genericTable));
+    Response resp =
+        delegate.loadGenericTable(prefix, namespace, genericTable, 
realmContext, securityContext);
+    polarisEventListener.onAfterLoadGenericTable(
+        new CatalogGenericTableServiceEvents.AfterLoadGenericTableEvent(
+            catalogName, namespace, ((LoadGenericTableResponse) 
resp.getEntity()).getTable()));
+    return resp;
   }
 }
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/events/CatalogGenericTableServiceEvents.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/events/CatalogGenericTableServiceEvents.java
new file mode 100644
index 000000000..a533e88c7
--- /dev/null
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/events/CatalogGenericTableServiceEvents.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.events;
+
+import org.apache.polaris.service.types.CreateGenericTableRequest;
+import org.apache.polaris.service.types.GenericTable;
+
+public class CatalogGenericTableServiceEvents {
+  public record BeforeCreateGenericTableEvent(
+      String catalogName, String namespace, CreateGenericTableRequest request) 
{}
+
+  public record AfterCreateGenericTableEvent(
+      String catalogName, String namespace, GenericTable table) {}
+
+  public record BeforeDropGenericTableEvent(
+      String catalogName, String namespace, String tableName) {}
+
+  public record AfterDropGenericTableEvent(
+      String catalogName, String namespace, String tableName) {}
+
+  public record BeforeListGenericTablesEvent(String catalogName, String 
namespace) {}
+
+  public record AfterListGenericTablesEvent(String catalogName, String 
namespace) {}
+
+  public record BeforeLoadGenericTableEvent(
+      String catalogName, String namespace, String tableName) {}
+
+  public record AfterLoadGenericTableEvent(
+      String catalogName, String namespace, GenericTable table) {}
+}
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/events/listeners/PolarisEventListener.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/events/listeners/PolarisEventListener.java
index 2d13194dc..1c72a0904 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/events/listeners/PolarisEventListener.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/events/listeners/PolarisEventListener.java
@@ -31,6 +31,7 @@ import 
org.apache.polaris.service.events.BeforeTableRefreshedEvent;
 import org.apache.polaris.service.events.BeforeTaskAttemptedEvent;
 import org.apache.polaris.service.events.BeforeViewCommitedEvent;
 import org.apache.polaris.service.events.BeforeViewRefreshedEvent;
+import org.apache.polaris.service.events.CatalogGenericTableServiceEvents;
 
 /**
  * Represents an event listener that can respond to notable moments during 
Polaris's execution.
@@ -76,4 +77,36 @@ public abstract class PolarisEventListener {
 
   /** {@link AfterCatalogCreatedEvent} */
   public void onAfterCatalogCreated(AfterCatalogCreatedEvent event) {}
+
+  /** {@link CatalogGenericTableServiceEvents.BeforeCreateGenericTableEvent} */
+  public void onBeforeCreateGenericTable(
+      CatalogGenericTableServiceEvents.BeforeCreateGenericTableEvent event) {}
+
+  /** {@link CatalogGenericTableServiceEvents.AfterCreateGenericTableEvent} */
+  public void onAfterCreateGenericTable(
+      CatalogGenericTableServiceEvents.AfterCreateGenericTableEvent event) {}
+
+  /** {@link CatalogGenericTableServiceEvents.BeforeDropGenericTableEvent} */
+  public void onBeforeDropGenericTable(
+      CatalogGenericTableServiceEvents.BeforeDropGenericTableEvent event) {}
+
+  /** {@link CatalogGenericTableServiceEvents.AfterDropGenericTableEvent} */
+  public void onAfterDropGenericTable(
+      CatalogGenericTableServiceEvents.AfterDropGenericTableEvent event) {}
+
+  /** {@link CatalogGenericTableServiceEvents.BeforeListGenericTablesEvent} */
+  public void onBeforeListGenericTables(
+      CatalogGenericTableServiceEvents.BeforeListGenericTablesEvent event) {}
+
+  /** {@link CatalogGenericTableServiceEvents.AfterListGenericTablesEvent} */
+  public void onAfterListGenericTables(
+      CatalogGenericTableServiceEvents.AfterListGenericTablesEvent event) {}
+
+  /** {@link CatalogGenericTableServiceEvents.BeforeLoadGenericTableEvent} */
+  public void onBeforeLoadGenericTable(
+      CatalogGenericTableServiceEvents.BeforeLoadGenericTableEvent event) {}
+
+  /** {@link CatalogGenericTableServiceEvents.AfterLoadGenericTableEvent} */
+  public void onAfterLoadGenericTable(
+      CatalogGenericTableServiceEvents.AfterLoadGenericTableEvent event) {}
 }

Reply via email to