Java Code Examples for org.apache.hadoop.util.StringUtils#simpleHostname()
The following examples show how to use
org.apache.hadoop.util.StringUtils#simpleHostname() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FairSchedulerAdmissionControlServlet.java From RDFS with Apache License 2.0 | 4 votes |
public void doActualGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Check for user set or pool set filters Set<String> userFilterSet = null; String userFilter = request.getParameter("users"); if (userFilter != null) { userFilterSet = new HashSet<String>(Arrays.asList(userFilter.split(","))); } Set<String> poolFilterSet = null; String poolFilter = request.getParameter("pools"); if (poolFilter != null) { poolFilterSet = new HashSet<String>(Arrays.asList(poolFilter.split(","))); } // Print out the normal response response.setContentType("text/html"); // Because the client may read arbitrarily slow, and we hold locks while // the servlet output, we want to write to our own buffer which we know // won't block. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(baos); String hostname = StringUtils.simpleHostname( jobTracker.getJobTrackerMachine()); out.print("<html><head>"); out.printf("<title>%s Job Scheduler Admininstration</title>\n", hostname); out.print("<link rel=\"stylesheet\" type=\"text/css\" " + "href=\"/static/hadoop.css\">\n"); out.print("<link rel=\"stylesheet\" type=\"text/css\" " + "href=\"/static/tablesorter/style.css\">\n"); out.print("<script type=\"text/javascript\" " + "src=\"/static/jquery-1.7.1.min.js\"></script>"); out.print("<script type=\"text/javascript\" " + "src=\"/static/tablesorter/jquery.tablesorter.js\"></script>"); out.print("<script type=\"text/javascript\" " + "src=\"/static/tablesorter/jobtablesorter.js\"></script>"); out.print("<script type=\"text/javascript\" " + "src=\"/static/dynamic-selector.js\"></script>\n"); out.print("<script type=\"text/javascript\" " + "src=\"/static/tablefilter.js\"></script>\n"); out.print("<script type=\"text/javascript\">"); out.print("function init() {\n"); out.print(" var table=document.getElementById('NotAdmittedJobsTable');\n"); out.print(" var startRow = 1; // Rows 0 is a header row\n"); out.print(" var filteredColumns = [" + "new ColumnSearchToggle(0, 'SubmittedTimeFilterToggle')," + "new ColumnSearchToggle(1, 'JobIDFilterToggle')," + "new ColumnSearchToggle(2, 'UserFilterToggle')," + "new ColumnSearchToggle(4, 'PoolFilterToggle')," + "new ColumnSearchToggle(5, 'PrioFilterToggle')];\n\n"); out.print("addTable(table, startRow, filteredColumns);\n"); out.print("}\nwindow.onload=init;</script>\n"); out.print("<style type=\"text/css\">" + ".fake-link {color: blue; " + "text-decoration: underline; " + "cursor: pointer;}</style>\n"); out.print("</head><body>\n"); out.printf("<h1><a href=\"/jobtracker.jsp\">%s</a> " + "Job Scheduler Administration</h1>\n", hostname); AdmissionControlData admissionControlData = scheduler.getJobInitializer().getAdmissionControlData(); out.printf("<b>Cluster-Wide Soft Task Limit :</b> %d<br>", admissionControlData.getSoftTaskLimit()); out.printf("<b>Cluster-Wide Hard Task Limit :</b> %d<br>", admissionControlData.getHardTaskLimit()); out.printf("<b>Cluster-Wide Total Tasks:</b> %d<br>", admissionControlData.getTotalTasks()); if (admissionControlData.getHardTaskLimit() < admissionControlData.getTotalTasks()) { out.print("<b style=\"color:#FF0000\">" + "Cluster is now in hard admission control. All new jobs will " + "have to wait until tasks clear before admission.</b><br>"); } else if (admissionControlData.getSoftTaskLimit() < admissionControlData.getTotalTasks()) { out.print("<b style=\"color:#FF6600\">" + "Cluster is now in soft admission control. Only jobs submitted to " + "SLA pools that also meet the SLA pool limits will be " + "admitted.</b><br>"); } FairSchedulerServlet.printFilterInfo( out, poolFilter, userFilter, "fairscheduleradmissioncontrol"); FairSchedulerServlet.showCluster(out, false, jobTracker); showJobsNotAdmitted(out, userFilterSet, poolFilterSet); out.print("</body></html>\n"); out.close(); // Flush our buffer to the real servlet output OutputStream servletOut = response.getOutputStream(); baos.writeTo(servletOut); servletOut.close(); }
Example 2
Source File: jobqueue_005fdetails_jsp.java From hadoop-gpu with Apache License 2.0 | 4 votes |
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write('\n'); out.write('\n'); JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); String trackerName = StringUtils.simpleHostname(tracker.getJobTrackerMachine()); String queueName = StringUtils.escapeHTML(request.getParameter("queueName")); TaskScheduler scheduler = tracker.getTaskScheduler(); Collection<JobInProgress> jobs = scheduler.getJobs(queueName); JobQueueInfo schedInfo = tracker.getQueueInfo(queueName); out.write("\n<html>\n<head>\n<title>Queue details for "); out.print(queueName!=null?queueName:""); out.write(" </title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hadoop.css\">\n<script type=\"text/javascript\" src=\"/static/jobtracker.js\"></script>\n</head>\n<body>\n"); JSPUtil.processButtons(request, response, tracker); out.write('\n'); String schedulingInfoString = schedInfo.getSchedulingInfo(); out.write("\n<h1>Hadoop Job Queue Scheduling Information on \n <a href=\"jobtracker.jsp\">"); out.print(trackerName); out.write("</a>\n</h1>\n<div>\nScheduling Information : "); out.print( schedulingInfoString.replaceAll("\n","<br/>") ); out.write("\n</div>\n<hr/>\n"); if(jobs == null || jobs.isEmpty()) { out.write("\n<center>\n<h2> No Jobs found for the Queue :: "); out.print(queueName!=null?queueName:""); out.write(" </h2>\n<hr/>\n</center>\n"); }else { out.write("\n<center>\n<h2> Job Summary for the Queue :: "); out.print(queueName!=null?queueName:"" ); out.write(" </h2>\n</center>\n<div style=\"text-align: center;text-indent: center;font-style: italic;\">\n(In the order maintained by the scheduler)\n</div>\n<br/>\n<hr/>\n"); out.print( JSPUtil.generateJobTable("Job List", jobs, 30, 0) ); out.write("\n<hr>\n"); } out.write('\n'); out.write('\n'); out.println(ServletUtil.htmlFooter()); out.write('\n'); out.write('\n'); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }