List of usage examples for org.apache.hadoop.mapred JobClient getQueues
public JobQueueInfo[] getQueues() throws IOException
From source file:com.cloudera.lib.service.hadoop.TestHadoopService.java
License:Open Source License
@Test @TestDir//w ww . ja v a2 s . c om @TestHadoop public void jobClientExecutor() throws Exception { String dir = getTestDir().getAbsolutePath(); String services = StringUtils.toString( Arrays.asList(InstrumentationService.class.getName(), HadoopService.class.getName()), ","); XConfiguration conf = new XConfiguration(); conf.set("server.services", services); Server server = new Server("server", dir, dir, dir, dir, conf); server.init(); Hadoop hadoop = server.get(Hadoop.class); final JobClient jca[] = new JobClient[1]; final FileSystem fsa[] = new FileSystem[1]; hadoop.execute("u", getHadoopConf(), new Hadoop.JobClientExecutor<Void>() { @Override public Void execute(JobClient jc, FileSystem fs) throws IOException { fs.mkdirs(new Path("/tmp/foo")); jc.getQueues(); jca[0] = jc; fsa[0] = fs; return null; } }); // NOT testing JobClient as the closed one still connects to the JobTracker successfully // try { // jca[0].submitJob(jobConf); // Assert.fail(); // } // catch (IOException ex) { // } // catch (Exception ex) { // Assert.fail(); // } try { fsa[0].mkdirs(new Path("/tmp/foo")); Assert.fail(); } catch (IOException ex) { } catch (Exception ex) { Assert.fail(); } server.destroy(); }
From source file:org.openflamingo.engine.monitoring.hadoop.JobTrackerMonitor.java
License:Apache License
public void printJobs() throws IOException { JobConf conf = new JobConf(); conf.set("mapred.job,tracker", "localhost:9001"); JobClient jobClient = new JobClient(conf); JobStatus[] allJobs = jobClient.getAllJobs(); if (allJobs != null) { for (JobStatus status : allJobs) { System.out.println(status.getJobID()); System.out.println(status.getSchedulingInfo()); }/* ww w .j a v a 2s . c om*/ } System.out.println(jobClient.getClusterStatus().getMapTasks()); JobQueueInfo[] queues = jobClient.getQueues(); if (queues != null) for (JobQueueInfo queue : queues) { System.out.println(queue.getQueueName()); System.out.println(queue.getSchedulingInfo()); System.out.println(queue.getQueueState()); } JobStatus[] jobStatuses = jobClient.jobsToComplete(); if (jobStatuses != null) for (JobStatus jobStatus : jobStatuses) { System.out.println(jobStatus.getJobID().getId()); System.out.println(jobStatus.getSchedulingInfo()); } }