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

jshao pushed a commit to branch branch-0.7
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-0.7 by this push:
     new e1d72a394 [#5370] feat(iceberg):  make IcebergTableOperationDispatcher 
interface more extendable (#5412)
e1d72a394 is described below

commit e1d72a394fdb58b42883eb769c000e87a71177b6
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Nov 1 12:14:16 2024 +0800

    [#5370] feat(iceberg):  make IcebergTableOperationDispatcher interface more 
extendable (#5412)
    
    ### What changes were proposed in this pull request?
    
    add `IcebergRequestContext` in `IcebergTableOperationDispatcher`
    
    ### Why are the changes needed?
    
    Fix: #5370
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    existing tests
    
    Co-authored-by: FANNG <[email protected]>
---
 .../iceberg/service/IcebergRequestContext.java     | 34 ++++++++++++++
 .../dispatcher/IcebergTableEventDispatcher.java    | 54 +++++++++++++---------
 .../IcebergTableOperationDispatcher.java           | 32 +++++++------
 .../dispatcher/IcebergTableOperationExecutor.java  | 46 ++++++++++++------
 .../service/rest/IcebergTableOperations.java       | 24 ++++++----
 .../service/rest/IcebergTableRenameOperations.java |  8 ++--
 6 files changed, 133 insertions(+), 65 deletions(-)

diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRequestContext.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRequestContext.java
new file mode 100644
index 000000000..ad8d7692f
--- /dev/null
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRequestContext.java
@@ -0,0 +1,34 @@
+/*
+ *  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.gravitino.iceberg.service;
+
+import javax.servlet.http.HttpServletRequest;
+import lombok.Getter;
+
+/** The general request context information for Iceberg REST operations. */
+public class IcebergRequestContext {
+  @Getter private final HttpServletRequest httpRequest;
+  @Getter private final String catalogName;
+
+  public IcebergRequestContext(HttpServletRequest httpRequest, String 
catalogName) {
+    this.httpRequest = httpRequest;
+    this.catalogName = catalogName;
+  }
+}
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.java
index bd49630de..60bb517a0 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.java
@@ -20,6 +20,7 @@
 package org.apache.gravitino.iceberg.service.dispatcher;
 
 import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.iceberg.service.IcebergRequestContext;
 import org.apache.gravitino.iceberg.service.IcebergRestUtils;
 import org.apache.gravitino.listener.EventBus;
 import org.apache.gravitino.listener.api.event.IcebergCreateTableEvent;
@@ -74,17 +75,18 @@ public class IcebergTableEventDispatcher implements 
IcebergTableOperationDispatc
 
   @Override
   public LoadTableResponse createTable(
-      String catalogName, Namespace namespace, CreateTableRequest 
createTableRequest) {
+      IcebergRequestContext context, Namespace namespace, CreateTableRequest 
createTableRequest) {
     TableIdentifier tableIdentifier = TableIdentifier.of(namespace, 
createTableRequest.name());
     NameIdentifier nameIdentifier =
-        IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, catalogName, 
tableIdentifier);
+        IcebergRestUtils.getGravitinoNameIdentifier(
+            metalakeName, context.getCatalogName(), tableIdentifier);
     eventBus.dispatchEvent(
         new IcebergCreateTablePreEvent(
             PrincipalUtils.getCurrentUserName(), nameIdentifier, 
createTableRequest));
     LoadTableResponse loadTableResponse;
     try {
       loadTableResponse =
-          icebergTableOperationDispatcher.createTable(catalogName, namespace, 
createTableRequest);
+          icebergTableOperationDispatcher.createTable(context, namespace, 
createTableRequest);
     } catch (Exception e) {
       eventBus.dispatchEvent(
           new IcebergCreateTableFailureEvent(
@@ -102,17 +104,19 @@ public class IcebergTableEventDispatcher implements 
IcebergTableOperationDispatc
 
   @Override
   public LoadTableResponse updateTable(
-      String catalogName, TableIdentifier tableIdentifier, UpdateTableRequest 
updateTableRequest) {
+      IcebergRequestContext context,
+      TableIdentifier tableIdentifier,
+      UpdateTableRequest updateTableRequest) {
     NameIdentifier gravitinoNameIdentifier =
-        IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, catalogName, 
tableIdentifier);
+        IcebergRestUtils.getGravitinoNameIdentifier(
+            metalakeName, context.getCatalogName(), tableIdentifier);
     eventBus.dispatchEvent(
         new IcebergUpdateTablePreEvent(
             PrincipalUtils.getCurrentUserName(), gravitinoNameIdentifier, 
updateTableRequest));
     LoadTableResponse loadTableResponse;
     try {
       loadTableResponse =
-          icebergTableOperationDispatcher.updateTable(
-              catalogName, tableIdentifier, updateTableRequest);
+          icebergTableOperationDispatcher.updateTable(context, 
tableIdentifier, updateTableRequest);
     } catch (Exception e) {
       eventBus.dispatchEvent(
           new IcebergUpdateTableFailureEvent(
@@ -130,14 +134,15 @@ public class IcebergTableEventDispatcher implements 
IcebergTableOperationDispatc
 
   @Override
   public void dropTable(
-      String catalogName, TableIdentifier tableIdentifier, boolean 
purgeRequested) {
+      IcebergRequestContext context, TableIdentifier tableIdentifier, boolean 
purgeRequested) {
     NameIdentifier gravitinoNameIdentifier =
-        IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, catalogName, 
tableIdentifier);
+        IcebergRestUtils.getGravitinoNameIdentifier(
+            metalakeName, context.getCatalogName(), tableIdentifier);
     eventBus.dispatchEvent(
         new IcebergDropTablePreEvent(
             PrincipalUtils.getCurrentUserName(), gravitinoNameIdentifier, 
purgeRequested));
     try {
-      icebergTableOperationDispatcher.dropTable(catalogName, tableIdentifier, 
purgeRequested);
+      icebergTableOperationDispatcher.dropTable(context, tableIdentifier, 
purgeRequested);
     } catch (Exception e) {
       eventBus.dispatchEvent(
           new IcebergDropTableFailureEvent(
@@ -150,14 +155,16 @@ public class IcebergTableEventDispatcher implements 
IcebergTableOperationDispatc
   }
 
   @Override
-  public LoadTableResponse loadTable(String catalogName, TableIdentifier 
tableIdentifier) {
+  public LoadTableResponse loadTable(
+      IcebergRequestContext context, TableIdentifier tableIdentifier) {
     NameIdentifier gravitinoNameIdentifier =
-        IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, catalogName, 
tableIdentifier);
+        IcebergRestUtils.getGravitinoNameIdentifier(
+            metalakeName, context.getCatalogName(), tableIdentifier);
     eventBus.dispatchEvent(
         new IcebergLoadTablePreEvent(PrincipalUtils.getCurrentUserName(), 
gravitinoNameIdentifier));
     LoadTableResponse loadTableResponse;
     try {
-      loadTableResponse = 
icebergTableOperationDispatcher.loadTable(catalogName, tableIdentifier);
+      loadTableResponse = icebergTableOperationDispatcher.loadTable(context, 
tableIdentifier);
     } catch (Exception e) {
       eventBus.dispatchEvent(
           new IcebergLoadTableFailureEvent(
@@ -171,14 +178,15 @@ public class IcebergTableEventDispatcher implements 
IcebergTableOperationDispatc
   }
 
   @Override
-  public ListTablesResponse listTable(String catalogName, Namespace namespace) 
{
+  public ListTablesResponse listTable(IcebergRequestContext context, Namespace 
namespace) {
     NameIdentifier gravitinoNameIdentifier =
-        IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, catalogName, 
namespace);
+        IcebergRestUtils.getGravitinoNameIdentifier(
+            metalakeName, context.getCatalogName(), namespace);
     eventBus.dispatchEvent(
         new IcebergListTablePreEvent(PrincipalUtils.getCurrentUserName(), 
gravitinoNameIdentifier));
     ListTablesResponse listTablesResponse;
     try {
-      listTablesResponse = 
icebergTableOperationDispatcher.listTable(catalogName, namespace);
+      listTablesResponse = icebergTableOperationDispatcher.listTable(context, 
namespace);
     } catch (Exception e) {
       eventBus.dispatchEvent(
           new IcebergListTableFailureEvent(
@@ -191,15 +199,16 @@ public class IcebergTableEventDispatcher implements 
IcebergTableOperationDispatc
   }
 
   @Override
-  public boolean tableExists(String catalogName, TableIdentifier 
tableIdentifier) {
+  public boolean tableExists(IcebergRequestContext context, TableIdentifier 
tableIdentifier) {
     NameIdentifier gravitinoNameIdentifier =
-        IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, catalogName, 
tableIdentifier);
+        IcebergRestUtils.getGravitinoNameIdentifier(
+            metalakeName, context.getCatalogName(), tableIdentifier);
     eventBus.dispatchEvent(
         new IcebergTableExistsPreEvent(
             PrincipalUtils.getCurrentUserName(), gravitinoNameIdentifier));
     boolean isExists;
     try {
-      isExists = icebergTableOperationDispatcher.tableExists(catalogName, 
tableIdentifier);
+      isExists = icebergTableOperationDispatcher.tableExists(context, 
tableIdentifier);
     } catch (Exception e) {
       eventBus.dispatchEvent(
           new IcebergTableExistsFailureEvent(
@@ -213,15 +222,16 @@ public class IcebergTableEventDispatcher implements 
IcebergTableOperationDispatc
   }
 
   @Override
-  public void renameTable(String catalogName, RenameTableRequest 
renameTableRequest) {
+  public void renameTable(IcebergRequestContext context, RenameTableRequest 
renameTableRequest) {
     TableIdentifier sourceTable = renameTableRequest.source();
     NameIdentifier gravitinoNameIdentifier =
-        IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, catalogName, 
sourceTable);
+        IcebergRestUtils.getGravitinoNameIdentifier(
+            metalakeName, context.getCatalogName(), sourceTable);
     eventBus.dispatchEvent(
         new IcebergRenameTablePreEvent(
             PrincipalUtils.getCurrentUserName(), gravitinoNameIdentifier, 
renameTableRequest));
     try {
-      icebergTableOperationDispatcher.renameTable(catalogName, 
renameTableRequest);
+      icebergTableOperationDispatcher.renameTable(context, renameTableRequest);
     } catch (Exception e) {
       eventBus.dispatchEvent(
           new IcebergRenameTableFailureEvent(
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationDispatcher.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationDispatcher.java
index 68a0db16f..49b910960 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationDispatcher.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationDispatcher.java
@@ -19,6 +19,7 @@
 
 package org.apache.gravitino.iceberg.service.dispatcher;
 
+import org.apache.gravitino.iceberg.service.IcebergRequestContext;
 import org.apache.iceberg.catalog.Namespace;
 import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.iceberg.rest.requests.CreateTableRequest;
@@ -36,66 +37,69 @@ public interface IcebergTableOperationDispatcher {
   /**
    * Creates a new Iceberg table.
    *
-   * @param catalogName The catalog name when creating the table.
+   * @param context Iceberg REST request context information.
    * @param namespace The namespace within which the table should be created.
    * @param createTableRequest The request object containing the details for 
creating the table.
    * @return A {@link LoadTableResponse} object containing the result of the 
operation.
    */
   LoadTableResponse createTable(
-      String catalogName, Namespace namespace, CreateTableRequest 
createTableRequest);
+      IcebergRequestContext context, Namespace namespace, CreateTableRequest 
createTableRequest);
 
   /**
    * Updates an Iceberg table.
    *
-   * @param catalogName The catalog name when updating the table.
+   * @param context Iceberg REST request context information.
    * @param tableIdentifier The Iceberg table identifier.
    * @param updateTableRequest The request object containing the details for 
updating the table.
    * @return A {@link LoadTableResponse} object containing the result of the 
operation.
    */
   LoadTableResponse updateTable(
-      String catalogName, TableIdentifier tableIdentifier, UpdateTableRequest 
updateTableRequest);
+      IcebergRequestContext context,
+      TableIdentifier tableIdentifier,
+      UpdateTableRequest updateTableRequest);
 
   /**
    * Drops an Iceberg table.
    *
-   * @param catalogName The catalog name when dropping the table.
+   * @param context Iceberg REST request context information.
    * @param tableIdentifier The Iceberg table identifier.
    * @param purgeRequested Whether to purge the table.
    */
-  void dropTable(String catalogName, TableIdentifier tableIdentifier, boolean 
purgeRequested);
+  void dropTable(
+      IcebergRequestContext context, TableIdentifier tableIdentifier, boolean 
purgeRequested);
 
   /**
    * Loads an Iceberg table.
    *
-   * @param catalogName The catalog name when dropping the table.
+   * @param context Iceberg REST request context information.
    * @param tableIdentifier The Iceberg table identifier.
    * @return A {@link LoadTableResponse} object containing the result of the 
operation.
    */
-  LoadTableResponse loadTable(String catalogName, TableIdentifier 
tableIdentifier);
+  LoadTableResponse loadTable(IcebergRequestContext context, TableIdentifier 
tableIdentifier);
 
   /**
    * Lists Iceberg tables.
    *
-   * @param catalogName The catalog name when dropping the table.
+   * @param context Iceberg REST request context information.
    * @param namespace The Iceberg namespace.
    * @return A {@link ListTablesResponse} object containing the list of table 
identifiers.
    */
-  ListTablesResponse listTable(String catalogName, Namespace namespace);
+  ListTablesResponse listTable(IcebergRequestContext context, Namespace 
namespace);
 
   /**
    * Check whether an Iceberg table exists.
    *
-   * @param catalogName The catalog name when dropping the table.
+   * @param context Iceberg REST request context information.
    * @param tableIdentifier The Iceberg table identifier.
    * @return Whether table exists.
    */
-  boolean tableExists(String catalogName, TableIdentifier tableIdentifier);
+  boolean tableExists(IcebergRequestContext context, TableIdentifier 
tableIdentifier);
 
   /**
    * Rename an Iceberg table.
    *
-   * @param catalogName The catalog name when dropping the table.
+   * @param context Iceberg REST request context information.
    * @param renameTableRequest Rename table request information.
    */
-  void renameTable(String catalogName, RenameTableRequest renameTableRequest);
+  void renameTable(IcebergRequestContext context, RenameTableRequest 
renameTableRequest);
 }
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationExecutor.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationExecutor.java
index 8016b5def..d2993b13e 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationExecutor.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationExecutor.java
@@ -20,6 +20,7 @@
 package org.apache.gravitino.iceberg.service.dispatcher;
 
 import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;
+import org.apache.gravitino.iceberg.service.IcebergRequestContext;
 import org.apache.iceberg.catalog.Namespace;
 import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.iceberg.rest.requests.CreateTableRequest;
@@ -38,47 +39,62 @@ public class IcebergTableOperationExecutor implements 
IcebergTableOperationDispa
 
   @Override
   public LoadTableResponse createTable(
-      String catalogName, Namespace namespace, CreateTableRequest 
createTableRequest) {
+      IcebergRequestContext context, Namespace namespace, CreateTableRequest 
createTableRequest) {
     return icebergCatalogWrapperManager
-        .getCatalogWrapper(catalogName)
+        .getCatalogWrapper(context.getCatalogName())
         .createTable(namespace, createTableRequest);
   }
 
   @Override
   public LoadTableResponse updateTable(
-      String catalogName, TableIdentifier tableIdentifier, UpdateTableRequest 
updateTableRequest) {
+      IcebergRequestContext context,
+      TableIdentifier tableIdentifier,
+      UpdateTableRequest updateTableRequest) {
     return icebergCatalogWrapperManager
-        .getCatalogWrapper(catalogName)
+        .getCatalogWrapper(context.getCatalogName())
         .updateTable(tableIdentifier, updateTableRequest);
   }
 
   @Override
   public void dropTable(
-      String catalogName, TableIdentifier tableIdentifier, boolean 
purgeRequested) {
+      IcebergRequestContext context, TableIdentifier tableIdentifier, boolean 
purgeRequested) {
     if (purgeRequested) {
-      
icebergCatalogWrapperManager.getCatalogWrapper(catalogName).purgeTable(tableIdentifier);
+      icebergCatalogWrapperManager
+          .getCatalogWrapper(context.getCatalogName())
+          .purgeTable(tableIdentifier);
     } else {
-      
icebergCatalogWrapperManager.getCatalogWrapper(catalogName).dropTable(tableIdentifier);
+      icebergCatalogWrapperManager
+          .getCatalogWrapper(context.getCatalogName())
+          .dropTable(tableIdentifier);
     }
   }
 
   @Override
-  public LoadTableResponse loadTable(String catalogName, TableIdentifier 
tableIdentifier) {
-    return 
icebergCatalogWrapperManager.getCatalogWrapper(catalogName).loadTable(tableIdentifier);
+  public LoadTableResponse loadTable(
+      IcebergRequestContext context, TableIdentifier tableIdentifier) {
+    return icebergCatalogWrapperManager
+        .getCatalogWrapper(context.getCatalogName())
+        .loadTable(tableIdentifier);
   }
 
   @Override
-  public ListTablesResponse listTable(String catalogName, Namespace namespace) 
{
-    return 
icebergCatalogWrapperManager.getCatalogWrapper(catalogName).listTable(namespace);
+  public ListTablesResponse listTable(IcebergRequestContext context, Namespace 
namespace) {
+    return icebergCatalogWrapperManager
+        .getCatalogWrapper(context.getCatalogName())
+        .listTable(namespace);
   }
 
   @Override
-  public boolean tableExists(String catalogName, TableIdentifier 
tableIdentifier) {
-    return 
icebergCatalogWrapperManager.getCatalogWrapper(catalogName).tableExists(tableIdentifier);
+  public boolean tableExists(IcebergRequestContext context, TableIdentifier 
tableIdentifier) {
+    return icebergCatalogWrapperManager
+        .getCatalogWrapper(context.getCatalogName())
+        .tableExists(tableIdentifier);
   }
 
   @Override
-  public void renameTable(String catalogName, RenameTableRequest 
renameTableRequest) {
-    
icebergCatalogWrapperManager.getCatalogWrapper(catalogName).renameTable(renameTableRequest);
+  public void renameTable(IcebergRequestContext context, RenameTableRequest 
renameTableRequest) {
+    icebergCatalogWrapperManager
+        .getCatalogWrapper(context.getCatalogName())
+        .renameTable(renameTableRequest);
   }
 }
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
index ce245e945..a9ffe1265 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
@@ -49,6 +49,7 @@ import org.apache.gravitino.credential.CredentialProvider;
 import org.apache.gravitino.credential.CredentialUtils;
 import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;
 import org.apache.gravitino.iceberg.service.IcebergObjectMapper;
+import org.apache.gravitino.iceberg.service.IcebergRequestContext;
 import org.apache.gravitino.iceberg.service.IcebergRestUtils;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;
 import org.apache.gravitino.iceberg.service.metrics.IcebergMetricsManager;
@@ -81,9 +82,7 @@ public class IcebergTableOperations {
   private ObjectMapper icebergObjectMapper;
   private IcebergTableOperationDispatcher tableOperationDispatcher;
 
-  @SuppressWarnings("UnusedVariable")
-  @Context
-  private HttpServletRequest httpRequest;
+  @Context private HttpServletRequest httpRequest;
 
   @Inject
   public IcebergTableOperations(
@@ -105,8 +104,8 @@ public class IcebergTableOperations {
     String catalogName = IcebergRestUtils.getCatalogName(prefix);
     Namespace icebergNS = RESTUtil.decodeNamespace(namespace);
     LOG.info("List Iceberg tables, catalog: {}, namespace: {}", catalogName, 
icebergNS);
-    ListTablesResponse listTablesResponse =
-        tableOperationDispatcher.listTable(catalogName, icebergNS);
+    IcebergRequestContext context = new IcebergRequestContext(httpRequest, 
catalogName);
+    ListTablesResponse listTablesResponse = 
tableOperationDispatcher.listTable(context, icebergNS);
     return IcebergRestUtils.ok(listTablesResponse);
   }
 
@@ -130,8 +129,9 @@ public class IcebergTableOperations {
         createTableRequest,
         accessDelegation,
         isCredentialVending);
+    IcebergRequestContext context = new IcebergRequestContext(httpRequest, 
catalogName);
     LoadTableResponse loadTableResponse =
-        tableOperationDispatcher.createTable(catalogName, icebergNS, 
createTableRequest);
+        tableOperationDispatcher.createTable(context, icebergNS, 
createTableRequest);
     if (isCredentialVending) {
       return IcebergRestUtils.ok(
           injectCredentialConfig(
@@ -163,9 +163,10 @@ public class IcebergTableOperations {
           table,
           SerializeUpdateTableRequest(updateTableRequest));
     }
+    IcebergRequestContext context = new IcebergRequestContext(httpRequest, 
catalogName);
     TableIdentifier tableIdentifier = TableIdentifier.of(icebergNS, table);
     LoadTableResponse loadTableResponse =
-        tableOperationDispatcher.updateTable(catalogName, tableIdentifier, 
updateTableRequest);
+        tableOperationDispatcher.updateTable(context, tableIdentifier, 
updateTableRequest);
     return IcebergRestUtils.ok(loadTableResponse);
   }
 
@@ -188,7 +189,8 @@ public class IcebergTableOperations {
         table,
         purgeRequested);
     TableIdentifier tableIdentifier = TableIdentifier.of(namespace, table);
-    tableOperationDispatcher.dropTable(catalogName, tableIdentifier, 
purgeRequested);
+    IcebergRequestContext context = new IcebergRequestContext(httpRequest, 
catalogName);
+    tableOperationDispatcher.dropTable(context, tableIdentifier, 
purgeRequested);
     return IcebergRestUtils.noContent();
   }
 
@@ -216,8 +218,9 @@ public class IcebergTableOperations {
         isCredentialVending);
     // todo support snapshots
     TableIdentifier tableIdentifier = TableIdentifier.of(icebergNS, table);
+    IcebergRequestContext context = new IcebergRequestContext(httpRequest, 
catalogName);
     LoadTableResponse loadTableResponse =
-        tableOperationDispatcher.loadTable(catalogName, tableIdentifier);
+        tableOperationDispatcher.loadTable(context, tableIdentifier);
     if (isCredentialVending) {
       return IcebergRestUtils.ok(
           injectCredentialConfig(catalogName, tableIdentifier, 
loadTableResponse));
@@ -242,8 +245,9 @@ public class IcebergTableOperations {
         catalogName,
         icebergNS,
         table);
+    IcebergRequestContext context = new IcebergRequestContext(httpRequest, 
catalogName);
     TableIdentifier tableIdentifier = TableIdentifier.of(icebergNS, table);
-    boolean exists = tableOperationDispatcher.tableExists(catalogName, 
tableIdentifier);
+    boolean exists = tableOperationDispatcher.tableExists(context, 
tableIdentifier);
     if (exists) {
       return IcebergRestUtils.okWithoutContent();
     } else {
diff --git 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java
 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java
index 4d7ecef25..bced33e77 100644
--- 
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java
+++ 
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableRenameOperations.java
@@ -30,6 +30,7 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import org.apache.gravitino.iceberg.service.IcebergRequestContext;
 import org.apache.gravitino.iceberg.service.IcebergRestUtils;
 import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;
 import org.apache.gravitino.metrics.MetricNames;
@@ -43,9 +44,7 @@ import org.slf4j.LoggerFactory;
 public class IcebergTableRenameOperations {
   private static final Logger LOG = 
LoggerFactory.getLogger(IcebergTableOperations.class);
 
-  @SuppressWarnings("UnusedVariable")
-  @Context
-  private HttpServletRequest httpRequest;
+  @Context private HttpServletRequest httpRequest;
 
   private IcebergTableOperationDispatcher tableOperationDispatcher;
 
@@ -66,7 +65,8 @@ public class IcebergTableRenameOperations {
         catalogName,
         renameTableRequest.source(),
         renameTableRequest.destination());
-    tableOperationDispatcher.renameTable(catalogName, renameTableRequest);
+    IcebergRequestContext context = new IcebergRequestContext(httpRequest, 
catalogName);
+    tableOperationDispatcher.renameTable(context, renameTableRequest);
     return IcebergRestUtils.okWithoutContent();
   }
 }

Reply via email to