Example usage for org.apache.hadoop.registry.client.binding RegistryPathUtils encodeYarnID

List of usage examples for org.apache.hadoop.registry.client.binding RegistryPathUtils encodeYarnID

Introduction

In this page you can find the example usage for org.apache.hadoop.registry.client.binding RegistryPathUtils encodeYarnID.

Prototype

public static String encodeYarnID(String yarnId) 

Source Link

Document

Perform whatever transforms are needed to get a YARN ID into a DNS-compatible name

Usage

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//  w  ww .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;
}

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

License:Apache License

/**
 * Handler for {@link UnregisterComponentInstance}
 * //from w  w w  .  j  a v  a  2s. c  o m
 * unregister a component. At the time this message is received,
 * the component may not have been registered
 * @param id the component
 */
public void unregisterComponent(ContainerId id) {
    log.info("Unregistering component {}", id);
    if (yarnRegistryOperations == null) {
        log.warn("Processing unregister component event before initialization " + "completed; init flag ="
                + initCompleted);
        return;
    }
    String cid = RegistryPathUtils.encodeYarnID(id.toString());
    try {
        yarnRegistryOperations.deleteComponent(cid);
    } catch (IOException e) {
        log.warn("Failed to delete container {} : {}", id, e, e);
    }
}