Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-33292 Common-up code for creating roxie connection map #19502

Open
wants to merge 2 commits into
base: candidate-9.10.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions esp/services/ws_ecl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ include_directories (
./../../../common/fileview2
./../../../dali/base
${HPCC_SOURCE_DIR}/common/thorhelper
${HPCC_SOURCE_DIR}/esp/smc/SMCLib
${HPCC_SOURCE_DIR}/dali/sasha
)

ADD_DEFINITIONS( -D_USRDLL )
Expand All @@ -77,6 +79,7 @@ target_link_libraries ( ws_ecl
hql
fileview2
xmllib
SMCLib
${COMMON_ESP_SERVICE_LIBS}
)

Expand Down
52 changes: 5 additions & 47 deletions esp/services/ws_ecl/ws_ecl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include "jsonhelpers.hpp"
#include "securesocket.hpp"

#define SDS_LOCK_TIMEOUT (5*60*1000) // 5mins, 30s a bit short
#include "TpWrapper.hpp"


#define WSECL_ACCESS "WsEclAccess"
static const char* WSECL_ACCESS_DENIED = "WsEcl access permission denied.";
Expand Down Expand Up @@ -178,30 +179,6 @@ static void escapeSingleQuote(StringBuffer& src, StringBuffer& escaped)
}
}

static void appendServerAddress(StringBuffer &s, IPropertyTree &env, IPropertyTree &server, const char *daliAddress, const char *farmerPort)
{
//just in case, for backward compatability with old environment.xml files, allow server rather than farmer to specify port
const char *port = server.queryProp("@port");
if (!port)
port = farmerPort;
if (port && streq(port, "0")) //0 == roxie listening on queue rather than port
return;

const char *netAddress = server.queryProp("@netAddress");
if (!netAddress && server.hasProp("@computer"))
{
VStringBuffer xpath("Hardware/Computer[@name='%s']/@netAddress", server.queryProp("@computer"));
netAddress = env.queryProp(xpath.str());
}
if ((!netAddress || *netAddress=='.') && daliAddress && *daliAddress)
netAddress = daliAddress;
if (!netAddress || !*netAddress)
return;
if (s.length())
s.append('|');
s.append(netAddress).append(':').append(port ? port : "9876");
}

class WsEclSocketFactory : public CSmartSocketFactory
{
public:
Expand Down Expand Up @@ -234,7 +211,7 @@ void initContainerRoxieTargets(MapStringToMyClass<ISmartSocketFactory> &connMap)
}

#ifndef _CONTAINERIZED
void initBareMetalRoxieTargets(MapStringToMyClass<ISmartSocketFactory> &connMap, IPropertyTree *serviceTree, const char *daliAddress)
void initWsEclBareMetalRoxieTargets(MapStringToMyClass<ISmartSocketFactory> &connMap, IPropertyTree *serviceTree, const char *daliAddress)
{
IPropertyTree *vips = serviceTree->queryPropTree("VIPS");
Owned<IStringIterator> roxieTargets = getTargetClusters("RoxieCluster", NULL);
Expand Down Expand Up @@ -283,29 +260,10 @@ void initBareMetalRoxieTargets(MapStringToMyClass<ISmartSocketFactory> &connMap,
}
else
{
const char *farmerPort = nullptr;
VStringBuffer xpath("Software/RoxieCluster[@name='%s'][1]", process.str());
IPropertyTree *roxieCluster = pRoot->queryPropTree(xpath.str());
if (roxieCluster)
{
//port and TLS config come from farmer, node addresses come from server
Owned<IPropertyTreeIterator> farmers = roxieCluster->getElements("RoxieFarmProcess");
ForEach(*farmers)
{
IPropertyTree &farmer = farmers->query();
const char *port = farmer.queryProp("@port");
if (!port || streq(port, "0"))
continue;
farmerPort = port;
const char *protocol = farmer.queryProp("@protocol");
if (protocol && streq(protocol, "ssl"))
tlsConfig.setown(createSecureSocketConfig(farmer.queryProp("@certificateFileName"), farmer.queryProp("@privateKeyFileName"), nullptr, true));
break; //use the first one without port==0
}
Owned<IPropertyTreeIterator> servers = roxieCluster->getElements("RoxieServerProcess");
ForEach(*servers)
appendServerAddress(list, *pRoot, servers->query(), daliAddress, farmerPort);
}
getAddressesAndTlsConfigForRoxieProcess(*pRoot, *roxieCluster, list, tlsConfig, daliAddress);
}
if (list.length())
{
Expand Down Expand Up @@ -359,7 +317,7 @@ bool CWsEclService::init(const char * name, const char * type, IPropertyTree * c
#ifdef _CONTAINERIZED
initContainerRoxieTargets(connMap);
#else
initBareMetalRoxieTargets(connMap, serviceTree, daliAddress.str());
initWsEclBareMetalRoxieTargets(connMap, serviceTree, daliAddress.str());
#endif
translator = new wsEclTypeTranslator();

Expand Down
56 changes: 31 additions & 25 deletions esp/smc/SMCLib/TpWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,7 @@ extern TPWRAPPER_API void initContainerRoxieTargets(MapStringToMyClass<ISmartSoc
}
}

void appendServerAddress(StringBuffer& list, IPropertyTree& env, IPropertyTree& server, const char* farmerPort)
void appendServerAddress(StringBuffer& list, IPropertyTree& env, IPropertyTree& server, const char* farmerPort, const char* daliAddress)
{
//just in case, for backward compatability with old environment.xml files, allow server rather than farmer to specify port
const char *port = server.queryProp("@port");
Expand All @@ -2108,6 +2108,8 @@ void appendServerAddress(StringBuffer& list, IPropertyTree& env, IPropertyTree&
VStringBuffer xpath("Hardware/Computer[@name='%s']/@netAddress", server.queryProp("@computer"));
netAddress = env.queryProp(xpath.str());
}
if ((!netAddress || *netAddress=='.') && daliAddress && *daliAddress)
netAddress = daliAddress;
if (!netAddress || !*netAddress)
return;
if (list.length())
Expand All @@ -2131,36 +2133,40 @@ extern TPWRAPPER_API void initBareMetalRoxieTargets(MapStringToMyClass<ISmartSoc

StringBuffer addressList;
StringBuffer port("");
Owned<IPropertyTree> tlsConfig = createPTree("none");
Owned<IPropertyTree> tlsConfig;
getAddressesAndTlsConfigForRoxieProcess(*envRoot, roxieCluster, addressList, tlsConfig, nullptr);

Owned<IPropertyTreeIterator> roxieFarms = roxieCluster.getElements("RoxieFarmProcess");
ForEach(*roxieFarms)
Owned<ISmartSocketFactory> sf = tlsConfig.get() != nullptr ? createSecureSmartSocketFactory(addressList, tlsConfig) : createSmartSocketFactory(addressList);
connMap.setValue(name, sf.get());
}
}

extern TPWRAPPER_API void getAddressesAndTlsConfigForRoxieProcess(IPropertyTree& env, IPropertyTree& roxieCluster, StringBuffer& addrList, Owned<IPropertyTree> & tlsConfig, const char* daliAddress)
{
StringBuffer preferredPort;
Owned<IPropertyTreeIterator> roxieFarms = roxieCluster.getElements("RoxieFarmProcess");
ForEach(*roxieFarms)
{
IPropertyTree& farm = roxieFarms->query();
const char* farmPort = farm.queryProp("@port");
if (!isEmptyString(farmPort) && !streq(farmPort, "0"))
{
IPropertyTree& farm = roxieFarms->query();
const char* farmPort = farm.queryProp("@port");
if (!isEmptyString(farmPort) && !streq(farmPort, "0"))
const char *protocol = farm.queryProp("@protocol");
if (!isEmptyString(protocol) && strieq(protocol, "ssl"))
{
const char *protocol = farm.queryProp("@protocol");
if (!isEmptyString(protocol) && strieq(protocol, "ssl"))
{
port.set(farmPort);
tlsConfig.setown(createSecureSocketConfig(farm.queryProp("@certificateFileName"), farm.queryProp("@privateKeyFileName"), nullptr, true));
break;
}
else if (isEmptyString(port.str()))
{
port.set(farmPort);
}
preferredPort.set(farmPort);
tlsConfig.setown(createSecureSocketConfig(farm.queryProp("@certificateFileName"), farm.queryProp("@privateKeyFileName"), nullptr, true));
break;
}
else if (isEmptyString(preferredPort.str()))
{
preferredPort.set(farmPort);
}
}

Owned<IPropertyTreeIterator> roxieServers = roxieCluster.getElements("RoxieServerProcess");
ForEach(*roxieServers)
appendServerAddress(addressList, *envRoot, roxieServers->query(), port.str());

Owned<ISmartSocketFactory> sf = streq(tlsConfig->queryName(), "ssl") ? createSecureSmartSocketFactory(addressList, tlsConfig) : createSmartSocketFactory(addressList);
connMap.setValue(name, sf.get());
}
Owned<IPropertyTreeIterator> roxieServers = roxieCluster.getElements("RoxieServerProcess");
ForEach(*roxieServers)
appendServerAddress(addrList, env, roxieServers->query(), preferredPort.str(), daliAddress);
}

extern TPWRAPPER_API void getRoxieTargetsSupportingPublishedQueries(StringArray& names)
Expand Down
10 changes: 10 additions & 0 deletions esp/smc/SMCLib/TpWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ extern TPWRAPPER_API unsigned getContainerWUClusterInfo(CConstWUClusterInfoArray
extern TPWRAPPER_API unsigned getWUClusterInfo(CConstWUClusterInfoArray& clusters);
extern TPWRAPPER_API IConstWUClusterInfo* getWUClusterInfoByName(const char* clustName);

/**
* Get pipe-delimited list of roxie server addresses and TLS config from environment configuration for the roxie process named `process`.
* @param env environment configuration
* @param process roxie process name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name doesn't match. Looks like line 211 refers to this name as well.

* @param addrList pipe-delimited list of roxie server addresses
* @param tlsConfig TLS configuration
* @param daliAddress optional dali address to use for ws_ecl service if `@netAddress` not found in `server` configuration
* @return void
*/
extern TPWRAPPER_API void getAddressesAndTlsConfigForRoxieProcess(IPropertyTree& env, IPropertyTree& roxieCluster, StringBuffer& addrList, Owned<IPropertyTree> & tlsConfig, const char* daliAddress);
extern TPWRAPPER_API void initContainerRoxieTargets(MapStringToMyClass<ISmartSocketFactory>& connMap);
extern TPWRAPPER_API void initBareMetalRoxieTargets(MapStringToMyClass<ISmartSocketFactory>& connMap);
extern TPWRAPPER_API unsigned getThorClusterNames(StringArray& targetNames, StringArray& queueNames);
Expand Down
Loading