This is an automated email from the ASF dual-hosted git repository. yangzhg pushed a commit to branch libhdfs3 in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git
commit 19a12015b047937b79795aa6013e5e79f0416f5b Author: yangzhg <[email protected]> AuthorDate: Wed Jun 8 12:13:07 2022 +0800 add kerberos principal --- src/client/Hdfs.cpp | 8 ++++++++ src/client/hdfs.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/client/Hdfs.cpp b/src/client/Hdfs.cpp index 2840adc..fa250d0 100644 --- a/src/client/Hdfs.cpp +++ b/src/client/Hdfs.cpp @@ -229,6 +229,7 @@ public: shared_ptr<Config> conf; std::string nn; std::string userName; + std::string principal; tPort port; }; @@ -479,6 +480,8 @@ hdfsFS hdfsBuilderConnect(struct hdfsBuilder * bld) { if (!bld->token.empty()) { fs->connect(uri.c_str(), NULL, bld->token.c_str()); + } else if (!bld->principal.empty()) { + fs->connect(uri.c_str(), bld->principal.c_str(), NULL); } else { fs->connect(uri.c_str()); } @@ -534,6 +537,11 @@ void hdfsBuilderSetUserName(struct hdfsBuilder * bld, const char * userName) { bld->userName = userName; } +void hdfsBuilderSetPrincipal(struct hdfsBuilder * bld, const char * principal) { + assert(bld && principal && strlen(principal) > 0); + bld->principal = principal; +} + void hdfsBuilderSetKerbTicketCachePath(struct hdfsBuilder * bld, const char * kerbTicketCachePath) { assert(bld && kerbTicketCachePath && strlen(kerbTicketCachePath) > 0); diff --git a/src/client/hdfs.h b/src/client/hdfs.h index a60c150..6dd023c 100644 --- a/src/client/hdfs.h +++ b/src/client/hdfs.h @@ -203,6 +203,14 @@ void hdfsBuilderSetNameNodePort(struct hdfsBuilder * bld, tPort port); */ void hdfsBuilderSetUserName(struct hdfsBuilder * bld, const char * userName); +/** + * Set the Kerberos principal to use when connecting to the HDFS cluster. + * + * @param bld The HDFS builder + * @param principal The Kerberos principal. The string will be shallow-copied. + */ +void hdfsBuilderSetPrincipal(struct hdfsBuilder * bld, const char * principal); + /** * Set the path to the Kerberos ticket cache to use when connecting to * the HDFS cluster. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
