Example usage for org.apache.hadoop.registry.client.types.yarn YarnRegistryAttributes YARN_PERSISTENCE

List of usage examples for org.apache.hadoop.registry.client.types.yarn YarnRegistryAttributes YARN_PERSISTENCE

Introduction

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

Prototype

String YARN_PERSISTENCE

To view the source code for org.apache.hadoop.registry.client.types.yarn YarnRegistryAttributes YARN_PERSISTENCE.

Click Source Link

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 www  . j  ava2 s.co 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//from   w  ww . j av  a2 s.  co m
 * @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);
    }
}

From source file:org.apache.slider.server.appmaster.SliderAppMaster.java

License:Apache License

/**
 * Handler for {@link RegisterComponentInstance action}
 * Register/re-register an ephemeral container that is already in the app state
 * @param id the component//ww w.  j  a v a  2s  .c o  m
 * @param description
 */
public boolean registerComponent(ContainerId id, String description) throws IOException {
    RoleInstance instance = appState.getOwnedContainer(id);
    if (instance == null) {
        return false;
    }
    // this is where component registrations  go
    log.info("Registering component {}", id);
    String cid = RegistryPathUtils.encodeYarnID(id.toString());
    ServiceRecord container = new ServiceRecord();
    container.set(YarnRegistryAttributes.YARN_ID, cid);
    container.description = description;
    container.set(YarnRegistryAttributes.YARN_PERSISTENCE, PersistencePolicies.CONTAINER);
    try {
        yarnRegistryOperations.putComponent(cid, container);
    } catch (IOException e) {
        log.warn("Failed to register container {}/{}: {}", id, description, e, e);
    }
    return true;
}