@Override public void requestResources(SamzaResourceRequest resourceRequest){
  final int DEFAULT_PRIORITY=0;
  log.info("Requesting resources on  " + resourceRequest.getPreferredHost() + " for container "+ resourceRequest.getContainerID());
  int memoryMb=resourceRequest.getMemoryMB();
  int cpuCores=resourceRequest.getNumCores();
  String containerLabel=yarnConfig.getContainerLabel();
  String preferredHost=resourceRequest.getPreferredHost();
  Resource capability=Resource.newInstance(memoryMb,cpuCores);
  Priority priority=Priority.newInstance(DEFAULT_PRIORITY);
  AMRMClient.ContainerRequest issuedRequest;
  if (preferredHost.equals("ANY_HOST")) {
    log.info("Making a request for ANY_HOST " + preferredHost);
    issuedRequest=new AMRMClient.ContainerRequest(capability,null,null,priority,true,containerLabel);
  }
 else {
    log.info("Making a preferred host request on " + preferredHost);
    issuedRequest=new AMRMClient.ContainerRequest(capability,new String[]{preferredHost},null,priority,true,containerLabel);
  }
synchronized (lock) {
    requestsMap.put(resourceRequest,issuedRequest);
    amClient.addContainerRequest(issuedRequest);
  }
}

@ Override public void requestResources ( SamzaResourceRequest resourceRequest ) { final int DEFAULT_PRIORITY = 0 ; log . info ( "Requesting resources on  " + resourceRequest . getPreferredHost ( ) + " for container " + resourceRequest . getContainerID ( ) ) ; int memoryMb = resourceRequest . getMemoryMB ( ) ; int cpuCores = resourceRequest . getNumCores ( ) ; String containerLabel = yarnConfig . getContainerLabel ( ) ; String preferredHost = resourceRequest . getPreferredHost ( ) ; Resource capability = Resource . newInstance ( memoryMb , cpuCores ) ; Priority priority = Priority . newInstance ( DEFAULT_PRIORITY ) ; AMRMClient . ContainerRequest issuedRequest ; if ( preferredHost . equals ( "ANY_HOST" ) ) { log . info ( "Making a request for ANY_HOST " + preferredHost ) ; issuedRequest = new AMRMClient . ContainerRequest ( capability , null , null , priority , true , containerLabel ) ; } else { log . info ( "Making a preferred host request on " + preferredHost ) ; issuedRequest = new AMRMClient . ContainerRequest ( capability , new String [ ] { preferredHost } , null , priority , true , containerLabel ) ; } synchronized ( lock ) { requestsMap . put ( resourceRequest , issuedRequest ) ; amClient . addContainerRequest ( issuedRequest ) ; } }
request resources for running container processes .
