Example usage for org.apache.hadoop.registry.client.types.yarn PersistencePolicies APPLICATION

List of usage examples for org.apache.hadoop.registry.client.types.yarn PersistencePolicies APPLICATION

Introduction

In this page you can find the example usage for org.apache.hadoop.registry.client.types.yarn PersistencePolicies APPLICATION.

Prototype

String APPLICATION

To view the source code for org.apache.hadoop.registry.client.types.yarn PersistencePolicies APPLICATION.

Click Source Link

Document

Remove when the YARN application defined in the id field terminates: .

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 {//from w  ww  .  ja va  2  s .c o m
        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.server.appmaster.SliderAppMaster.java

License:Apache License

/**
 * This registers the service instance and its external values
 * @param instanceName name of this instance
 * @param appid application ID//  w ww.ja  v  a  2  s.  c om
 * @throws IOException
 */
private void registerServiceInstance(String instanceName, ApplicationId appid) throws IOException {

    // the registry is running, so register services
    URL amWebURI = new URL(appMasterTrackingUrl);
    URL agentOpsURI = new URL(agentOpsUrl);
    URL agentStatusURI = new URL(agentStatusUrl);

    //Give the provider restricted access to the state, registry
    setupInitialRegistryPaths();
    yarnRegistryOperations = new YarnRegistryViewForProviders(registryOperations, service_user_name,
            SliderKeys.APP_TYPE, instanceName, appAttemptID);
    providerService.bindToYarnRegistry(yarnRegistryOperations);
    sliderAMProvider.bindToYarnRegistry(yarnRegistryOperations);

    // Yarn registry
    ServiceRecord serviceRecord = new ServiceRecord();
    serviceRecord.set(YarnRegistryAttributes.YARN_ID, appid.toString());
    serviceRecord.set(YarnRegistryAttributes.YARN_PERSISTENCE, PersistencePolicies.APPLICATION);
    serviceRecord.description = "Slider Application Master";

    /* SLIDER-531: disable this addition so things compile against versions of
    the registry with/without the new record format
            
        serviceRecord.addExternalEndpoint(
            RegistryTypeUtils.ipcEndpoint(
    CustomRegistryConstants.AM_IPC_PROTOCOL,
    rpcServiceAddress));
            
        */
    // internal services
    sliderAMProvider.applyInitialRegistryDefinitions(amWebURI, agentOpsURI, agentStatusURI, serviceRecord);

    // provider service dynamic definitions.
    providerService.applyInitialRegistryDefinitions(amWebURI, agentOpsURI, agentStatusURI, serviceRecord);

    // register the service's entry
    log.info("Service Record \n{}", serviceRecord);
    yarnRegistryOperations.registerSelf(serviceRecord, true);
    log.info("Registered service under {}; absolute path {}", yarnRegistryOperations.getSelfRegistrationPath(),
            yarnRegistryOperations.getAbsoluteSelfRegistrationPath());

    boolean isFirstAttempt = 1 == appAttemptID.getAttemptId();
    // delete the children in case there are any and this is an AM startup.
    // just to make sure everything underneath is purged
    if (isFirstAttempt) {
        yarnRegistryOperations.deleteChildren(yarnRegistryOperations.getSelfRegistrationPath(), true);
    }
}