static JobQueueInfo newJobQueueInfo(List<JobQueueInfo> children, Properties props, String queueName, QueueState state, String schedulingInfo) { JobQueueInfo jqi = new JobQueueInfo(); jqi.setChildren(children); if (props != null) { jqi.setProperties(props); } jqi.setQueueName(queueName); jqi.setQueueState(state.getStateName()); jqi.setSchedulingInfo(schedulingInfo); return jqi; } }
assertEquals(firstSubQueue.getJobQueueInfo().getQueueName(), "first"); assertEquals(firstSubQueue.getJobQueueInfo().getQueueState(), "running"); assertEquals(firstSubQueue.getJobQueueInfo().getSchedulingInfo(), "queueInfo"); assertEquals(secondSubQueue.getJobQueueInfo().getChildren().size(), 0); queueJobQueueInfos.add(jobInfo.getQueueName()); rootJobQueueInfos.add(queue.getJobQueueInfo().getQueueName()); manager.getJobQueueInfoMapping().get("first").getQueueName(), "first");
private void updateSchedulerProps(JobQueueInfo jqi) { LOG.info("Updating properties for SchedulerQueue " + jqi.getQueueName()); LOG.info("Putting " + jqi.getProperties() + " in " + jqi.getQueueName()); schedulerPropsMap.put(jqi.getQueueName(), jqi.getProperties()); for (JobQueueInfo child : jqi.getChildren()) { updateSchedulerProps(child); } }
/** * Test that print job queue recursively prints child queues */ @Test @SuppressWarnings("deprecation") public void testPrintJobQueueInfo() throws IOException { JobQueueClient queueClient = new JobQueueClient(); JobQueueInfo parent = new JobQueueInfo(); JobQueueInfo child = new JobQueueInfo(); JobQueueInfo grandChild = new JobQueueInfo(); child.addChild(grandChild); parent.addChild(child); grandChild.setQueueName("GrandChildQueue"); ByteArrayOutputStream bbos = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter(bbos); queueClient.printJobQueueInfo(parent, writer); Assert.assertTrue("printJobQueueInfo did not print grandchild's name", bbos.toString().contains("GrandChildQueue")); }
/** * Remove the child from this {@link JobQueueInfo}. This also resets the * queue-name of the child from a fully-qualified name to a simple queue name. * * Only for testing. * * @param child */ void removeChild(JobQueueInfo child) { List<JobQueueInfo> children = getChildren(); children.remove(child); setChildren(children); }
qName.setTextContent(getSimpleQueueName(jqi.getQueueName())); q.appendChild(qName); Properties props = jqi.getProperties(); Element propsElement = document.createElement(PROPERTIES_TAG); if (props != null) { String queueState = jqi.getState().getStateName(); if (queueState != null && !queueState.equals(QueueState.UNDEFINED.getStateName())) { List<JobQueueInfo> children = jqi.getChildren(); if (children != null) { for (JobQueueInfo child : children) {
JobQueueInfo(QueueInfo queue) { this(queue.getQueueName(), queue.getSchedulingInfo()); setQueueState(queue.getState().getStateName()); setQueueChildren(queue.getQueueChildren()); setProperties(queue.getProperties()); setJobStatuses(queue.getJobStatuses()); }
qName.setTextContent(getSimpleQueueName(jqi.getQueueName())); q.appendChild(qName); Properties props = jqi.getProperties(); Element propsElement = document.createElement(PROPERTIES_TAG); if (props != null) { String queueState = jqi.getQueueState(); if (queueState != null && !queueState.equals(QueueState.UNDEFINED.getStateName())) { List<JobQueueInfo> children = jqi.getChildren(); if (children != null) { for (JobQueueInfo child : children) {
assertNotNull(queueInfos); assertEquals(1, queueInfos.length); assertEquals("default", queueInfos[0].getQueueName()); assertEquals(QueueState.RUNNING.getStateName(), queueInfos[0].getQueueState()); JobConf conf = mrCluster.createJobConf(); FileSystem fileSys = dfsCluster.getFileSystem(); .getQueueName()); assertNotNull(queueInfo.getQueueName()); assertNotNull(queueInfo.getSchedulingInfo()); assertEquals(expectedQueueInfo, queueInfo.getSchedulingInfo()); numberOfJobs += jobStatusList.length; for (JobStatus status : jobStatusList) {
/** * Method used to display the list of the JobQueues registered * with the {@link QueueManager} * * @throws IOException */ private void displayQueueList() throws IOException { JobQueueInfo[] queues = jc.getQueues(); for (JobQueueInfo queue : queues) { String schedInfo = queue.getSchedulingInfo(); if(schedInfo.trim().equals("")){ schedInfo = "N/A"; } System.out.printf("Queue Name : %s \n", queue.getQueueName()); System.out.printf("Scheduling Info : %s \n",queue.getSchedulingInfo()); } }
private static String getTree(String parent, List<JobQueueInfo> children) { StringBuilder str = new StringBuilder(); if (children == null) { return ""; } for (JobQueueInfo queueInfo : children) { String variableName = StringUtils.replaceChars(queueInfo.getQueueName(), ":-*+#.^", "_______"); String label = queueInfo.getQueueName().split(":")[queueInfo .getQueueName().split(":").length - 1]; str.append(String.format( "var %sTreeNode = new YAHOO.widget.MenuNode(\"%s\", %s, false);\n", variableName, label, parent)); str.append(String.format("%sTreeNode.data=\"%s\";\n", variableName, queueInfo.getSchedulingInfo().replaceAll("\n", "<br/>"))); str.append(String.format("%sTreeNode.name=\"%s\";\n", variableName, queueInfo.getQueueName())); str.append(getTree(variableName + "TreeNode", queueInfo.getChildren())); } return str.toString(); }
@Test public void testQueueInfoPrinting() throws Exception { // create a test queue with children. // create some sample queues in a hierarchy.. JobQueueInfo root = new JobQueueInfo("q1", "q1 scheduling info"); List<JobQueueInfo> children = new ArrayList<JobQueueInfo>(); children.add(new JobQueueInfo("q1:1", null)); children.add(new JobQueueInfo("q1:2", null)); root.setChildren(children); JobQueueClient client = new JobQueueClient(new JobConf()); StringWriter writer = new StringWriter(); client.printJobQueueInfo(root, writer); StringBuffer sb = new StringBuffer(); sb.append("Queue Name : q1 \n"); sb.append("Queue State : running \n"); sb.append("Scheduling Info : q1 scheduling info \n"); sb.append("Child Queues : q1:1, q1:2\n"); sb.append("======================\n"); assertEquals(sb.toString(), writer.toString()); }
private JobQueueInfo[] getJobQueueInfoArray(QueueInfo[] queues) throws IOException { JobQueueInfo[] ret = new JobQueueInfo[queues.length]; for (int i = 0; i < queues.length; i++) { ret[i] = new JobQueueInfo(queues[i]); } return ret; }
@Test public void testQueueOrdering() throws Exception { // create some sample queues in a hierarchy.. JobQueueInfo[] roots = new JobQueueInfo[2]; roots[0] = new JobQueueInfo("q1", "q1 scheduling info"); roots[1] = new JobQueueInfo("q2", "q2 scheduling info"); List<JobQueueInfo> children = new ArrayList<JobQueueInfo>(); children.add(new JobQueueInfo("q1:1", null)); children.add(new JobQueueInfo("q1:2", null)); roots[0].setChildren(children); // test dfs ordering JobQueueClient client = new JobQueueClient(new JobConf()); List<JobQueueInfo> allQueues = client.expandQueueList(roots); assertEquals(4, allQueues.size()); assertEquals("q1", allQueues.get(0).getQueueName()); assertEquals("q1:1", allQueues.get(1).getQueueName()); assertEquals("q1:2", allQueues.get(2).getQueueName()); assertEquals("q2", allQueues.get(3).getQueueName()); }
/** * Expands the hierarchy of queues and gives the list of all queues in * depth-first order * @param rootQueues the top-level queues * @return the list of all the queues in depth-first order. */ List<JobQueueInfo> expandQueueList(JobQueueInfo[] rootQueues) { List<JobQueueInfo> allQueues = new ArrayList<JobQueueInfo>(); for (JobQueueInfo queue : rootQueues) { allQueues.add(queue); if (queue.getChildren() != null) { JobQueueInfo[] childQueues = queue.getChildren().toArray(new JobQueueInfo[0]); allQueues.addAll(expandQueueList(childQueues)); } } return allQueues; }
private QueueInfo[] getQueueInfoArray(JobQueueInfo[] queues) throws IOException { for (JobQueueInfo queue : queues) { queue.setJobStatuses(getJobsFromQueue(queue.getQueueName())); for(JobQueueInfo childqueue : queue.getChildren()){ childqueue.setJobStatuses(getJobsFromQueue(childqueue.getQueueName())); } } return queues; }
/** * Method used to display information pertaining to a Single JobQueue * registered with the {@link QueueManager}. Display of the Jobs is determine * by the boolean * * @throws IOException, InterruptedException */ private void displayQueueInfo(String queue, boolean showJobs) throws IOException, InterruptedException { JobQueueInfo jobQueueInfo = jc.getQueueInfo(queue); if (jobQueueInfo == null) { System.out.println("Queue \"" + queue + "\" does not exist."); return; } printJobQueueInfo(jobQueueInfo, new PrintWriter(new OutputStreamWriter( System.out, Charsets.UTF_8))); if (showJobs && (jobQueueInfo.getChildren() == null || jobQueueInfo.getChildren().size() == 0)) { JobStatus[] jobs = jobQueueInfo.getJobStatuses(); if (jobs == null) jobs = new JobStatus[0]; jc.displayJobList(jobs); } }
assertEquals(rootQueueInfo[0].getQueueName(), "default"); JobQueueInfo[] qinfo = client.getQueues(); assertEquals(qinfo.length, 1); assertEquals(qinfo[0].getQueueName(), "default"); assertEquals(client.getChildQueues("default").length, 0); assertEquals(client.getJobsFromQueue("default").length, 1); assertEquals(qi.getQueueName(), "default"); assertEquals(qi.getQueueState(), "running");
@Test public void testMissingConfigFile() throws Exception { deleteQueuesConfigFile(); // deletes file try { new QueueManager(QUEUES_CONFIG_FILE_PATH, true); fail("Should throw an exception for missing file when " + "explicitly passed."); } catch (RuntimeException re) { } // If we just want to pick up the queues from the class loader // it should fall through to the default. The class loader is set to // load CONFIG for the "mapred-queues.xml" resource, but it's missing // so should fall through to mapred-queues-default.xml QueueManager qm = new QueueManager(); List<JobQueueInfo> rootQueues = qm.getRoot().getJobQueueInfo().getChildren(); assertEquals(1, rootQueues.size()); assertEquals("default", rootQueues.get(0).getQueueName()); }
@Override public synchronized void start() throws IOException { super.start(); QueueManager queueManager = taskTrackerManager.getQueueManager(); String queueName = queueManager.getJobQueueInfos()[0].getQueueName(); queueManager.setSchedulerInfo(queueName ,"Maximum Tasks Per Job :: " + String.valueOf(maxTasksPerJob)); }