Search code examples
hadoophadoop-yarn

ContainerLaunchContext.setResource() missing of hadoop yarn


http://hadoop.apache.org/docs/r2.1.0-beta/hadoop-yarn/hadoop-yarn-site/WritingYarnApplications.html

I am try to make the example work well from the above link.but I can't compile the code below

 Resource capability = Records.newRecord(Resource.class);
 capability.setMemory(512);
 amContainer.setResource(capability);

 // Set the container launch content into the
 // ApplicationSubmissionContext
 appContext.setAMContainerSpec(amContainer);

amContainer is ContainerLaunchContext and my hadoop version is 2.1.0-beta. I did some investigation. I found there's no method "setResource" in ContainerLaunchContext

I have 3 question about this
1) the method has been removed or something?
2) if the method has been removed, how can I do now?
3) is there any doc about yarn, because I found the doc in website is very easy, I hope I can get a manual or something. for example, capability.setMemory(512); I don't know it's 512k or 512M according comments in code.


Solution

  • You can set memory available to ApplicationMaster via commend. As such:

    // Set the necessary command to execute the application master
    Vector<CharSequence> vargs = new Vector<CharSequence>(30);
    ...
    vargs.add("-Xmx" + amMemory + "m"); // notice "m" indicating megabytes, you can use also -Xms combined with -Xmx
    ... // transform vargs to String commands
    amContainer.setCommands(commands);
    

    This should solve your problem. As for the 3 questions. Yarn is rapidly evolving software. My advice forget documentation, get source code and read it. This will answer a lot of your questions.