Hadoop Web项目使用Ajax监控Mapreduce过程

2019-03-28 12:59|来源: 网络

Hadoop Web项目的改进版,新增Ajax技术。Ajax主要是在浏览器中输入hdfs路径时的后台检查和在监控任务执行状态时使用Ajax去和后台交互,获取job信息。

项目代码下载

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2013年资料/6月/17日/Hadoop Web项目使用Ajax监控Mapreduce过程

整个项目的思路大概如下:

获取job信息的jsp如下:

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ page import ="util.*" %>

<%@ page import ="org.apache.hadoop.conf.*" %>

<html>

    <script language='javascript'>
      timeId = setInterval("myrefresh()",2000);
      var xmlHttpShow;
   function createXMLHttpInRequest(){
    if(window.XMLHttpRequest){
     xmlHttpShow=new XMLHttpRequest();
    }else{
     xmlHttpShow=new ActiveXObject("Microsoft.XMLHTTP");
    }
   }
   
   
      function myrefresh(){
  //     alert("ok");
    if(document.getElementById("redProgress").innerText.indexOf("100.0%")==0){
     clearInterval(timeId);
    }
       createXMLHttpInRequest();
  var url="validate/get_progress.jsp?time="+new Date().getTime();
  xmlHttpShow.open("get",url,true);
   
  // 把方法地址赋值给xmlHttp的onreadystatechange属性
  xmlHttpShow.onreadystatechange=showcallback;
   
  xmlHttpShow.send(null);
      }
     
      function showcallback(){
       var progress=xmlHttpShow.responseText;
       var a=progress.indexOf(",");
       var length=progress.length;
       document.getElementById("mapProgress").innerText=progress.substring(0,a);
       
       document.getElementById("redProgress").innerText=progress.substring(a+1,length);
      }
     
      </script>
  <head>
 
    <title>My JSP 'bottom_print.jsp' starting page</title>
 

  </head>

  <%
  String jobName=request.getParameter("jobName");
  %>
 
 
 
  <body>
    <h3>Map Reduce Progress</h3> <br>
   
    <table border="1">
    <tr>
      <th>Job Name</th>
      <td><%=jobName %></td>
     </tr>
     <tr>
      <th>Map Progress</th>
      <td id="mapProgress">0.00%</td>
     </tr>
     <tr>
      <th>Reduce Progress</th>
      <td id="redProgress">0.00%</td>
     </tr>
    </table>
   
  </body>
</html>

说明:目前可选的算法只有单词计数可用,其他算法可以在后续进行添加即可;

配置Hadoop集群的文件在:src/util/Utils.java文件里面;

分享,快乐,成长

出处:http://blog.csdn.net/fansy1990

更多Hadoop相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13

相关问答

更多
  • 它们被分离出来,因为这两个包都代表2个不同的API。 org.apache.hadoop.mapred是旧的API, org.apache.hadoop.mapreduce是新的。 这样做是为了让程序员以更方便,更简单和复杂的方式编写MapReduce作业。 您可能会发现此演示文稿很有用,其中详细讨论了不同之处。 希望这回答你的问题。 They are separated out because both of these packages represent 2 different APIs. org.a ...
  • 本教程提到: 下载Hadoop-core-1.2.1.jar,用于编译和执行MapReduce程序。 访问以下链接http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-core/1.2.1下载jar。 所以在这里你可以找到不同版本的所有罐子 This tutorial mentions : Download Hadoop-core-1.2.1.jar, which is used to compile and execute the MapRe ...
  • 它是实现正确的接口还是为reducer实现扩展正确的类。 例外情况表明实现方法中的包差异与使用相比(新旧vso hadoop api) Is it implementing the correct interface or extending the correct class for the reducer implementation. The exception says a package difference in the implementation method required vs the ...
  • 做了一个全新安装的hadoop并用同一个罐子运行工作,问题就消失了。 似乎是一个错误,而不是编程错误。 Did a fresh installation of hadoop and ran the job with the same jar, the problem disappeared. Seems to be a bug rather than programming errors.
  • 您应该添加/usr/lib/hadoop-0.xx/lib找到的所有jar以避免这种类路径问题。 为了给你一个想法,你可以输入hadoop classpath ,它将打印出获取Hadoop jar和所需库所需的类路径。 在你的情况下,你错过了hadoop-common-0.xx.jar ,所以你应该把它添加到classpath中,你应该很好。 You should add all the jars found in /usr/lib/hadoop-0.xx/lib to avoid this kind of ...
  • 这可能发生在作业仅检测到本地文件系统的情况下,它使用LocalFileSystem API与本地文件系统中的文件进行交互。 请参考以下链接, 使用MiniDFSCluster单元测试hadoop hdfs着作 这是我们在开发环境中开发的mapreduce / hdfs代码的单元测试选项之一。虽然在hadoop clsuter中部署相同的代码,但输入文件将在HDFS位置。 This probably happens in the scenario where the job only detects the ...
  • 假设zipIn是java.util.zip.ZipInputStream ,你不应该迭代地调用getNextEntry而不是读取字节吗? I resolved this issue after doing some changes in my code. In the first part of code, I was trying to unzip all the zip files whereas I should have access the spilts. Hadoop basic, which ...
  • Web控制台运行在40013, 这里提到。 The web console runs at 40013, mentioned here.
  • Mapper接口按以下顺序需要4个类型参数:Map输入键,Map输入值,Map输出键和Map输出值。 在您的情况下,由于您正在处理4个整数,其中3个构成您的值,1个是您的密钥,因此使用IntWritable作为Map输入键并且应该使用Text而错误。 此外,您在MapClass定义中指定的类型与传递给Map函数的类型不匹配。 鉴于您正在处理文本文件,您的MapClass应定义如下: public static class MapClass extends MapReduceBase implements M ...
  • 我按原样使用了您的代码,并在进行了3次修改后进行了编译: 在以下语句中,将filename更改为fileName ( fileName 'N'大写) 更改: word.set(itr.nextToken().toLowerCase().replaceAll("[^a-z]+","") +" "+ filename); 至: word.set(itr.nextToken().toLowerCase().replaceAll("[^a-z]+","") +" "+ fileName); 导入的包Gene ...