This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev-2.1.1
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev-2.1.1 by this push:
new b6e08f421 hadoop sample auth support
b6e08f421 is described below
commit b6e08f421a24025636386759c635984faf1086c2
Author: benjobs <[email protected]>
AuthorDate: Tue Jun 6 18:17:18 2023 +0800
hadoop sample auth support
---
.../org/apache/streampark/common/util/HadoopUtils.scala | 2 +-
.../org/apache/streampark/common/util/YarnUtils.scala | 14 +++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git
a/streampark-common/src/main/scala/org/apache/streampark/common/util/HadoopUtils.scala
b/streampark-common/src/main/scala/org/apache/streampark/common/util/HadoopUtils.scala
index fa6d3c267..aca0f75a8 100644
---
a/streampark-common/src/main/scala/org/apache/streampark/common/util/HadoopUtils.scala
+++
b/streampark-common/src/main/scala/org/apache/streampark/common/util/HadoopUtils.scala
@@ -58,7 +58,7 @@ object HadoopUtils extends Logger {
private[this] var tgt: KerberosTicket = _
- private lazy val hadoopUserName: String =
+ lazy val hadoopUserName: String =
InternalConfigHolder.get(CommonConfig.STREAMPARK_HADOOP_USER_NAME)
private[this] lazy val debugKerberos =
diff --git
a/streampark-common/src/main/scala/org/apache/streampark/common/util/YarnUtils.scala
b/streampark-common/src/main/scala/org/apache/streampark/common/util/YarnUtils.scala
index d9058de3d..4c5985010 100644
---
a/streampark-common/src/main/scala/org/apache/streampark/common/util/YarnUtils.scala
+++
b/streampark-common/src/main/scala/org/apache/streampark/common/util/YarnUtils.scala
@@ -56,6 +56,11 @@ object YarnUtils extends Logger {
"kerberos".equalsIgnoreCase(yarnHttpAuth)
}
+ lazy val hasYarnHttpSampleAuth: Boolean = {
+ val yarnHttpAuth: String =
InternalConfigHolder.get[String](CommonConfig.STREAMPARK_YARN_AUTH)
+ "sample".equalsIgnoreCase(yarnHttpAuth)
+ }
+
/**
* @param appName
* @return
@@ -256,15 +261,15 @@ object YarnUtils extends Logger {
def restRequest(url: String): String = {
if (url == null) return null
- def request(url: String): String = {
- logDebug("request url is " + url);
+ def request(reqUrl: String): String = {
+ logDebug("request url is " + reqUrl)
val config = RequestConfig.custom.setConnectTimeout(5000).build
if (hasYarnHttpKerberosAuth) {
HadoopUtils
.getUgi()
.doAs(new PrivilegedExceptionAction[String] {
override def run(): String = {
- Try(HttpClientUtils.httpAuthGetRequest(url, config)) match {
+ Try(HttpClientUtils.httpAuthGetRequest(reqUrl, config)) match {
case Success(v) => v
case Failure(e) =>
logError("yarnUtils authRestRequest error, detail: ", e)
@@ -273,6 +278,9 @@ object YarnUtils extends Logger {
}
})
} else {
+ val url = if (hasYarnHttpSampleAuth) {
+ s"$reqUrl?user.name=${HadoopUtils.hadoopUserName}"
+ } else reqUrl
Try(HttpClientUtils.httpGetRequest(url, config)) match {
case Success(v) => v
case Failure(e) =>