hadoop web项目使用ajax监控mapreduce过程

项目代码可以在http://download.csdn.net/detail/fansy1990/5590951 下载;

Hadoop集群版本:1.0.4 ,结合myeclipse开发;

此次的hadoop web项目是前次的改进版,增加了ajax技术,主要用在了路径的检查(字符串检查和hdfs交互)以及在监控mapreduce过程时和后台交互获得job信息;

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


获取job信息的jsp如下:

[html]  view plain copy
  1. <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>  
  2. <%@ page import ="util.*" %>  
  3.   
  4. <%@ page import ="org.apache.hadoop.conf.*" %>  
  5.   
  6. <html>  
  7.   
  8.     <script language='javascript'>  
  9.       timeId = setInterval("myrefresh()",2000);  
  10.       var xmlHttpShow;  
  11.         function createXMLHttpInRequest(){  
  12.             if(window.XMLHttpRequest){  
  13.                 xmlHttpShow=new XMLHttpRequest();  
  14.             }else{  
  15.                 xmlHttpShow=new ActiveXObject("Microsoft.XMLHTTP");  
  16.             }  
  17.         }  
  18.           
  19.           
  20.       function myrefresh(){  
  21.   //        alert("ok");  
  22.         if(document.getElementById("redProgress").innerText.indexOf("100.0%")==0){  
  23.             clearInterval(timeId);  
  24.         }  
  25.         createXMLHttpInRequest();  
  26.         var url="validate/get_progress.jsp?time="+new Date().getTime();  
  27.         xmlHttpShow.open("get",url,true);  
  28.                   
  29.         // 把方法地址赋值给xmlHttp的onreadystatechange属性  
  30.         xmlHttpShow.onreadystatechange=showcallback;  
  31.                   
  32.         xmlHttpShow.send(null);  
  33.       }  
  34.         
  35.       function showcallback(){  
  36.         var progress=xmlHttpShow.responseText;  
  37.         var a=progress.indexOf(",");  
  38.         var length=progress.length;  
  39.         document.getElementById("mapProgress").innerText=progress.substring(0,a);  
  40.           
  41.         document.getElementById("redProgress").innerText=progress.substring(a+1,length);  
  42.       }  
  43.         
  44.       </script>  
  45.   <head>  
  46.    
  47.     <title>My JSP 'bottom_print.jsp' starting page</title>  
  48.    
  49.   
  50.   </head>  
  51.   
  52.   <%  
  53.    String jobName=request.getParameter("jobName");  
  54.    %>  
  55.    
  56.     
  57.     
  58.   <body>  
  59.      <h3>Map Reduce Progress</h3> <br>  
  60.       
  61.     <table border="1">  
  62.          <tr>  
  63.             <th>Job Name</th>  
  64.             <td><%=jobName %></td>  
  65.         </tr>  
  66.         <tr>  
  67.             <th>Map Progress</th>  
  68.             <td id="mapProgress">0.00%</td>  
  69.         </tr>  
  70.         <tr>  
  71.             <th>Reduce Progress</th>  
  72.             <td id="redProgress">0.00%</td>  
  73.         </tr>  
  74.     </table>  
  75.       
  76.   </body>  
  77. </html>  


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

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


分享,快乐,成长


转载请注明出处:http://blog.csdn.net/fansy1990 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值