Hadoop YARN is the next generation computing platform in Apache Hadoop with support for programming paradigms besides MapReduce. In the world of Big Data, one cannot solve all the problems wholly using the Map Reduce programming model. Typical installations run separate programming models like MR, MPI, graph-processing frameworks on individual clusters. Running fewer larger clusters is cheaper than running more small clusters. Therefore,_leveraging YARN to allow both MR and non-MR applications to run on top of a common cluster becomes more important from an economical and operational point of view. This talk will cover the different APIs and RPC protocols that are available for developers to implement new application frameworks on top of YARN. We will also go through a simple application which demonstrates how one can implement their own Application Master, schedule requests to the YARN resource-manager and then subsequently use the allocated resources to run user code on the NodeManagers.
2. Hitesh Shah - Background
⢠Member of Technical Staff at Hortonworks Inc.
⢠Committer for Apache MapReduce and Ambari
⢠Earlier, spent 8+ years at Yahoo! building various
infrastructure pieces all the way from data storage
platforms to high throughput online ad-serving
systems.
Architecting the Future of Big Data
Page 2
Š Hortonworks Inc. 2011
3. Agenda
â˘YARN Architecture and Concepts
â˘Writing a New Framework
Architecting the Future of Big Data
Page 3
Š Hortonworks Inc. 2011
4. YARN Architecture
⢠Resource Manager
âGlobal resource scheduler
âHierarchical queues
⢠Node Manager
âPer-machine agent
âManages the life-cycle of container
âContainer resource monitoring
⢠Application Master
âPer-application
âManages application scheduling and task execution
âE.g. MapReduce Application Master
Architecting the Future of Big Data
Page 4
Š Hortonworks Inc. 2011
5. YARN Architecture
Node
Manager
Container App Mstr
Client
Resource Node
Manager Manager
Client
App Mstr Container
MapReduce Status Node
Manager
Job Submission
Node Status
Resource Request Container Container
Architecting the Future of Big Data
Page 5
Š Hortonworks Inc. 2011
6. YARN Concepts
⢠Application ID
âApplication Attempt IDs
⢠Container
âContainerLaunchContext
⢠ResourceRequest
âHost/Rack/Any match
âPriority
âResource constraints
⢠Local Resource
âFile/Archive
âVisibility â public/private/application
Architecting the Future of Big Data
Page 6
Š Hortonworks Inc. 2011
7. What you need for a new Framework
⢠Application Submission Client
âFor example, the MR Job Client
⢠Application Master
âThe core framework library
⢠Application History ( optional )
âHistory of all previously run instances
⢠Auxiliary Services ( optional )
âLong-running application-specific services running on the
NodeManager
Architecting the Future of Big Data
Page 7
Š Hortonworks Inc. 2011
8. Use Case: Distributed Shell
⢠Take a user-provided script Node
or application and run it on a Manager
set of nodes in the Cluster
DS AppMaster
⢠Input:
â User Script to execute
â Number of containers to run on Node
Manager
â Variable arguments for each
different container Shell Script
â Memory requirements for the
shell script Node
â Output Location/Dir Manager
Shell Script
Architecting the Future of Big Data
Page 8
Š Hortonworks Inc. 2011
9. Client: RPC calls
⢠Uses ClientRM Protocol
ClientRMProtocol#getNewApplication
⢠Get a new Application
ID from the RM
ClientRMProtocol#submitApplication
⢠Application Submission CLIENT
RM
ClientRMProtocol#getApplicationReport
⢠Application Monitoring
ClientRMProtocol#killApplication
⢠Kill the Application?
Architecting the Future of Big Data
Page 9
Š Hortonworks Inc. 2011
10. Client
⢠Registration with the RM
âNew Application ID
⢠Application Submission
âUser information
âScheduler queue
âDefine the container for the Distributed Shell App Master via
the ContainerLaunchContext
⢠Application Monitoring
â AppMaster host details with tokens if needed, tracking url
â Application Status (submitted/running/finished)
Architecting the Future of Big Data
Page 10
Š Hortonworks Inc. 2011
11. Defining a Container
⢠ContainerLaunchContext class
âCan run a shell script, a java process or launch a VM
⢠Command(s) to run
⢠Local resources needed for the process to run
âDependent jars, native libs, data files/archives
⢠Environment to setup
âJava Classpath
⢠Security-related data
âContainer Tokens
Architecting the Future of Big Data
Page 11
Š Hortonworks Inc. 2011
12. Application Master: RPC calls
⢠AMRM and CM protocols
Client
⢠Register AM with RM AMRM.registerAM
⢠Ask RM to allocate
resources AMRM.allocate
AM
RM
⢠Launch tasks on
allocated containers AMRM.
ďŹnishAM
App-speciďŹc
⢠Manage tasks to final RPC
completion
CM.startContainer
⢠Inform RM of completion NM NM
Architecting the Future of Big Data
Page 12
Š Hortonworks Inc. 2011
13. Application Master
⢠Setup RPC to handle requests from Client and/or tasks launched
on Containers
⢠Register and send regular heartbeats to the RM
⢠Request resources from the RM.
⢠Launch user shell script on containers as and when allocated.
⢠Monitor status of user script of remote containers and manage
failures by retrying if needed.
⢠Inform RM of completion when application is done.
Architecting the Future of Big Data
Page 13
Š Hortonworks Inc. 2011
14. AMRM#allocate
⢠Request:
â Containers needed
â Not a delta protocol
â Locality constraints: Host/Rack/Any
â Resource constraints: memory
â Priority-based assignments
â Containers to release â extra/unwanted?
â Only non-launched containers
⢠Response:
â Allocated Containers
â Launch or release
â Completed Containers
â Status of completion
Architecting the Future of Big Data
Page 14
Š Hortonworks Inc. 2011
15. YARN Applications
⢠Data Processing:
â OpenMPI on Hadoop
â Spark (UC Berkeley)
â Shark ( Hive-on-Spark )
â Real-time data processing
â Storm ( Twitter )
â Apache S4
â Graph processing â Apache Giraph
⢠Beyond data:
â Deploying Apache HBase via YARN (HBASE-4329)
â Hbase Co-processors via YARN (HBASE-4047)
Architecting the Future of Big Data
Page 15
Š Hortonworks Inc. 2011
16. References
â˘Doc on writing new applications:
âWritingYarnApplications.html ( available at
http://hadoop.apache.org/common/docs/r2.0.0-
alpha/ )
Architecting the Future of Big Data
Page 16
Š Hortonworks Inc. 2011
21. Client: App Monitoring
⢠Get Application Status
GetApplicationReportRequest reportRequest =
Records.newRecord(GetApplicationReportRequest.class);
reportRequest.setApplicationId(appId);
GetApplicationReportResponse reportResponse =
applicationsManager.getApplicationReport(reportRequest);
ApplicationReport report = reportResponse.getApplicationReport();
⢠Kill the application
KillApplicationRequest killRequest =
Records.newRecord(KillApplicationRequest.class);
killRequest.setApplicationId(appId);
applicationsManager.forceKillApplication(killRequest);
Architecting the Future of Big Data
Page 21
Š Hortonworks Inc. 2011
22. AM: Ask RM for Containers
ResourceRequest rsrcRequest;
rsrcRequest.setHostName("*â); // hostname, rack, wildcard
rsrcRequest.setPriority(pri);
Resource capability; capability.setMemory(containerMemory);
rsrcRequest.setCapability(capability)
rsrcRequest.setNumContainers(numContainers);
List<ResourceRequest> requestedContainers;
List<ContainerId> releasedContainers;
AllocateRequest req;
req.setResponseId(rmRequestID);
req.addAllAsks(requestedContainers);
req.addAllReleases(releasedContainers);
req.setProgress(currentProgress);
AllocateResponse allocateResponse = resourceManager.allocate(req);
Architecting the Future of Big Data
Page 22
Š Hortonworks Inc. 2011
23. AM: Launch Containers
AMResponse amResp = allocateResponse.getAMResponse();
ContainerManager cm = (ContainerManager)rpc.getProxy
(ContainerManager.class, cmAddress, conf);
List<Container> allocatedContainers = amResp.getAllocatedContainers();
for (Container allocatedContainer : allocatedContainers) {
ContainerLaunchContext ctx;
ctx.setContainerId(allocatedContainer .getId());
ctx.setResource(allocatedContainer .getResource());
// set env, command, local resources, âŚ
StartContainerRequest startReq;
startReq.setContainerLaunchContext(ctx);
cm.startContainer(startReq);
}
Architecting the Future of Big Data
Page 23
Š Hortonworks Inc. 2011
24. AM: Monitoring Containers
⢠Running Containers
GetContainerStatusRequest statusReq;
statusReq.setContainerId(containerId);
GetContainerStatusResponse statusResp =
cm.getContainerStatus(statusReq);
⢠Completed Containers
AMResponse amResp = allocateResponse.getAMResponse();
List<Container> completedContainersStatus =
amResp.getCompletedContainerStatuses();
for (ContainerStatus containerStatus : completedContainers) {
// containerStatus.getContainerId()
// containerStatus.getExitStatus()
// containerStatus.getDiagnostics()
}
Architecting the Future of Big Data
Page 24
Š Hortonworks Inc. 2011
25. AM: I am done
FinishApplicationMasterRequest finishReq;
finishReq.setAppAttemptId(appAttemptID);
finishReq.setFinishApplicationStatus
(FinalApplicationStatus.SUCCEEDED); // or FAILED
finishReq.setDiagnostics(diagnostics);
resourceManager.finishApplicationMaster(finishReq);
Architecting the Future of Big Data
Page 25
Š Hortonworks Inc. 2011