Hisoka-X commented on code in PR #7809:
URL: https://github.com/apache/seatunnel/pull/7809#discussion_r1795246214
##########
seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java:
##########
@@ -273,12 +300,42 @@ private void initializeWithRemoteUserLogin() throws
Exception {
configuration,
hadoopConf.getRemoteUser(),
(configuration, userGroupInformation) -> {
- final FileSystem fileSystem =
FileSystem.get(configuration);
+ this.userGroupInformation = userGroupInformation;
+ this.fileSystem = FileSystem.get(configuration);
return Pair.of(userGroupInformation, fileSystem);
});
log.info("Create FileSystem success with RemoteUser: {}.",
hadoopConf.getRemoteUser());
- this.userGroupInformation = pair.getKey();
- this.fileSystem = pair.getValue();
- this.fileSystem.setWriteChecksum(false);
+ userGroupInformation = pair.getKey();
+ fileSystem = pair.getValue();
+ fileSystem.setWriteChecksum(false);
+ }
+
+ private <T> T execute(PrivilegedExceptionAction<T> action) throws
IOException {
+ if (isAuthTypeKerberos) {
+ return doAsPrivileged(action);
+ } else {
+ try {
+ return action.run();
+ } catch (IOException e) {
+ throw e;
+ } catch (SeaTunnelRuntimeException e) {
+ throw new SeaTunnelRuntimeException(e.getSeaTunnelErrorCode(),
e.getParams());
Review Comment:
```suggestion
} catch (IOException | SeaTunnelRuntimeException e) {
throw e;
```
##########
seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java:
##########
@@ -273,12 +300,42 @@ private void initializeWithRemoteUserLogin() throws
Exception {
configuration,
hadoopConf.getRemoteUser(),
(configuration, userGroupInformation) -> {
- final FileSystem fileSystem =
FileSystem.get(configuration);
+ this.userGroupInformation = userGroupInformation;
+ this.fileSystem = FileSystem.get(configuration);
return Pair.of(userGroupInformation, fileSystem);
});
log.info("Create FileSystem success with RemoteUser: {}.",
hadoopConf.getRemoteUser());
- this.userGroupInformation = pair.getKey();
- this.fileSystem = pair.getValue();
- this.fileSystem.setWriteChecksum(false);
+ userGroupInformation = pair.getKey();
+ fileSystem = pair.getValue();
+ fileSystem.setWriteChecksum(false);
+ }
+
+ private <T> T execute(PrivilegedExceptionAction<T> action) throws
IOException {
+ if (isAuthTypeKerberos) {
+ return doAsPrivileged(action);
+ } else {
+ try {
+ return action.run();
+ } catch (IOException e) {
+ throw e;
+ } catch (SeaTunnelRuntimeException e) {
+ throw new SeaTunnelRuntimeException(e.getSeaTunnelErrorCode(),
e.getParams());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private <T> T doAsPrivileged(PrivilegedExceptionAction<T> action) throws
IOException {
+ if (fileSystem == null || userGroupInformation == null) {
+ initialize();
+ }
+
+ try {
+ return userGroupInformation.doAs(action);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
Review Comment:
does this necessary?
##########
seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java:
##########
@@ -273,12 +300,42 @@ private void initializeWithRemoteUserLogin() throws
Exception {
configuration,
hadoopConf.getRemoteUser(),
(configuration, userGroupInformation) -> {
- final FileSystem fileSystem =
FileSystem.get(configuration);
+ this.userGroupInformation = userGroupInformation;
+ this.fileSystem = FileSystem.get(configuration);
return Pair.of(userGroupInformation, fileSystem);
});
log.info("Create FileSystem success with RemoteUser: {}.",
hadoopConf.getRemoteUser());
- this.userGroupInformation = pair.getKey();
- this.fileSystem = pair.getValue();
- this.fileSystem.setWriteChecksum(false);
+ userGroupInformation = pair.getKey();
+ fileSystem = pair.getValue();
+ fileSystem.setWriteChecksum(false);
+ }
+
+ private <T> T execute(PrivilegedExceptionAction<T> action) throws
IOException {
Review Comment:
Please add some comments about why we need execute method to run action?
--
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]