chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r773123 - in /hadoop/chukwa/trunk: ./ src/java/org/apache/hadoop/chukwa/hicc/ src/java/org/apache/hadoop/chukwa/util/ src/web/hicc/ src/web/hicc/descriptors/ src/web/hicc/js/workspace/ src/web/hicc/jsp/
Date Fri, 08 May 2009 22:16:14 GMT
Author: eyang
Date: Fri May  8 22:16:14 2009
New Revision: 773123

URL: http://svn.apache.org/viewvc?rev=773123&view=rev
Log:
CHUKWA-219. Improved usability of host selector, and updated caching for host list. (Eric
Yang)

Added:
    hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_dropdown.jsp
    hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_role.jsp
    hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_user.jsp
Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Iframe.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java
    hadoop/chukwa/trunk/src/web/hicc/descriptors/host_selector.descriptor
    hadoop/chukwa/trunk/src/web/hicc/index.jsp
    hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js
    hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector.jsp

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=773123&r1=773122&r2=773123&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Fri May  8 22:16:14 2009
@@ -117,6 +117,8 @@
 
   BUG FIXES
 
+    CHUKWA-103. Fix documentation broken link. (Eric Yang)
+
     CHUKWA-208. Skip copying of test/sample directory if it doesn't exist. (Eric Yang)
 
     CHUKWA-206. Removed hard coded path from configuration files, and sample data. (Eric
Yang)

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Iframe.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Iframe.java?rev=773123&r1=773122&r2=773123&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Iframe.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Iframe.java Fri May  8 22:16:14
2009
@@ -30,8 +30,8 @@
     PrintWriter out = response.getWriter();
     StringBuffer source = new StringBuffer();
     String requestURL = request.getRequestURL().toString().replaceFirst("iframe/", "");
-    if(requestURL.indexOf("/hicc")!=-1) {
-       requestURL = requestURL.substring(requestURL.indexOf("/hicc"));
+    if(requestURL.indexOf("/hicc/")!=-1) {
+       requestURL = requestURL.substring(requestURL.indexOf("/hicc/"));
     }
     source.append(requestURL);
     source.append("?");
@@ -39,11 +39,13 @@
     while (names.hasMoreElements()) {
       String key = xf.filter((String) names.nextElement());
       String[] values = xf.getParameterValues(key);
-      for (int i = 0; i < values.length; i++) {
-        source.append(key + "=" + values[i] + "&");
-      }
-      if (key.toLowerCase().intern() == "height".intern()) {
-        height = xf.getParameter(key);
+      if(values!=null) {
+        for (int i = 0; i < values.length; i++) {
+          source.append(key + "=" + values[i] + "&");
+        }
+        if (key.toLowerCase().intern() == "height".intern()) {
+          height = xf.getParameter(key);
+        }
       }
     }
     out.println("<html><body><iframe id=\"iframe" + this.id + "\" " + "src=\""

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java?rev=773123&r1=773122&r2=773123&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java Fri May  8 22:16:14
2009
@@ -1,7 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.hadoop.chukwa.util;
 
+import java.util.Enumeration;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
 import javax.servlet.http.HttpServletRequest;
-
+import javax.servlet.http.HttpSession;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -10,12 +31,24 @@
 public class XssFilter {
     private HttpServletRequest request = null;
     private static Log log = LogFactory.getLog(XssFilter.class);
-    
+    private HttpSession session = null;
+
     public XssFilter() {
     }
 
     public XssFilter(HttpServletRequest request) {
       this.request = request;
+      this.session = request.getSession();
+      for (Enumeration e = request.getParameterNames() ; e.hasMoreElements() ;) {
+        Pattern p = Pattern.compile("_session\\.(.*)");
+        String name = (String) e.nextElement();
+        Matcher matcher = p.matcher(name);
+        if(matcher.find()) {
+            String realName = matcher.group(1);
+            session.setAttribute(realName,filter(request.getParameter(name)));
+        }
+      }
+
     }
     
     public String getParameter(String key) {

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/host_selector.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/host_selector.descriptor?rev=773123&r1=773122&r2=773123&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/host_selector.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/host_selector.descriptor Fri May  8 22:16:14
2009
@@ -4,9 +4,12 @@
 "version":"0.1",
 "categories":"Global,Utility",
 "module":"jsp\/host_selector.jsp",
-"description":"Global control to manipulate hosts across widgets",
-"screendump":"",
+"description":"Global control to manipulate host selection across widgets",
 "refresh":"15",
 "parameters":[
-]
-}
+{"name":"style","type":"select","value":"role","label":"Selector Style","options":[
+{"label":"By node type","value":"role"},
+{"label":"By drop down list","value":"dropdown"},
+{"label":"By user input","value":"user"}
+]},
+]}

Modified: hadoop/chukwa/trunk/src/web/hicc/index.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/index.jsp?rev=773123&r1=773122&r2=773123&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/index.jsp (original)
+++ hadoop/chukwa/trunk/src/web/hicc/index.jsp Fri May  8 22:16:14 2009
@@ -120,6 +120,9 @@
   <li><select class="formSelect" id="currentpage" onChange="changeView(this);"></select></li>
 </ul>
 <ul>
+  <li><a href="#" onClick="javascript:manage_content(); return false;"><img
src="/hicc/images/table.png" border="0" align="absmiddle"> Dashboard Builder</a></li>
+</ul>
+<ul>
   <li><a href="#" onClick="return false;"><img src="/hicc/images/application.png"
border="0" align="absmiddle"> Options</a>
     <ul>
       <table>
@@ -133,9 +136,6 @@
   </li>
 </ul>
 <ul>
-  <li><a href="#" onClick="javascript:manage_content(); return false;"><img
src="/hicc/images/table.png" border="0" align="absmiddle"> Workspace Builder</a></li>
-</ul>
-<ul>
   <li><a href="#" onClick="saveView(); return false;"><img src="/hicc/images/drive.png"
border="0" align="absmiddle"> Save Dashboard</a></li>
 </ul>
 </div>
@@ -149,12 +149,12 @@
 <div id="manage_view" style="display:none;overflow:hidden;width:100%;">
 <table cellspacing="10" cellpadding="0" width="100%" class="ppsmenu">
 <tr><td>
-<table width="100%" class="titlebar"><tr><td>Workspace</td><td
align="right"><span class="glossy_icon"><a href="#" onClick="manage_content('close');"><img
src="images/close.png" align="absmiddle"></a></span></td></tr></table>
+<table width="100%" class="titlebar"><tr><td>Dashboard</td><td
align="right"><span class="glossy_icon"><a href="#" onClick="manage_content('close');"><img
src="images/close.png" align="absmiddle"></a></span></td></tr></table>
 <div id="views_list_div">
 </div>
 </td></tr>
 <tr><td colspan="2">
-<input class="formButton" type="button" name="new_workspace" value="Create New Workspace"
onClick="createNewView();"/>
+<input class="formButton" type="button" name="new_workspace" value="Create New Dashboard"
onClick="createNewView();"/>
 </td></tr>
 </table>
 </div>

Modified: hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js?rev=773123&r1=773122&r2=773123&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js (original)
+++ hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js Fri May  8 22:16:14 2009
@@ -3246,7 +3246,7 @@
         "/hicc/jsp/session.jsp",
         {
             asynchronous: false,
-            method: 'get',
+            method: 'post',
             parameters: "hosts="+cookie
         }
     );
@@ -3256,6 +3256,49 @@
 
 }
 
+function save_host_user(boxId) {
+    var obj = document.getElementById(boxId+"group_items").value;
+    var hosts = obj.replace(/\n/g,",");
+    var myAjax=new Ajax.Request(
+        "/hicc/jsp/session.jsp",
+        {
+            asynchronous: false,
+            method: 'post',
+            parameters: {"hosts":hosts}
+        }
+    );
+    if (myAjax.success()) {
+        _currentView.getCurrentPage().refresh_all();
+    }
+}
+
+function save_host_role(boxId) {
+    var parameters = "save=true";
+    if(document.getElementById(boxId+"namenode").checked) {
+      parameters = parameters + "&namenode=true";
+    }
+    if(document.getElementById(boxId+"datanode").checked) {
+      parameters = parameters + "&datanode=true";
+    }
+    if(document.getElementById(boxId+"jobtracker").checked) {
+      parameters = parameters + "&jobtracker=true";
+    }
+    if(document.getElementById(boxId+"tasktracker").checked) {
+      parameters = parameters + "&tasktracker=true";
+    }
+    var myAjax=new Ajax.Request(
+        "/hicc/jsp/host_selector_role.jsp",
+        {
+            asynchronous: false,
+            method: 'post',
+            parameters: parameters
+        }
+    );
+    if (myAjax.success()) {
+        _currentView.getCurrentPage().refresh_all();
+    }
+}
+
 function save_hod(HodID) {
     var myAjax=new Ajax.Request(
         "/hicc/jsp/session.jsp",

Modified: hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector.jsp?rev=773123&r1=773122&r2=773123&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector.jsp (original)
+++ hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector.jsp Fri May  8 22:16:14 2009
@@ -17,136 +17,31 @@
  * limitations under the License.
  */
 %>
-<%@ page import = "javax.servlet.http.*, java.sql.*,java.io.*, java.util.Calendar, java.util.Date,
java.text.SimpleDateFormat, java.util.*, org.apache.hadoop.chukwa.hicc.ClusterConfig, org.apache.hadoop.chukwa.hicc.TimeHandler,
org.apache.hadoop.chukwa.database.DatabaseConfig, org.apache.hadoop.chukwa.util.XssFilter"
 %>
-<% XssFilter xf = new XssFilter(request);
-   String boxId = xf.getParameter("boxId"); %>
+<%@ page import = "java.text.SimpleDateFormat" %>
+<%@ page import = "java.text.NumberFormat" %>
+<%@ page import = "java.util.Hashtable" %>
+<%@ page import = "java.util.Enumeration" %>
+<%@ page import = "java.util.Calendar" %>
+<%@ page import = "java.util.Date" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.TimeHandler" %>
+<%@ page import = "org.apache.hadoop.chukwa.util.XssFilter" %>
 <%
-   response.setHeader("boxId", xf.getParameter("boxId"));
+  RequestDispatcher disp = null;
+  XssFilter xf = new XssFilter(request);
+  response.setContentType("text/html; chartset=UTF-8//IGNORE");
+  response.setHeader("boxId", xf.getParameter("boxId"));
+  String hostSelectorType="dropdown";
+  if(request.getParameter("style")!=null) {
+    hostSelectorType=xf.getParameter("style");
+  }
+  if(hostSelectorType.intern()=="role".intern()) {
+    disp = getServletContext( ).getRequestDispatcher("/jsp/host_selector_role.jsp");
+    disp.forward(request, response);
+  } else if(hostSelectorType.intern()=="dropdown".intern()) {
+    disp = getServletContext( ).getRequestDispatcher("/jsp/host_selector_dropdown.jsp");
+    disp.forward(request, response);
+  } else if(hostSelectorType.intern()=="user".intern()) {
+    disp = getServletContext( ).getRequestDispatcher("/jsp/host_selector_user.jsp");
+    disp.forward(request, response);
+  } 
 %>
-<div class="panel">
-<h2>Hosts</h2>
-<fieldset>
-<div class="row">
-<select id="<%= boxId %>group_items" name="<%= boxId %>group_items" MULTIPLE
size=10 class="formSelect" style="width:200px;">
-<%
-    String[] machineNames = (String [])session.getAttribute("machine_names");
-    String cluster=xf.getParameter("cluster");
-    if(cluster!=null && !cluster.equals("null")) {
-        session.setAttribute("cluster",cluster);
-    } else {
-        cluster = (String) session.getAttribute("cluster");
-        if(cluster==null || cluster.equals("null")) {
-            cluster="demo";
-            session.setAttribute("cluster",cluster);
-        }
-    }
-    ClusterConfig cc = new ClusterConfig();
-    String jdbc = cc.getURL(cluster);
-    TimeHandler time = new TimeHandler(request,(String)session.getAttribute("time_zone"));
-    String startS = time.getStartTimeText();
-    String endS = time.getEndTimeText();
-    String timefield = "timestamp";
-    String dateclause = timefield+" >= '"+startS+"' and "+timefield+" <= '"+endS+"'";
-    Connection conn = null;
-    Statement stmt = null;
-    ResultSet rs = null;
-    try {
-        HashMap<String, String> hosts = new HashMap<String, String>();
-        try {
-            String[] selected_hosts = ((String)session.getAttribute("hosts")).split(",");
-            for(String name: selected_hosts) {
-                hosts.put(name,name);
-            }
-        } catch (NullPointerException e) {
-    }
-           conn = org.apache.hadoop.chukwa.util.DriverManagerUtil.getConnection(jdbc);
-           stmt = conn.createStatement();
-           String query = "";
-           String HodID = (String)session.getAttribute("HodID");
-           if(HodID!=null && !HodID.equals("null") && !HodID.equals(""))
{
-               query = "select DISTINCT Machine from HodMachine where HodID='"+HodID+"' order
by Machine;";
-           } else if(machineNames==null) {
-               long start = time.getStartTime();
-               long end = time.getEndTime(); 
-               String table = "system_metrics";
-               DatabaseConfig dbc = new DatabaseConfig();
-               String[] tables = dbc.findTableName(table, start, end);
-               table=tables[0];
-               query="select DISTINCT host from "+table+" order by host";
-           }
-           // or alternatively, if you don't know ahead of time that
-           // the query will be a SELECT...
-           if(!query.equals("")) {
-               if (stmt.execute(query)) {
-                   int i=0;
-                   rs = stmt.getResultSet();
-                   rs.last();
-                   int size = rs.getRow();
-                   machineNames = new String[size];
-                   rs.beforeFirst();
-                   while (rs.next()) {
-                       String machine = rs.getString(1);
-                       machineNames[i]=machine;
-                       if(hosts.containsKey(machine)) {
-                           out.println("<option selected>"+machine+"</option>");
-                       } else {
-                           out.println("<option>"+machine+"</option>");
-                       }
-                       i++;
-                   }
-                   if(HodID==null || HodID.equals("null") || HodID.equals("")) {
-                       session.setAttribute("machine_names",machineNames);
-                   }
-               }
-           } else {
-                   for(String machine : machineNames) {
-                       if(hosts.containsKey(machine)) {
-                           out.println("<option selected>"+machine+"</option>");
-                       } else {
-                           out.println("<option>"+machine+"</option>");
-                       }
-                   }
-           }
-           // Now do something with the ResultSet ....
-       } catch (SQLException ex) {
-           // handle any errors
-           out.println("SQLException: " + ex.getMessage());
-           out.println("SQLState: " + ex.getSQLState());
-           out.println("VendorError: " + ex.getErrorCode());
-       } finally {
-           // it is a good idea to release
-           // resources in a finally{} block
-           // in reverse-order of their creation
-           // if they are no-longer needed
-           if (rs != null) {
-               try {
-                   rs.close();
-               } catch (SQLException sqlEx) {
-                   // ignore
-               }
-               rs = null;
-           }
-           if (stmt != null) {
-               try {
-                   stmt.close();
-               } catch (SQLException sqlEx) {
-                   // ignore
-               }
-               stmt = null;
-           }
-           if (conn != null) {
-               try {
-                   conn.close();
-               } catch (SQLException sqlEx) {
-                   // ignore
-               }
-               conn = null;
-           }
-       }
-%>
-</select></div>
-<div class="row">
-<input type="button" onClick="save_host('<%= boxId %>');" name="Apply" value="Apply"
class="formButton">
-</div>
-</fieldset>
-</div>

Added: hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_dropdown.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_dropdown.jsp?rev=773123&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_dropdown.jsp (added)
+++ hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_dropdown.jsp Fri May  8 22:16:14 2009
@@ -0,0 +1,166 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file 
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+%>
+<%@ page import = "javax.servlet.http.*" %>
+<%@ page import = "java.sql.*" %>
+<%@ page import = "java.io.*" %>
+<%@ page import = "java.util.Calendar" %>
+<%@ page import = "java.util.Date" %>
+<%@ page import = "java.text.SimpleDateFormat" %>
+<%@ page import = "java.util.*" %>
+<%@ page import = "org.json.*" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.ClusterConfig" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.TimeHandler" %>
+<%@ page import = "org.apache.hadoop.chukwa.database.DatabaseConfig" %>
+<%@ page import = "org.apache.hadoop.chukwa.util.XssFilter"  %>
+<% XssFilter xf = new XssFilter(request);
+   String boxId = xf.getParameter("boxId");
+   response.setHeader("boxId", xf.getParameter("boxId"));
+%>
+<div class="panel">
+<h2>Hosts</h2>
+<fieldset>
+<div class="row">
+<select id="<%= boxId %>group_items" name="<%= boxId %>group_items" MULTIPLE
size=10 class="formSelect" style="width:200px;">
+<%
+    JSONArray machineNames = null;
+    if(session.getAttribute("machine_names")!=null) {
+        machineNames = new JSONArray(session.getAttribute("machine_names").toString());
+    }
+    String cluster=xf.getParameter("cluster");
+    if(cluster!=null && !cluster.equals("null")) {
+        session.setAttribute("cluster",cluster);
+    } else {
+        cluster = (String) session.getAttribute("cluster");
+        if(cluster==null || cluster.equals("null")) {
+            cluster="demo";
+            session.setAttribute("cluster",cluster);
+        }
+    }
+    ClusterConfig cc = new ClusterConfig();
+    String jdbc = cc.getURL(cluster);
+    TimeHandler time = new TimeHandler(request,(String)session.getAttribute("time_zone"));
+    String startS = time.getStartTimeText();
+    String endS = time.getEndTimeText();
+    String timefield = "timestamp";
+    String dateclause = timefield+" >= '"+startS+"' and "+timefield+" <= '"+endS+"'";
+    Connection conn = null;
+    Statement stmt = null;
+    ResultSet rs = null;
+    try {
+        HashMap<String, String> hosts = new HashMap<String, String>();
+        try {
+            String[] selected_hosts = ((String)session.getAttribute("hosts")).split(",");
+            for(String name: selected_hosts) {
+                hosts.put(name,name);
+            }
+        } catch (NullPointerException e) {
+    }
+           conn = org.apache.hadoop.chukwa.util.DriverManagerUtil.getConnection(jdbc);
+           stmt = conn.createStatement();
+           String query = "";
+           String jobId = (String)session.getAttribute("JobID");
+           if(jobId!=null && !jobId.equals("null") && !jobId.equals(""))
{
+               query = "select DISTINCT Machine from HodMachine where HodID='"+jobId+"' order
by Machine;";
+           } else if(machineNames==null) {
+               long start = time.getStartTime();
+               long end = time.getEndTime(); 
+               String table = "system_metrics";
+               DatabaseConfig dbc = new DatabaseConfig();
+               String[] tables = dbc.findTableName(table, start, end);
+               table=tables[0];
+               query="select DISTINCT host from "+table+" order by host";
+           }
+           // or alternatively, if you don't know ahead of time that
+           // the query will be a SELECT...
+           if(!query.equals("")) {
+               if (stmt.execute(query)) {
+                   int i=0;
+                   rs = stmt.getResultSet();
+                   rs.last();
+                   int size = rs.getRow();
+                   machineNames = new JSONArray();
+                   rs.beforeFirst();
+                   while (rs.next()) {
+                       String machine = rs.getString(1);
+                       machineNames.put(machine);
+                       if(hosts.containsKey(machine)) {
+                           out.println("<option selected>"+machine+"</option>");
+                       } else {
+                           out.println("<option>"+machine+"</option>");
+                       }
+                       i++;
+                   }
+                   if(jobId==null || jobId.equals("null") || jobId.equals("")) {
+                       session.setAttribute("machine_names",machineNames.toString());
+                   }
+               }
+           } else {
+                   for(int j=0;j<machineNames.length();j++) {
+                       String machine = machineNames.get(j).toString();
+                       if(hosts.containsKey(machine)) {
+                           out.println("<option selected>"+machine+"</option>");
+                       } else {
+                           out.println("<option>"+machine+"</option>");
+                       }
+                   }
+           }
+           // Now do something with the ResultSet ....
+       } catch (SQLException ex) {
+           // handle any errors
+           out.println("SQLException: " + ex.getMessage());
+           out.println("SQLState: " + ex.getSQLState());
+           out.println("VendorError: " + ex.getErrorCode());
+       } finally {
+           // it is a good idea to release
+           // resources in a finally{} block
+           // in reverse-order of their creation
+           // if they are no-longer needed
+           if (rs != null) {
+               try {
+                   rs.close();
+               } catch (SQLException sqlEx) {
+                   // ignore
+               }
+               rs = null;
+           }
+           if (stmt != null) {
+               try {
+                   stmt.close();
+               } catch (SQLException sqlEx) {
+                   // ignore
+               }
+               stmt = null;
+           }
+           if (conn != null) {
+               try {
+                   conn.close();
+               } catch (SQLException sqlEx) {
+                   // ignore
+               }
+               conn = null;
+           }
+       }
+%>
+</select></div>
+<div class="row">
+<input type="button" onClick="save_host('<%= boxId %>');" name="Apply" value="Apply"
class="formButton">
+</div>
+</fieldset>
+</div>

Added: hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_role.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_role.jsp?rev=773123&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_role.jsp (added)
+++ hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_role.jsp Fri May  8 22:16:14 2009
@@ -0,0 +1,89 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file 
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+%>
+<%@ page import = "javax.servlet.http.*" %>
+<%@ page import = "java.sql.*" %>
+<%@ page import = "java.io.*" %>
+<%@ page import = "java.util.Calendar" %>
+<%@ page import = "java.util.Date" %>
+<%@ page import = "java.text.SimpleDateFormat" %>
+<%@ page import = "java.util.*" %>
+<%@ page import = "org.json.*" %>
+<%@ page import = "org.apache.hadoop.chukwa.database.Macro" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.ClusterConfig" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.TimeHandler" %>
+<%@ page import = "org.apache.hadoop.chukwa.util.DatabaseWriter" %>
+<%@ page import = "org.apache.hadoop.chukwa.util.XssFilter"  %>
+<% XssFilter xf = new XssFilter(request);
+   String boxId = xf.getParameter("boxId");
+   response.setHeader("boxId", xf.getParameter("boxId"));
+   TimeHandler time = new TimeHandler(request, (String)session.getAttribute("time_zone"));
+   long start = time.getStartTime();
+   long end = time.getEndTime();
+   String cluster = (String) session.getAttribute("cluster");
+   boolean first = false;
+   String[] types = {"namenode","datanode","jobtracker","tasktracker"};
+   String[] queries = {"select distinct host from [dfs_namenode] where timestamp between
'[start]' and '[end]'",
+                       "select distinct host from [hadoop_jvm] where process_name='datanode'
and timestamp between '[start]' and '[end]'",
+                       "select distinct host from [hadoop_jvm] where process_name='jobtracker'
and timestamp between '[start]' and '[end]'",
+                       "select distinct host from [hadoop_jvm] where process_name='tasktracker'
and timestamp between '[start]' and '[end]'"};
+   int i = 0;
+   StringBuffer hosts = new StringBuffer();
+   JSONObject roles = new JSONObject();
+   for(String type : types) {
+     if(xf.getParameter(type)!=null) {
+       Macro mp = new Macro(start, end, queries[i]);
+       String query = mp.toString();
+       DatabaseWriter db = new DatabaseWriter(cluster);
+       try {
+         ResultSet rs = db.query(query);
+         while(rs.next()) {
+           if(!first) {
+             hosts.append(",");
+           }
+           hosts.append(rs.getString(1));
+           first=false;
+         }
+         roles.put(type,"checked");
+       } catch(SQLException ex) {
+         // Ignore if there is no data for the cluster.
+       } finally {
+         db.close();
+       }
+     } else {
+       roles.put(type,"");
+     }
+     i++;
+   }
+   if(xf.getParameter("save")!=null) {
+     session.setAttribute("hosts",hosts.toString());
+     session.setAttribute("host.selector.role",roles.toString());
+   } else {
+     if(session.getAttribute("host.selector.role")!=null) {
+       roles = new JSONObject(session.getAttribute("host.selector.role").toString());
+     }
+   }
+%>
+HDFS Cluster<br>
+<input type="checkbox" id="<%= boxId %>namenode" value="true" <%= roles.get("namenode")
%>> Name Nodes<br>
+<input type="checkbox" id="<%= boxId %>datanode" value="true" <%= roles.get("datanode")
%>> Data Nodes<br><br>
+Map Reduce Cluster<br>
+<input type="checkbox" id="<%= boxId %>jobtracker" value="true" <%= roles.get("jobtracker")
%>> Job Tracker<br>
+<input type="checkbox" id="<%= boxId %>tasktracker" value="true" <%= roles.get("tasktracker")
%>> Task Trackers<br><br>
+<input type="button" onClick="save_host_role('<%= boxId %>');" name="Apply" value="Apply"
class="formButton">

Added: hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_user.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_user.jsp?rev=773123&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_user.jsp (added)
+++ hadoop/chukwa/trunk/src/web/hicc/jsp/host_selector_user.jsp Fri May  8 22:16:14 2009
@@ -0,0 +1,70 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file 
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+%>
+<%@ page import = "javax.servlet.http.*" %>
+<%@ page import = "org.apache.hadoop.chukwa.util.XssFilter"  %>
+<% XssFilter xf = new XssFilter(request);
+   String boxId = xf.getParameter("boxId");
+   response.setHeader("boxId", xf.getParameter("boxId"));
+%>
+<h2>Hosts</h2>
+<textarea id="<%= boxId %>group_items" name="<%= boxId %>group_items" class="formSelect"
style="width:200px;"><%
+  if(session.getAttribute("hosts")!=null) {
+    String[] machineNames = (session.getAttribute("hosts").toString()).split(",");
+    for(String node: machineNames) {
+      out.println(node);
+    }
+  }
+%></textarea><br>
+<input type="button" onClick="save_host_user('<%= boxId %>');" name="Apply" value="Apply"
class="formButton">
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file 
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+%>
+<%@ page import = "javax.servlet.http.*" %>
+<%@ page import = "org.apache.hadoop.chukwa.util.XssFilter"  %>
+<% XssFilter xf = new XssFilter(request);
+   String boxId = xf.getParameter("boxId");
+   response.setHeader("boxId", xf.getParameter("boxId"));
+%>
+<h2>Hosts</h2>
+<textarea id="<%= boxId %>group_items" name="<%= boxId %>group_items" class="formSelect"
style="width:200px;"><%
+  if(session.getAttribute("hosts")!=null) {
+    String[] machineNames = (session.getAttribute("hosts").toString()).split(",");
+    for(String node: machineNames) {
+      out.println(node);
+    }
+  }
+%></textarea><br>
+<input type="button" onClick="save_host_user('<%= boxId %>');" name="Apply" value="Apply"
class="formButton">



Mime
View raw message