jerryshao commented on code in PR #5495:
URL: https://github.com/apache/gravitino/pull/5495#discussion_r1835908517
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRequestContext.java:
##########
@@ -19,16 +19,23 @@
package org.apache.gravitino.iceberg.service;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import lombok.Getter;
+import org.apache.gravitino.utils.PrincipalUtils;
/** The general request context information for Iceberg REST operations. */
public class IcebergRequestContext {
- @Getter private final HttpServletRequest httpRequest;
+
@Getter private final String catalogName;
+ @Getter private final String userName;
+ @Getter private final String remoteIp;
Review Comment:
I think it should be made clear whether the return value is IP address or
hostname, or others, it should not be mixed conceptually.
Besides, do we need a remote port as well?
##########
iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java:
##########
@@ -119,4 +124,11 @@ protected void configure() {
}
return resourceConfig;
}
+
+ static HttpServletRequest createMockHttpRequest() {
+ HttpServletRequest mockRequest = mock(HttpServletRequest.class);
+ when(mockRequest.getRemoteAddr()).thenReturn("127.0.0.1");
+
when(mockRequest.getHeaderNames()).thenReturn(Collections.emptyEnumeration());
+ return mockRequest;
+ }
Review Comment:
Can you please add several UTs to cover your change for `Context` and
various `events`.
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRequestContext.java:
##########
@@ -19,16 +19,23 @@
package org.apache.gravitino.iceberg.service;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import lombok.Getter;
+import org.apache.gravitino.utils.PrincipalUtils;
/** The general request context information for Iceberg REST operations. */
public class IcebergRequestContext {
- @Getter private final HttpServletRequest httpRequest;
+
@Getter private final String catalogName;
+ @Getter private final String userName;
+ @Getter private final String remoteIp;
Review Comment:
This class now becomes a public class that will be leveraged by users. You
should move it to the `listener/api/event` package, also:
1. don't use lombok to generate the method, clearly define them manually and
add javadoc.
2. make the class stable and make all the event compatible.
--
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]