首页 > 解决方案 > 在 Apache hadoop 2.x 中。当前的 UserGroupInformation 是否会在子线程中丢失凭据?

问题描述

这是我用来演示问题的简单实验,用 scala 编写,Hadoop 2.7.7 作为唯一依赖项:


import org.apache.hadoop.security.UserGroupInformation

import scala.concurrent.duration.{Duration, MINUTES}
import scala.concurrent.{Await, ExecutionContext, Future}

object UGITest {
        val ugi = UserGroupInformation.getCurrentUser
        val credential = ugi.getCredentials

        val ff = Future {

          val _ugi = UserGroupInformation.getCurrentUser
          val _credential = _ugi.getCredentials

          require(ugi == _ugi, s"UGI is lost, before: $ugi, now ${_ugi}")

          require(credential == _credential, s"credential is lost, before: $credential, now ${_credential}")

        }(ExecutionContext.global)

        Await.result(ff, Duration.apply(1, MINUTES))
}

第一个需求ugi==_ugi成功通过,说明Future在子线程中成功启动了 的关闭。

第二个要求credential==_credential失败并显示以下信息:

java.lang.IllegalArgumentException: requirement failed: credential is lost, before: org.apache.hadoop.security.Credentials@cb6e68f, now org.apache.hadoop.security.Credentials@6b746674
    at scala.Predef$.require(Predef.scala:281)
    at ...

似乎使用了相同的 UserGroupInformation,但所有凭据都丢失了。这个设计的目的是什么?

上述实验只是在一台计算机上执行,而不是在任何集群中。我没有使用任何启用的hadoop 身份验证框架(例如kerberos)对其进行测试。但我认为结果或多或少是一样的。

标签: authenticationhadoophadoop2usergroups

解决方案


推荐阅读