private static PrestoNode findCurrentNode(List<ServiceDescriptor> allServices, String currentNodeId, NodeVersion expectedNodeVersion, boolean httpsRequired)
{
for (ServiceDescriptor service : allServices) {
URI uri = getHttpUri(service, httpsRequired);
NodeVersion nodeVersion = getNodeVersion(service);
if (uri != null && nodeVersion != null) {
PrestoNode node = new PrestoNode(service.getNodeId(), uri, nodeVersion, isCoordinator(service));
if (node.getNodeIdentifier().equals(currentNodeId)) {
checkState(
node.getNodeVersion().equals(expectedNodeVersion),
"INVARIANT: current node version (%s) should be equal to %s",
node.getNodeVersion(),
expectedNodeVersion);
return node;
}
}
}
throw new IllegalStateException("INVARIANT: current node not returned from service selector");
}