List of usage examples for org.apache.hadoop.yarn.client ClientRMProxy createRMProxy
public static <T> T createRMProxy(final Configuration configuration, final Class<T> protocol) throws IOException
From source file:disAMS.AMRMClient.Impl.AMRMClientImpl.java
License:Apache License
@Override protected void serviceStart() throws Exception { final YarnConfiguration conf = new YarnConfiguration(getConfig()); try {/*w w w . j ava 2s . c o m*/ rmClient = ClientRMProxy.createRMProxy(conf, ApplicationMasterProtocol.class); } catch (IOException e) { throw new YarnRuntimeException(e); } super.serviceStart(); }
From source file:org.apache.hive.service.server.KillQueryImpl.java
License:Apache License
public static Set<ApplicationId> getChildYarnJobs(Configuration conf, String tag) throws IOException, YarnException { Set<ApplicationId> childYarnJobs = new HashSet<ApplicationId>(); GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(ApplicationsRequestScope.OWN); gar.setApplicationTags(Collections.singleton(tag)); ApplicationClientProtocol proxy = ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class); GetApplicationsResponse apps = proxy.getApplications(gar); List<ApplicationReport> appsList = apps.getApplicationList(); for (ApplicationReport appReport : appsList) { if (isAdmin() || appReport.getApplicationTags() .contains(QueryState.USERID_TAG + "=" + SessionState.get().getUserName())) { childYarnJobs.add(appReport.getApplicationId()); }//w w w . j a v a 2s. c om } if (childYarnJobs.isEmpty()) { LOG.info("No child applications found"); } else { LOG.info("Found child YARN applications: " + StringUtils.join(childYarnJobs, ",")); } return childYarnJobs; }
From source file:org.apache.oozie.action.hadoop.LauncherMainHadoopUtils.java
License:Apache License
private static Set<ApplicationId> getChildYarnJobs(Configuration actionConf) { System.out.println("Fetching child yarn jobs"); Set<ApplicationId> childYarnJobs = new HashSet<ApplicationId>(); String tag = actionConf.get(CHILD_MAPREDUCE_JOB_TAGS); if (tag == null) { System.out.print("Could not find Yarn tags property " + CHILD_MAPREDUCE_JOB_TAGS); return childYarnJobs; }//w w w.j ava 2s . com System.out.println("tag id : " + tag); long startTime = 0L; try { startTime = Long.parseLong((System.getProperty(OOZIE_JOB_LAUNCH_TIME))); } catch (NumberFormatException nfe) { throw new RuntimeException("Could not find Oozie job launch time", nfe); } GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(ApplicationsRequestScope.OWN); gar.setApplicationTags(Collections.singleton(tag)); long endTime = System.currentTimeMillis(); if (startTime > endTime) { System.out.println( "WARNING: Clock skew between the Oozie server host and this host detected. Please fix this. " + "Attempting to work around..."); // We don't know which one is wrong (relative to the RM), so to be safe, let's assume they're both wrong and add an // offset in both directions long diff = 2 * (startTime - endTime); startTime = startTime - diff; endTime = endTime + diff; } gar.setStartRange(startTime, endTime); try { ApplicationClientProtocol proxy = ClientRMProxy.createRMProxy(actionConf, ApplicationClientProtocol.class); GetApplicationsResponse apps = proxy.getApplications(gar); List<ApplicationReport> appsList = apps.getApplicationList(); for (ApplicationReport appReport : appsList) { childYarnJobs.add(appReport.getApplicationId()); } } catch (IOException ioe) { throw new RuntimeException("Exception occurred while finding child jobs", ioe); } catch (YarnException ye) { throw new RuntimeException("Exception occurred while finding child jobs", ye); } System.out.println("Child yarn jobs are found - " + StringUtils.join(childYarnJobs, ",")); return childYarnJobs; }
From source file:org.apache.tez.dag.app.rm.UtilizationTable.java
License:Apache License
/** * A function that creates the protocol proxy to communicate with Unicorn * * @return The created protocol proxy//ww w .ja v a 2 s .co m */ protected UtilizationProtocol createUtilizationProtocolProxy(Configuration conf) throws YarnRuntimeException { try { return ClientRMProxy.createRMProxy(conf, UtilizationProtocol.class); } catch (IOException e) { throw new YarnRuntimeException(e); } }