Skip to content

Commit 1c361bb

Browse files
authored
[Fix-17036] Fix kerberos will not refresh in HdfsStorageOperator (#17039)
1 parent 045383f commit 1c361bb

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/main/java/org/apache/dolphinscheduler/plugin/storage/hdfs

dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/main/java/org/apache/dolphinscheduler/plugin/storage/hdfs/HdfsStorageOperator.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
package org.apache.dolphinscheduler.plugin.storage.hdfs;
1919

20+
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
2021
import org.apache.dolphinscheduler.common.utils.FileUtils;
22+
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
23+
import org.apache.dolphinscheduler.plugin.datasource.api.constants.DataSourceConstants;
2124
import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils;
2225
import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
2326
import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
@@ -51,6 +54,7 @@
5154
import java.util.Date;
5255
import java.util.LinkedList;
5356
import java.util.List;
57+
import java.util.concurrent.TimeUnit;
5458
import java.util.stream.Collectors;
5559

5660
import lombok.SneakyThrows;
@@ -102,6 +106,18 @@ private void init() {
102106

103107
if (CommonUtils.getKerberosStartupState()) {
104108
CommonUtils.loadKerberosConf(configuration);
109+
final Long kerberosExpireTimeInHour = PropertyUtils.getLong(DataSourceConstants.KERBEROS_EXPIRE_TIME, -1L);
110+
if (kerberosExpireTimeInHour > 0) {
111+
ThreadUtils.newDaemonScheduledExecutorService("ds-hdfs-kerberos-refresh-%s", 1)
112+
.scheduleWithFixedDelay(() -> {
113+
try {
114+
UserGroupInformation.getLoginUser().checkTGTAndReloginFromKeytab();
115+
log.info("checkTGTAndReloginFromKeytab finished");
116+
} catch (Exception e) {
117+
log.error("checkTGTAndReloginFromKeytab Error", e);
118+
}
119+
}, kerberosExpireTimeInHour, kerberosExpireTimeInHour, TimeUnit.MINUTES);
120+
}
105121
fs = FileSystem.get(configuration);
106122
log.info("Initialize HdfsStorageOperator with kerberos");
107123
return;

0 commit comments

Comments
 (0)