Example usage for org.apache.hadoop.registry.client.types ServiceRecord getInternalEndpoint

List of usage examples for org.apache.hadoop.registry.client.types ServiceRecord getInternalEndpoint

Introduction

In this page you can find the example usage for org.apache.hadoop.registry.client.types ServiceRecord getInternalEndpoint.

Prototype

public Endpoint getInternalEndpoint(String api) 

Source Link

Document

Look up an internal endpoint

Usage

From source file:org.apache.hive.service.server.HiveServer2Instance.java

License:Apache License

public HiveServer2Instance(final ServiceRecord srv, final String endPointName) throws IOException {
    super(srv, endPointName);

    Endpoint activeEndpoint = srv.getInternalEndpoint(HS2ActivePassiveHARegistry.ACTIVE_ENDPOINT);
    Endpoint passiveEndpoint = srv.getInternalEndpoint(HS2ActivePassiveHARegistry.PASSIVE_ENDPOINT);
    this.isLeader = activeEndpoint != null;
    Preconditions.checkArgument(activeEndpoint == null || passiveEndpoint == null,
            "Incorrect service record. Both active and passive endpoints cannot be non-null!");
    this.transportMode = srv.get(HiveConf.ConfVars.HIVE_SERVER2_TRANSPORT_MODE.varname);
    if (transportMode.equalsIgnoreCase("http")) {
        this.httpEndpoint = srv.get(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_PATH.varname);
    } else {/*from  w w w.  j  a  v a2 s.co  m*/
        this.httpEndpoint = "";
    }
}

From source file:org.apache.hive.service.server.HS2ActivePassiveHARegistry.java

License:Apache License

@Override
protected HiveServer2Instance createServiceInstance(final ServiceRecord srv) throws IOException {
    Endpoint activeEndpoint = srv.getInternalEndpoint(HS2ActivePassiveHARegistry.ACTIVE_ENDPOINT);
    return new HiveServer2Instance(srv, activeEndpoint != null ? ACTIVE_ENDPOINT : PASSIVE_ENDPOINT);
}

From source file:org.apache.slider.client.ClientRegistryBinder.java

License:Apache License

/**
 * Get an endpont by API//from  www  . j a va 2 s .  co  m
 * @param record service record
 * @param api API
 * @param external flag to indicate this is an external record
 * @return the endpoint or null
 */
public static Endpoint getEndpoint(ServiceRecord record, String api, boolean external) {
    return external ? record.getExternalEndpoint(api) : record.getInternalEndpoint(api);
}

From source file:org.apache.slider.core.registry.retrieve.RegistryRetriever.java

License:Apache License

/**
 * Retrieve from a service by locating the
 * exported {@link CustomRegistryConstants#PUBLISHER_CONFIGURATIONS_API}
 * and working off it./*www  .j  a v  a  2  s . c  o m*/
 * @param record service record
 * @throws RegistryIOException the address type of the endpoint does
 * not match that expected (i.e. not a list of URLs), missing endpoint...
 */
public RegistryRetriever(ServiceRecord record) throws RegistryIOException {
    Endpoint internal = record.getInternalEndpoint(CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API);
    String url = null;
    if (internal != null) {
        List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(internal);
        if (addresses != null && !addresses.isEmpty()) {
            url = addresses.get(0);
        }
    }
    internalConfigurationURL = url;
    Endpoint external = record.getExternalEndpoint(CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API);
    url = null;
    if (external != null) {
        List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(external);
        if (addresses != null && !addresses.isEmpty()) {
            url = addresses.get(0);
        }
    }
    externalConfigurationURL = url;

    internal = record.getInternalEndpoint(CustomRegistryConstants.PUBLISHER_EXPORTS_API);
    url = null;
    if (internal != null) {
        List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(internal);
        if (addresses != null && !addresses.isEmpty()) {
            url = addresses.get(0);
        }
    }
    internalExportsURL = url;
    external = record.getExternalEndpoint(CustomRegistryConstants.PUBLISHER_EXPORTS_API);
    url = null;
    if (external != null) {
        List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(external);
        if (addresses != null && !addresses.isEmpty()) {
            url = addresses.get(0);
        }
    }
    externalExportsURL = url;
}