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

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

Introduction

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

Prototype

public void addExternalEndpoint(Endpoint endpoint) 

Source Link

Document

Add an external endpoint

Usage

From source file:org.apache.slider.providers.hbase.HBaseProviderService.java

License:Apache License

private void registerHBaseServiceEntry() throws IOException {

    String name = amState.getApplicationName();
    ServiceRecord serviceRecord = new ServiceRecord();
    // bond lifespan to the application
    serviceRecord.set(YarnRegistryAttributes.YARN_ID,
            yarnRegistry.getApplicationAttemptId().getApplicationId().toString());
    serviceRecord.set(YarnRegistryAttributes.YARN_PERSISTENCE, PersistencePolicies.APPLICATION);
    try {// w  w  w .  j av a2 s. c om
        URL configURL = new URL(amWebAPI, SLIDER_PATH_PUBLISHER + "/" + HBASE_SERVICE_TYPE);

        serviceRecord.addExternalEndpoint(RegistryTypeUtils
                .restEndpoint(CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API, configURL.toURI()));
    } catch (URISyntaxException e) {
        log.warn("failed to create config URL: {}", e, e);
    }
    log.info("registering {}/{}", name, HBASE_SERVICE_TYPE);
    yarnRegistry.putService(HBASE_SERVICE_TYPE, name, serviceRecord, true);

    PublishedConfiguration publishedSite = new PublishedConfiguration("HBase site", siteConf);
    PublishedConfigSet configSet = amState.getOrCreatePublishedConfigSet(HBASE_SERVICE_TYPE);

    configSet.put(HBASE_SITE_PUBLISHED_CONFIG, publishedSite);
}

From source file:org.apache.slider.providers.slideram.SliderAMProviderService.java

License:Apache License

@Override
public void applyInitialRegistryDefinitions(URL amWebURI, URL agentOpsURI, URL agentStatusURI,
        ServiceRecord serviceRecord) throws IOException {
    super.applyInitialRegistryDefinitions(amWebURI, agentOpsURI, agentStatusURI, serviceRecord);
    // now publish site.xml files
    YarnConfiguration defaultYarnConfig = new YarnConfiguration();
    amState.getPublishedSliderConfigurations().put(PublishedArtifacts.COMPLETE_CONFIG,
            new PublishedConfiguration("Complete slider application settings", getConfig(), getConfig()));
    amState.getPublishedSliderConfigurations().put(PublishedArtifacts.YARN_SITE_CONFIG,
            new PublishedConfiguration("YARN site settings", ConfigHelper.loadFromResource("yarn-site.xml"),
                    defaultYarnConfig));

    amState.getPublishedSliderConfigurations().put(PublishedArtifacts.CORE_SITE_CONFIG,
            new PublishedConfiguration("Core site settings", ConfigHelper.loadFromResource("core-site.xml"),
                    defaultYarnConfig));
    amState.getPublishedSliderConfigurations().put(PublishedArtifacts.HDFS_SITE_CONFIG,
            new PublishedConfiguration("HDFS site settings", ConfigHelper.loadFromResource("hdfs-site.xml"),
                    new HdfsConfiguration(true)));

    try {//from www . j a v  a 2  s .c  om

        URL managementAPI = new URL(amWebURI, SLIDER_PATH_MANAGEMENT);
        URL registryREST = new URL(amWebURI, SLIDER_PATH_REGISTRY);

        URL publisherURL = new URL(amWebURI, SLIDER_PATH_PUBLISHER);

        // Set the configurations URL.

        String configurationsURL = SliderUtils.appendToURL(publisherURL.toExternalForm(),
                RestPaths.SLIDER_CONFIGSET);
        String exportsURL = SliderUtils.appendToURL(publisherURL.toExternalForm(), RestPaths.SLIDER_EXPORTS);

        serviceRecord.addExternalEndpoint(
                RegistryTypeUtils.webEndpoint(CustomRegistryConstants.WEB_UI, amWebURI.toURI()));
        serviceRecord.addExternalEndpoint(RegistryTypeUtils
                .restEndpoint(CustomRegistryConstants.MANAGEMENT_REST_API, managementAPI.toURI()));
        serviceRecord.addExternalEndpoint(RegistryTypeUtils
                .restEndpoint(CustomRegistryConstants.PUBLISHER_REST_API, publisherURL.toURI()));
        serviceRecord.addExternalEndpoint(RegistryTypeUtils
                .restEndpoint(CustomRegistryConstants.REGISTRY_REST_API, registryREST.toURI()));
        serviceRecord.addExternalEndpoint(RegistryTypeUtils.restEndpoint(
                CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API, new URI(configurationsURL)));
        serviceRecord.addExternalEndpoint(RegistryTypeUtils
                .restEndpoint(CustomRegistryConstants.PUBLISHER_EXPORTS_API, new URI(exportsURL)));

    } catch (URISyntaxException e) {
        throw new IOException(e);
    }
}