Skip to content

Commit

Permalink
支持kerberos刷新
Browse files Browse the repository at this point in the history
  • Loading branch information
peacewong committed Oct 30, 2024
1 parent 7057bb5 commit a735a99
Showing 1 changed file with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.linkis.common.utils.ByteTimeUtils;
import org.apache.linkis.hadoop.common.utils.HDFSUtils;
import org.apache.linkis.hadoop.common.utils.KerberosUtils;
import org.apache.linkis.metadata.dao.MdqDao;
import org.apache.linkis.metadata.domain.mdq.DomainCoversionUtils;
import org.apache.linkis.metadata.domain.mdq.Tunple;
Expand Down Expand Up @@ -383,14 +384,27 @@ private int getTableFileNum(String tableLocation) throws IOException {
}

private String getTableSize(String tableLocation) throws IOException {
String tableSize = "0B";
if (StringUtils.isNotBlank(tableLocation) && getRootHdfs().exists(new Path(tableLocation))) {
FileStatus tableFile = getFileStatus(tableLocation);
tableSize =
ByteTimeUtils.bytesToString(
getRootHdfs().getContentSummary(tableFile.getPath()).getLength());
try {
String tableSize = "0B";
if (StringUtils.isNotBlank(tableLocation) && getRootHdfs().exists(new Path(tableLocation))) {
FileStatus tableFile = getFileStatus(tableLocation);
tableSize =
ByteTimeUtils.bytesToString(
getRootHdfs().getContentSummary(tableFile.getPath()).getLength());
}
return tableSize;
} catch (IOException e) {
String message = e.getMessage();
String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e);
if (message != null && message.matches(DWSConfig.HDFS_FILE_SYSTEM_REST_ERRS)
|| rootCauseMessage.matches(DWSConfig.HDFS_FILE_SYSTEM_REST_ERRS)) {
logger.info("Failed to get tableSize, retry", e);
resetRootHdfs();
return getTableSize(tableLocation);
} else {
throw e;
}
}
return tableSize;
}

private static volatile FileSystem rootHdfs = null;
Expand All @@ -401,9 +415,8 @@ private FileStatus getFileStatus(String location) throws IOException {
} catch (IOException e) {
String message = e.getMessage();
String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e);
if ((message != null && message.matches(DWSConfig.HDFS_FILE_SYSTEM_REST_ERRS))
|| (rootCauseMessage != null
&& rootCauseMessage.matches(DWSConfig.HDFS_FILE_SYSTEM_REST_ERRS))) {
if (message != null && message.matches(DWSConfig.HDFS_FILE_SYSTEM_REST_ERRS)
|| rootCauseMessage.matches(DWSConfig.HDFS_FILE_SYSTEM_REST_ERRS)) {
logger.info("Failed to getFileStatus, retry", e);
resetRootHdfs();
return getFileStatus(location);
Expand All @@ -430,6 +443,7 @@ private FileSystem getRootHdfs() {
synchronized (this) {
if (rootHdfs == null) {
rootHdfs = HDFSUtils.getHDFSRootUserFileSystem();
KerberosUtils.startKerberosRefreshThread();
}
}
}
Expand Down

0 comments on commit a735a99

Please sign in to comment.