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-12426 Add WUQueryDetails option to list applicable WsEcl Addresses #6617

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions esp/scm/ws_workunits.ecm
Expand Up @@ -1334,6 +1334,7 @@ ESPrequest WUQueryDetailsRequest
string QuerySet;
bool IncludeStateOnClusters(false);
bool IncludeSuperFiles(false);
bool IncludeWsEclAddresses(false);
};

ESPStruct QuerySuperFile
Expand Down Expand Up @@ -1366,6 +1367,7 @@ ESPresponse [exceptions_inline] WUQueryDetailsResponse
[min_ver("1.46")] int CountGraphs;
[min_ver("1.46")] ESParray<string> GraphIds;
[min_ver("1.50")] int ResourceURLCount;
[min_ver("1.51")] ESParray<string, Address> WsEclAddresses;
};

ESPrequest WUMultiQuerySetDetailsRequest
Expand Down
63 changes: 63 additions & 0 deletions esp/services/ws_workunits/ws_workunitsQuerySets.cpp
Expand Up @@ -1593,6 +1593,69 @@ bool CWsWorkunitsEx::onWUQueryDetails(IEspContext &context, IEspWUQueryDetailsRe
WsWuInfo winfo(context, wuid);
resp.setResourceURLCount(winfo.getResourceURLCount());
}
if (req.getIncludeWsEclAddresses())
{
StringBuffer daliAddress;
if (!daliServers.isEmpty())
{
const char *finger = daliServers.get();
while (*finger && !strchr(":;,", *finger))
daliAddress.append(*finger++);
}

StringArray wseclAddresses;
Owned<IEnvironmentFactory> factory = getEnvironmentFactory();
Owned<IConstEnvironment> env = factory->openEnvironment();
if (env)
{
Owned<IPropertyTree> root = &env->getPTree();
Owned<IPropertyTreeIterator> services = root->getElements("Software/EspService[Properties/@type='ws_ecl']");
StringArray serviceNames;
VStringBuffer xpath("Target[@name='%s']", querySet);
ForEach(*services)
{
IPropertyTree &service = services->query();
if (!service.hasProp("Target") || service.hasProp(xpath))
serviceNames.append(service.queryProp("@name"));
}

Owned<IPropertyTreeIterator> processes = root->getElements("Software/EspProcess");
ForEach(*processes)
{
StringArray netAddrs;
IPropertyTree &process = processes->query();
Owned<IPropertyTreeIterator> instances = process.getElements("Instance");
ForEach(*instances)
{
IPropertyTree &instance = instances->query();
const char *netAddr = instance.queryProp("@netAddress");
if (!netAddr || !*netAddr)
continue;
if (streq(netAddr, ".") && daliAddress.length())
Copy link
Member

Choose a reason for hiding this comment

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

Looks odd - if netAddr = "." - then assume EspProcess/Instance is on dali node?

I'm not clear why you need to special case "." here, but if it is in the environment, then it surely means everything i, includes this esp node.
So you should probably use SocketEndpoint to resolve ".".

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like that "." is used for a netAddress in the environment at all. Since the ESP running this code may be one with an explicitly configured address, while others have ".", I have to assume "." means the address of the dali. Weird but the safest way I think. If they move dali, they can't use "."... and then I'd be happier anyway.

Copy link
Member

Choose a reason for hiding this comment

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

So you're thinking with environment with a mixture of "."'s and explicity netAddresses.. that would be weird..
I'm not sure what it means..

I think a comment at very least is needed, but really I think since "." means my local IP, it it SocketEndpoint(".") does not match your local IP - then I'd be temped to error with a mis-configuration issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I'll first think about looking up the computer reference rather than using the netAddress.

netAddrs.append(daliAddress);
else
netAddrs.append(netAddr);
}
Owned<IPropertyTreeIterator> bindings = process.getElements("EspBinding");
ForEach(*bindings)
{
IPropertyTree &binding = bindings->query();
const char *srvName = binding.queryProp("@service");
if (!serviceNames.contains(srvName))
continue;
Copy link
Member

Choose a reason for hiding this comment

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

There can be >1 EspBinding with the same @server name ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, ESP supports it. I can bind the same service configuration to multiple ports and with different protocols.

const char *port = binding.queryProp("@port");
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be a getPropInt ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It definitely could be. I just use it to build a string so thought converting twice was wasteful. Should I switch to getPropInt?

Copy link
Member

Choose a reason for hiding this comment

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

Nah fair enough, a comment perhaps that should always be an int.

if (!port || !*port)
continue;
ForEachItemIn(i, netAddrs)
{
VStringBuffer wseclAddr("%s:%s", netAddrs.item(i), port);
wseclAddresses.append(wseclAddr);
}
}
}
}
resp.setWsEclAddresses(wseclAddresses);
}

return true;
}
Expand Down