Merge pull request #5946 from akonyaev90/add_user_parsing_in_HDFS_uri

WIP: add user parsing in HDFS URI
This commit is contained in:
alexey-milovidov 2019-07-09 20:35:57 +03:00 committed by GitHub
commit 97b75fe343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
#if USE_HDFS
#include <Common/Exception.h>
namespace DB
{
namespace ErrorCodes
@ -9,6 +10,7 @@ namespace ErrorCodes
extern const int BAD_ARGUMENTS;
extern const int NETWORK_ERROR;
}
HDFSBuilderPtr createHDFSBuilder(const Poco::URI & uri)
{
auto & host = uri.getHost();
@ -25,6 +27,18 @@ HDFSBuilderPtr createHDFSBuilder(const Poco::URI & uri)
hdfsBuilderConfSetStr(builder.get(), "input.write.timeout", "60000"); // 1 min
hdfsBuilderConfSetStr(builder.get(), "input.connect.timeout", "60000"); // 1 min
std::string user_info = uri.getUserInfo();
if (!user_info.empty() && user_info.front() != ':')
{
std::string user;
size_t delim_pos = user_info.find(":");
if (delim_pos != std::string::npos)
user = user_info.substr(0, delim_pos);
else
user = user_info;
hdfsBuilderSetUserName(builder.get(), user.c_str());
}
hdfsBuilderSetNameNode(builder.get(), host.c_str());
hdfsBuilderSetNameNodePort(builder.get(), port);
return builder;