Search in sources :

Example 6 with Endpoint

use of org.apache.hadoop.registry.client.types.Endpoint in project hive by apache.

the class LlapZookeeperRegistryImpl method getServicesEndpoint.

public Endpoint getServicesEndpoint() {
    final int servicePort = HiveConf.getIntVar(conf, ConfVars.LLAP_DAEMON_WEB_PORT);
    final boolean isSSL = HiveConf.getBoolVar(conf, ConfVars.LLAP_DAEMON_WEB_SSL);
    final String scheme = isSSL ? "https" : "http";
    final URL serviceURL;
    try {
        serviceURL = new URL(scheme, hostname, servicePort, "");
        return RegistryTypeUtils.webEndpoint(IPC_SERVICES, serviceURL.toURI());
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    } catch (URISyntaxException e) {
        throw new RuntimeException("llap service URI for " + hostname + " is invalid", e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) Endpoint(org.apache.hadoop.registry.client.types.Endpoint) URL(java.net.URL)

Example 7 with Endpoint

use of org.apache.hadoop.registry.client.types.Endpoint in project hadoop by apache.

the class RegistryTestHelper method findEndpoint.

/**
   * Find an endpoint in a record or fail,
   * @param record record
   * @param api API
   * @param external external?
   * @param addressElements expected # of address elements?
   * @param addressTupleSize expected size of a type
   * @return the endpoint.
   */
public static Endpoint findEndpoint(ServiceRecord record, String api, boolean external, int addressElements, int addressTupleSize) {
    Endpoint epr = external ? record.getExternalEndpoint(api) : record.getInternalEndpoint(api);
    if (epr != null) {
        assertEquals("wrong # of addresses", addressElements, epr.addresses.size());
        assertEquals("wrong # of elements in an address tuple", addressTupleSize, epr.addresses.get(0).size());
        return epr;
    }
    List<Endpoint> endpoints = external ? record.external : record.internal;
    StringBuilder builder = new StringBuilder();
    for (Endpoint endpoint : endpoints) {
        builder.append("\"").append(endpoint).append("\" ");
    }
    fail("Did not find " + api + " in endpoints " + builder);
    // never reached; here to keep the compiler happy
    return null;
}
Also used : Endpoint(org.apache.hadoop.registry.client.types.Endpoint)

Aggregations

Endpoint (org.apache.hadoop.registry.client.types.Endpoint)7 URISyntaxException (java.net.URISyntaxException)3 Map (java.util.Map)3 ServiceRecord (org.apache.hadoop.registry.client.types.ServiceRecord)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 InetSocketAddress (java.net.InetSocketAddress)1 URI (java.net.URI)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 GnuParser (org.apache.commons.cli.GnuParser)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1 PersistentEphemeralNode (org.apache.curator.framework.recipes.nodes.PersistentEphemeralNode)1 PathNotFoundException (org.apache.hadoop.fs.PathNotFoundException)1