Example usage for org.apache.hadoop.yarn.server.api ApplicationInitializationContext getApplicationDataForService

List of usage examples for org.apache.hadoop.yarn.server.api ApplicationInitializationContext getApplicationDataForService

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.api ApplicationInitializationContext getApplicationDataForService.

Prototype

public ByteBuffer getApplicationDataForService() 

Source Link

Document

Get the data sent to the NodeManager via ContainerManagementProtocol#startContainers(StartContainersRequest) as part of ContainerLaunchContext#getServiceData()

Usage

From source file:org.apache.spark.network.yarn.YarnShuffleService.java

License:Apache License

@Override
public void initializeApplication(ApplicationInitializationContext context) {
    String appId = context.getApplicationId().toString();
    try {//from  w  w w  .j av  a 2s .c  o m
        ByteBuffer shuffleSecret = context.getApplicationDataForService();
        if (isAuthenticationEnabled()) {
            AppId fullId = new AppId(appId);
            if (db != null) {
                byte[] key = dbAppKey(fullId);
                byte[] value = mapper.writeValueAsString(shuffleSecret).getBytes(StandardCharsets.UTF_8);
                db.put(key, value);
            }
            secretManager.registerApp(appId, shuffleSecret);
        }
    } catch (Exception e) {
        logger.error("Exception when initializing application {}", appId, e);
    }
}

From source file:org.apache.tez.auxservices.ShuffleHandler.java

License:Apache License

@Override
public void initializeApplication(ApplicationInitializationContext context) {

    String user = context.getUser();
    ApplicationId appId = context.getApplicationId();
    ByteBuffer secret = context.getApplicationDataForService();
    // TODO these bytes should be versioned
    try {/*from   w  w w. ja  v a 2 s  . c o m*/
        Token<JobTokenIdentifier> jt = deserializeServiceData(secret);
        // TODO: Once SHuffle is out of NM, this can use MR APIs
        JobID jobId = new JobID(Long.toString(appId.getClusterTimestamp()), appId.getId());
        recordJobShuffleInfo(jobId, user, jt);
    } catch (IOException e) {
        LOG.error("Error during initApp", e);
        // TODO add API to AuxiliaryServices to report failures
    }
}

From source file:org.apache.tez.engine.common.shuffle.server.ShuffleHandler.java

License:Apache License

@Override
public void initializeApplication(ApplicationInitializationContext initAppContext) {
    // TODO these bytes should be versioned
    try {//from www.j  a va2s. c o m
        String user = initAppContext.getUser();
        ApplicationId appId = initAppContext.getApplicationId();
        ByteBuffer secret = initAppContext.getApplicationDataForService();
        Token<JobTokenIdentifier> jt = deserializeServiceData(secret);
        // TODO: Once SHuffle is out of NM, this can use MR APIs
        userRsrc.put(appId.toString(), user);
        LOG.info("Added token for " + appId.toString());
        secretManager.addTokenForJob(appId.toString(), jt);
    } catch (IOException e) {
        LOG.error("Error during initApp", e);
        // TODO add API to AuxiliaryServices to report failures
    }
}