/** * Request containers for resources before calling <code>allocate</code> * @param req Resource request */ public void addContainerRequest(T req) { client.addContainerRequest(req); }
@Override protected void shutDown() throws Exception { nmClient.stopAndWait(); amrmClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, null, trackerUrl.toString()); amrmClient.stop(); }
/** * Update application's blacklist with addition or removal resources. * * @param blacklistAdditions list of resources which should be added to the * application blacklist * @param blacklistRemovals list of resources which should be removed from the * application blacklist */ public void updateBlacklist(List<String> blacklistAdditions, List<String> blacklistRemovals) { client.updateBlacklist(blacklistAdditions, blacklistRemovals); }
AMRMClient<ContainerRequest> rmClient = AMRMClient.createAMRMClient(); rmClient.init(conf); rmClient.start(); rmClient.registerApplicationMaster("", 0, ""); System.out.println("registerApplicationMaster 1"); ContainerRequest containerAsk = new ContainerRequest(capability, null, null, priority); System.out.println("Making res-req " + i); rmClient.addContainerRequest(containerAsk); int completedContainers = 0; while (completedContainers < n) { AllocateResponse response = rmClient.allocate(responseId++); for (Container container : response.getAllocatedContainers()) { rmClient.unregisterApplicationMaster( FinalApplicationStatus.SUCCEEDED, "", "");
LOG.debug("Removing container request: {}", removedContainerRequests); for (ContainerRequest cr : removedContainerRequests) { amRmClient.removeContainerRequest(cr); LOG.debug("Asking RM for containers: {}", containerRequests); for (ContainerRequest cr : containerRequests) { amRmClient.addContainerRequest(cr); amRmClient.releaseAssignedContainer(containerId); return amRmClient.allocate(0);
@Override protected void startUp() throws Exception { Preconditions.checkNotNull(trackerAddr, "Tracker address not set."); Preconditions.checkNotNull(trackerUrl, "Tracker URL not set."); amrmClient.start(); RegisterApplicationMasterResponse response = amrmClient.registerApplicationMaster(trackerAddr.getHostName(), trackerAddr.getPort(), trackerUrl.toString()); maxCapability = response.getMaximumResourceCapability(); nmClient.startAndWait(); }
/** * Unregister the application master. This must be called in the end. * @param appStatus Success/Failure status of the master * @param appMessage Diagnostics message on failure * @param appTrackingUrl New URL to get master info * @throws YarnException * @throws IOException */ public void unregisterApplicationMaster(FinalApplicationStatus appStatus, String appMessage, String appTrackingUrl) throws YarnException, IOException { synchronized (unregisterHeartbeatLock) { keepRunning = false; client.unregisterApplicationMaster(appStatus, appMessage, appTrackingUrl); } }
RegisterApplicationMasterResponse response = amRmClient.registerApplicationMaster(appMasterHostname, 0, appMasterTrackingUrl); amRmClient.updateBlacklist(null, blacklistRemovals); LOG.info("Removing nodes {} from blacklist: time elapsed since last blacklisting due to failure is greater than specified timeout", blacklistRemovals.toString()); failedBlackListedNodes.removeAll(blacklistRemovals); amRmClient.updateBlacklist(blacklistAdditions, null); long timeStamp = System.currentTimeMillis(); for (String hostname : blacklistAdditions) {
public Hadoop21YarnAMClient(Configuration conf) { super(ApplicationConstants.Environment.CONTAINER_ID.name()); this.amrmClient = AMRMClient.createAMRMClient(); this.amrmClient.init(conf); this.nmClient = new Hadoop21YarnNMClient(conf); }
/** * Release containers assigned by the Resource Manager. If the app cannot use * the container or wants to give up the container then it can release them. * The app needs to make new requests for the released resource capability if * it still needs it. eg. it released non-local resources * @param containerId */ public void releaseAssignedContainer(ContainerId containerId) { client.releaseAssignedContainer(containerId); }
/** * Remove previous container request. The previous container request may have * already been sent to the ResourceManager. So even after the remove request * the app must be prepared to receive an allocation for the previous request * even after the remove request * @param req Resource request */ public void removeContainerRequest(T req) { client.removeContainerRequest(req); }
/** * Registers this application master with the resource manager. On successful * registration, starts the heartbeating thread. * @throws YarnException * @throws IOException */ public RegisterApplicationMasterResponse registerApplicationMaster( String appHostName, int appHostPort, String appTrackingUrl) throws YarnException, IOException { RegisterApplicationMasterResponse response = client .registerApplicationMaster(appHostName, appHostPort, appTrackingUrl); heartbeatThread.start(); return response; }
/** * Tells the heartbeat and handler threads to stop and waits for them to * terminate. */ @Override protected void serviceStop() throws Exception { keepRunning = false; heartbeatThread.interrupt(); try { heartbeatThread.join(); } catch (InterruptedException ex) { LOG.error("Error joining with heartbeat thread", ex); } client.stop(); handlerThread.interrupt(); super.serviceStop(); }
@Override protected void serviceStart() throws Exception { handlerThread.setDaemon(true); handlerThread.start(); client.start(); super.serviceStart(); }
@Override protected void serviceInit(Configuration conf) throws Exception { super.serviceInit(conf); client.init(conf); }
public AMRMClientAsync<?> createAMRMClientAsync(int intervalMs, AMRMCallBackHandler callBackHandler) { AMRMClient<?> amRmClient = AMRMClient.createAMRMClient(); AMRMClientAsync<?> amRmClientAsync = AMRMClientAsync.createAMRMClientAsync(amRmClient, intervalMs, callBackHandler); return amRmClientAsync; } }
int heartbeatInterval = getConf().getInt(HEARTBEAT_INTERVAL_KEY, HEARTBEAT_INTERNAL_DEFAULT); AMRMClient<LlamaContainerRequest> amRmClient = AMRMClient.createAMRMClient(); amRmClient.setNMTokenCache(nmTokenCache); amRmClientAsync = AMRMClientAsync.createAMRMClientAsync(amRmClient, heartbeatInterval, YarnRMConnector.this);
@Override protected void startUp() throws Exception { Preconditions.checkNotNull(trackerAddr, "Tracker address not set."); Preconditions.checkNotNull(trackerUrl, "Tracker URL not set."); amrmClient.start(); RegisterApplicationMasterResponse response = amrmClient.registerApplicationMaster(trackerAddr.getHostName(), trackerAddr.getPort(), trackerUrl.toString()); maxCapability = response.getMaximumResourceCapability(); nmClient.startAndWait(); }
/** * Unregister the application master. This must be called in the end. * @param appStatus Success/Failure status of the master * @param appMessage Diagnostics message on failure * @param appTrackingUrl New URL to get master info * @throws YarnException * @throws IOException */ public void unregisterApplicationMaster(FinalApplicationStatus appStatus, String appMessage, String appTrackingUrl) throws YarnException, IOException { synchronized (unregisterHeartbeatLock) { keepRunning = false; client.unregisterApplicationMaster(appStatus, appMessage, appTrackingUrl); } }
public Hadoop21YarnAMClient(Configuration conf) { super(ApplicationConstants.Environment.CONTAINER_ID.name()); this.amrmClient = AMRMClient.createAMRMClient(); this.amrmClient.init(conf); this.nmClient = new Hadoop21YarnNMClient(conf); }