List of usage examples for org.apache.hadoop.yarn.api.protocolrecords AllocateRequest setProgress
@Public @Stable public abstract void setProgress(float progress);
From source file:edu.uci.ics.hyracks.yarn.am.HyracksYarnApplicationMaster.java
License:Apache License
private void setupHeartbeats() { long heartbeatInterval = config.getLong(YarnConfiguration.RM_AM_EXPIRY_INTERVAL_MS, YarnConfiguration.DEFAULT_RM_AM_EXPIRY_INTERVAL_MS); System.err.println("Heartbeat interval: " + heartbeatInterval); heartbeatInterval = Math.min(heartbeatInterval, 1000); System.err.println("Heartbeat interval: " + heartbeatInterval); timer.schedule(new TimerTask() { @Override//from w ww . j ava 2 s. c o m public void run() { AllocateRequest hb = Records.newRecord(AllocateRequest.class); populateAllocateRequest(hb); hb.setApplicationAttemptId(amrmc.getApplicationAttemptId()); hb.setProgress(0); try { AllocateResponse allocateResponse = amrmc.getAMRMProtocol().allocate(hb); List<Container> allocatedContainers = allocateResponse.getAMResponse().getAllocatedContainers(); List<ContainerStatus> completedContainers = allocateResponse.getAMResponse() .getCompletedContainersStatuses(); processAllocation(allocatedContainers, completedContainers); } catch (YarnRemoteException e) { e.printStackTrace(); } } }, 0, heartbeatInterval); }
From source file:org.springframework.yarn.am.allocate.DefaultContainerAllocator.java
License:Apache License
@Override protected AllocateResponse doContainerRequest() { List<ResourceRequest> requestedContainers = new ArrayList<ResourceRequest>(); Map<String, Integer> allocateCounts = allocateCountTracker.getAllocateCounts(); for (Entry<String, Integer> entry : allocateCounts.entrySet()) { requestedContainers.add(getContainerResourceRequest(entry.getValue(), entry.getKey())); }// w w w . j a v a 2 s. c o m // add pending containers to be released List<ContainerId> release = new ArrayList<ContainerId>(); ContainerId element = null; while ((element = releaseContainers.poll()) != null) { release.add(element); } if (log.isDebugEnabled()) { log.debug("Requesting containers using " + requestedContainers.size() + " requests."); for (ResourceRequest resourceRequest : requestedContainers) { log.debug( "ResourceRequest: " + resourceRequest + " with count=" + resourceRequest.getNumContainers() + " with hostName=" + resourceRequest.getResourceName()); } log.debug("Releasing containers " + release.size()); for (ContainerId cid : release) { log.debug("Release container=" + cid); } log.debug("Request id will be: " + requestId.get()); } // build the allocation request AllocateRequest request = Records.newRecord(AllocateRequest.class); request.setResponseId(requestId.get()); request.setAskList(requestedContainers); request.setReleaseList(release); request.setProgress(applicationProgress); // do request and return response AllocateResponse allocate = getRmTemplate().allocate(request); requestId.set(allocate.getResponseId()); return allocate; }