hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wangzw <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request: HAWQ-38. Support HA for libyarn
Date Mon, 19 Oct 2015 09:33:38 GMT
Github user wangzw commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/27#discussion_r42351860
  
    --- Diff: depends/libyarn/src/libyarnclient/ApplicationClient.cpp ---
    @@ -4,29 +4,146 @@
     #include "rpc/RpcAuth.h"
     #include "common/XmlConfig.h"
     #include "common/SessionConfig.h"
    -
    +#include "Exception.h"
    +#include "ExceptionInternal.h"
     #include "ApplicationClient.h"
    +#include "StringUtil.h"
     
     namespace libyarn {
     
    +RMInfo::RMInfo() {
    +}
    +
    +const char * YARN_RESOURCEMANAGER_HA = "yarn.resourcemanager.ha";
    +
    +std::vector<RMInfo> RMInfo::getHARMInfo(const Yarn::Config & conf, const char*
name) {
    +	std::vector<RMInfo> retval;
    +	/*
    +	 * Read config and create a vector of RM address.
    +	 */
    +	try{
    +		std::string strHA = StringTrim(conf.getString(std::string(name)));
    +		std::vector<std::string> strRMs = StringSplit(strHA, ",");
    +		retval.resize(strRMs.size());
    +		for (size_t i = 0; i < strRMs.size(); ++i) {
    +			std::vector<std::string> rm = StringSplit(strRMs[i], ":");
    +			retval[i].setHost(rm[0]);
    +			retval[i].setPort(rm[1]);
    +		}
    +	} catch (const Yarn::YarnConfigNotFound &e) {
    +		LOG(INFO, "Yarn RM HA is not configured.");
    +	}
    +
    +	return retval;
    +}
    +
     ApplicationClient::ApplicationClient(string &user, string &host, string &port)
{
     	std::string tokenService = "";
     	Yarn::Internal::shared_ptr<Yarn::Config> conf = DefaultConfig().getConfig();
     	Yarn::Internal::SessionConfig sessionConfig(*conf);
     	LOG(INFO, "ApplicationClient session auth method : %s", sessionConfig.getRpcAuthMethod().c_str());
    -	appClient = (void*) new ApplicationClientProtocol(user, host, port, tokenService, sessionConfig);
    -}
     
    -ApplicationClient::ApplicationClient(ApplicationClientProtocol *appclient){
    -	appClient = (void*)appclient;
    +	std::vector<RMInfo> rmInfos = RMInfo::getHARMInfo(*conf, YARN_RESOURCEMANAGER_HA);
    +
    +    if (rmInfos.size() <= 1) {
    +    	LOG(INFO, "ApplicationClient Resource Manager HA is disable.");
    +        enableRMHA = false;
    +        maxRMHARetry = 0;
    +    } else {
    +    	LOG(INFO, "ApplicationClient Resource Manager HA is enable. Number of RM: %d", rmInfos.size());
    +    	enableRMHA = true;
    +    	maxRMHARetry = sessionConfig.getRpcMaxHaRetry();
    +    }
    +
    +    if (!enableRMHA)
    +    {
    +    	appClientProtos.push_back(
    +    		std::shared_ptr<ApplicationClientProtocol>(
    +    			new ApplicationClientProtocol(user, host, port, tokenService, sessionConfig)));
    +    }
    +    else {
    +    	/*
    +    	 * iterate RMInfo vector and create 1-1 applicationClientProtocol for each standby
RM
    +    	 */
    +		for (size_t i = 0; i < rmInfos.size(); ++i) {
    +			appClientProtos.push_back(
    --- End diff --
    
    should not mix tab and space


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message