chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r774159 [1/2] - in /hadoop/chukwa/trunk: ./ lib/ src/java/org/apache/hadoop/chukwa/hicc/ src/web/hicc/ src/web/hicc/descriptors/ src/web/hicc/js/workspace/ src/web/hicc/jsp/ src/web/hicc/views/
Date Wed, 13 May 2009 00:54:46 GMT
Author: eyang
Date: Wed May 13 00:54:46 2009
New Revision: 774159

URL: http://svn.apache.org/viewvc?rev=774159&view=rev
Log:
CHUKWA-84. Enhance the ability to select time per widget. (Terence Kwan via Eric Yang)

Added:
    hadoop/chukwa/trunk/lib/jchronic-0.2.3.jar   (with props)
    hadoop/chukwa/trunk/src/web/hicc/js/workspace/custom_edits.js
    hadoop/chukwa/trunk/src/web/hicc/jsp/help.jsp
Modified:
    hadoop/chukwa/trunk/build.xml
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/TimeHandler.java
    hadoop/chukwa/trunk/src/web/hicc/descriptors/client_trace.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk_pcnt.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics_pcnt.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_counter.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_rate.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_fsnamesystem.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_counter.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_rate.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_throughput.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/disk.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/disk_pcnt.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_counter.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_rate.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_mapred.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/node_activity_chart.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/rpc_metrics.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/sql_charter.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics.descriptor
    hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics_pcnt.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/views/default.view

Modified: hadoop/chukwa/trunk/build.xml
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/build.xml?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/build.xml (original)
+++ hadoop/chukwa/trunk/build.xml Wed May 13 00:54:46 2009
@@ -675,6 +675,7 @@
 		<copy todir="${build.dir}/hicc/WEB-INF/lib">
 			<fileset dir="${basedir}/lib">
 				<include name="json.jar" />
+				<include name="jchronic-0.2.3.jar" />
 				<include name="html-filter-1.0.jar" />
 			</fileset>
 			<fileset dir="${common.ivy.lib.dir}">

Added: hadoop/chukwa/trunk/lib/jchronic-0.2.3.jar
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/lib/jchronic-0.2.3.jar?rev=774159&view=auto
==============================================================================
Binary file - no diff available.

Propchange: hadoop/chukwa/trunk/lib/jchronic-0.2.3.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/TimeHandler.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/TimeHandler.java?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/TimeHandler.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/TimeHandler.java Wed May 13
00:54:46 2009
@@ -23,9 +23,19 @@
 
 import org.apache.hadoop.chukwa.util.XssFilter;
 
+import java.util.Date;
 import java.util.Calendar;
 import java.util.TimeZone;
+import java.util.StringTokenizer;
 import java.text.SimpleDateFormat;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import com.mdimension.jchronic.Chronic;
+import com.mdimension.jchronic.Options;
+import com.mdimension.jchronic.tags.Pointer;
+import com.mdimension.jchronic.utils.Span;
+import com.mdimension.jchronic.utils.Time;
+
 
 public class TimeHandler {
   private HttpSession session = null;
@@ -42,6 +52,7 @@
   private String startS = null;
   private String endS = null;
   private XssFilter xf = null;
+    private static Log log=LogFactory.getLog(TimeHandler.class);
   
   public TimeHandler(HttpServletRequest request) {
     this.tz = TimeZone.getTimeZone("UTC");
@@ -57,6 +68,43 @@
     init(request);
   }
 
+    /*
+     * Using the Chronic library to parse the english string
+     * and convert it to a long (millis seconds since 1970)
+     */
+    public long parseDateShorthand(String d) {
+	Calendar now = Calendar.getInstance();
+	long l=now.getTimeInMillis();
+	d=d.trim();
+	if (d.compareToIgnoreCase("now")==0) {
+	    // do nothing because it is default to now.
+	} else {
+	    Options options= new Options(false);
+	    options.setCompatibilityMode(true);
+	    options.setNow(now);
+	    try {
+		Span span = Chronic.parse(d, options);
+		l = span.getBegin()*1000;
+	    } catch (Exception e) {
+		// exception when parsing
+		log.error("parse error for: "+d);		
+	    }
+	}
+
+	/*
+	 * debug 
+	 */
+	/*
+        SimpleDateFormat sf =
+            new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+	Date ld=new Date(l);
+
+	log.error("Convert:"+d+" to "+Long.toString(l)+" - "+sf.format(ld)+ "-"+ld.getTime());
+	*/
+
+	return l;
+    }
+
   public void init(HttpServletRequest request) {
     xf = new XssFilter(request);
     Calendar now = Calendar.getInstance();
@@ -95,6 +143,27 @@
         start = end - (7 * 24 * 60 * 60 * 1000);
       } else if (period.equals("last30d")) {
         start = end - (30 * 24 * 60 * 60 * 1000);
+      } else if (period.startsWith("custom;")) {
+
+	  // default value is between 2 days ago and now
+	  String startString="2 days ago";
+	  String endString="now";
+	  
+	  // tokenize the value to "custom;2 days ago;now" 
+	  StringTokenizer st=new StringTokenizer(period,";");
+	  if (st.hasMoreTokens()) {
+	      st.nextToken(); // skip the first token
+	      if (st.hasMoreTokens()) {
+		  startString=st.nextToken();
+		  if (st.hasMoreTokens()) {
+		      endString=st.nextToken();
+		  }
+	      }
+	  }
+
+	  // parse the parameter strings
+	  start = parseDateShorthand(startString);
+	  end = parseDateShorthand(endString);
       }
     } else if (request.getParameter("start") != null
         && request.getParameter("end") != null) {

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/client_trace.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/client_trace.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/client_trace.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/client_trace.descriptor Wed May 13 00:54:46
2009
@@ -9,18 +9,7 @@
 "refresh":"15",
 "parameters":[
 {"name":"table","type":"string","value":"ClientTrace","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"local_hdfs_read","label":"Metric","options":[
 {"label":"Local HDFS Read","value":"local_hdfs_read"},
 {"label":"Intra-rack HDFS Read","value":"intra_rack_hdfs_read"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk.descriptor Wed May 13 00:54:46
2009
@@ -10,18 +10,7 @@
 "parameters":[
 {"name":"table","type":"string","value":"cluster_disk","edit":"0"},
 {"name":"group_override","type":"string","value":"mount","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"available","label":"Metric","options":[
 {"label":"used","value":"used"},                            
 {"label":"available","value":"available"}

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk_pcnt.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk_pcnt.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk_pcnt.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_disk_pcnt.descriptor Wed May 13 00:54:46
2009
@@ -13,18 +13,7 @@
 {"name":"y_axis_max","type":"string","value":"100","edit":"0"},
 {"name":"display_percentage","type":"string","value":"1","edit":"0"},
 {"name":"metric","type":"string","value":"used_percent","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"width","type":"select","value":"300","label":"Width","options":[
 {"label":"300","value":"300"},
 {"label":"400","value":"400"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics.descriptor Wed May 13 00:54:46
2009
@@ -9,18 +9,7 @@
 "refresh":"15",
 "parameters":[
 {"name":"table","type":"string","value":"cluster_system_metrics","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"load_15","label":"Metric","options":[
 {"label":"Reporting Hosts","value":"host"},
 {"label":"load_15","value":"load_15"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics_pcnt.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics_pcnt.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics_pcnt.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/cluster_metrics_pcnt.descriptor Wed May 13
00:54:46 2009
@@ -11,18 +11,7 @@
 {"name":"y_axis_max","type":"string","value":"100","edit":"0"},
 {"name":"display_percentage","type":"string","value":"1","edit":"0"},
 {"name":"table","type":"string","value":"cluster_system_metrics","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"load_15","label":"Metric","options":[
 {"label":"cpu_idle_pcnt","value":"cpu_idle_pcnt"},
 {"label":"cpu_nice_pcnt","value":"cpu_nice_pcnt"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_counter.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_counter.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_counter.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_counter.descriptor Wed May 13
00:54:46 2009
@@ -13,18 +13,7 @@
 {"name":"find_slope","type":"string","value":"true","edit":"0"},
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"bytes_read","label":"Metric","options":[
 {"label":"block_reports_num_ops","value":"block_reports_num_ops"}, 
 {"label":"block_verification_failures","value":"block_verification_failures"}, 

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_rate.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_rate.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_rate.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_datanode_rate.descriptor Wed May 13 00:54:46
2009
@@ -12,18 +12,7 @@
 {"name":"normalize_time","type":"string","value":"true","edit":"0"},
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"heart_beats_avg_time","label":"Metric","options":[
 {"label":"block_reports_avg_time","value":"block_reports_avg_time"}, 
 {"label":"copy_block_op_avg_time","value":"copy_block_op_avg_time"}, 

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_fsnamesystem.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_fsnamesystem.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_fsnamesystem.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_fsnamesystem.descriptor Wed May 13 00:54:46
2009
@@ -9,18 +9,7 @@
 "refresh":"15",
 "parameters":[
 {"name":"table","type":"string","value":"dfs_fsnamesystem","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"capacity_remaining_gb","label":"Metric","options":[
 {"label":"blocks_total","value":"blocks_total"},                            
 {"label":"capacity_remaining_gb","value":"capacity_remaining_gb"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_counter.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_counter.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_counter.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_counter.descriptor Wed May 13
00:54:46 2009
@@ -12,18 +12,7 @@
 {"name":"table","type":"string","value":"dfs_namenode","edit":"0"},
 {"name":"group_override","type":"string","value":"host","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"files_created","label":"Metric","options":[
 {"label":"add_block_ops","value":"add_block_ops"},                            
 {"label":"create_file_ops","value":"create_file_ops"},         

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_rate.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_rate.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_rate.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_namenode_rate.descriptor Wed May 13 00:54:46
2009
@@ -11,18 +11,7 @@
 {"name":"group_override","type":"string","value":"host","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
 {"name":"table","type":"string","value":"dfs_namenode","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"block_report_avg_time","label":"Metric","options":[
 {"label":"blocks_corrupted","value":"blocks_corrupted"},
 {"label":"safe_mode_time","value":"safe_mode_time"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_throughput.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_throughput.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_throughput.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/dfs_throughput.descriptor Wed May 13 00:54:46
2009
@@ -9,18 +9,7 @@
 "refresh":"15",
 "parameters":[
 {"name":"table","type":"string","value":"dfs_throughput","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"heart_beats_avg_time","label":"Metric","options":[
 {"label":"hosts","value":"hosts"},
 {"label":"block_reports_num_ops","value":"block_reports_num_ops"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/disk.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/disk.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/disk.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/disk.descriptor Wed May 13 00:54:46 2009
@@ -12,18 +12,7 @@
 {"name":"group_override","type":"string","value":"concat(host,mount) as mount","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"available","label":"Metric","options":[
 {"label":"used","value":"used"},                            
 {"label":"available","value":"available"}

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/disk_pcnt.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/disk_pcnt.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/disk_pcnt.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/disk_pcnt.descriptor Wed May 13 00:54:46
2009
@@ -15,18 +15,7 @@
 {"name":"metric","type":"string","value":"used_percent","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"width","type":"select","value":"300","label":"Width","options":[
 {"label":"300","value":"300"},
 {"label":"400","value":"400"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_counter.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_counter.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_counter.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_counter.descriptor Wed May 13
00:54:46 2009
@@ -13,18 +13,7 @@
 {"name":"group_override","type":"string","value":"concat(host,' ',process_name) as process","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select","value":"gc_timemillis","label":"Metric","options":[
 {"label":"gc_timemillis","value":"gc_timemillis"},
 {"label":"gc_count","value":"gc_count"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_rate.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_rate.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_rate.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_jvm_rate.descriptor Wed May 13 00:54:46
2009
@@ -13,18 +13,7 @@
 {"name":"group_override","type":"string","value":"concat(host,' ',process_name) as process","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select","value":"threads_blocked","label":"Metric","options":[
 {"label":"mem_heap_committed_m","value":"mem_heap_committed_m"},
 {"label":"mem_heap_used_m","value":"mem_heap_used_m"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_mapred.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_mapred.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_mapred.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/hadoop_mapred.descriptor Wed May 13 00:54:46
2009
@@ -10,18 +10,7 @@
 "parameters":[
 {"name":"find_slope","type":"string","value":"true","edit":"0"},
 {"name":"table","type":"string","value":"hadoop_mapred","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"heartbeat_avg_time","label":"Metric","options":[
 {"label":"jobs_completed","value":"jobs_completed"},
 {"label":"jobs_submitted","value":"jobs_submitted"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/node_activity_chart.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/node_activity_chart.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/node_activity_chart.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/node_activity_chart.descriptor Wed May 13
00:54:46 2009
@@ -15,18 +15,7 @@
 {"name":"title","type":"string","value":"Node Activity","edit":"0"},
 {"name":"compound_data","type":"string","value":"true","edit":"0"},
 {"name":"render","type":"string","value":"stack-area","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"width","type":"select","value":"300","label":"Width","options":[
 {"label":"300","value":"300"},
 {"label":"400","value":"400"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/rpc_metrics.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/rpc_metrics.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/rpc_metrics.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/rpc_metrics.descriptor Wed May 13 00:54:46
2009
@@ -12,18 +12,7 @@
 {"name":"group","type":"string","value":"host","edit":"0"},
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
 {"name":"table","type":"string","value":"hadoop_rpc","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select","value":"heartbeat_avg_time","label":"Metric","options":[
 {"label":"rpc_processing_time_avg_time","value":"rpc_processing_time_avg_time"}, 
 {"label":"rpc_processing_time_num_ops","value":"rpc_processing_time_num_ops"}, 

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/sql_charter.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/sql_charter.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/sql_charter.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/sql_charter.descriptor Wed May 13 00:54:46
2009
@@ -10,18 +10,7 @@
 {"name":"query","type":"text","value":"select host,max(load_1),min(load_1),avg(load_1) from
system_metrics_2032_week where timestamp >='2008-12-13 17:30' and timestamp <= '2008-12-13
18:30' group by host","label":"Query","edit":"1"},
 {"name":"title","type":"string","label":"Title","value":"","edit":"1"},
 {"name":"x_axis_label","type":"string","value":"Hostname","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"width","type":"select","value":"300","label":"Width","options":[
 {"label":"300","value":"300"},
 {"label":"400","value":"400"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics.descriptor Wed May 13 00:54:46
2009
@@ -11,18 +11,7 @@
 {"name":"table","type":"string","value":"system_metrics","edit":"0"},
 {"name":"group","type":"string","value":"host","edit":"0"},
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"load_1","label":"Metric","options":[
 {"label":"15 minutes load average","value":"load_15"},
 {"label":"5 minutes load average","value":"load_5"},

Modified: hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics_pcnt.descriptor
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics_pcnt.descriptor?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics_pcnt.descriptor (original)
+++ hadoop/chukwa/trunk/src/web/hicc/descriptors/system_metrics_pcnt.descriptor Wed May 13
00:54:46 2009
@@ -13,18 +13,7 @@
 {"name":"group_items","type":"string","value":"hosts","edit":"0"},
 {"name":"y_axis_max","type":"string","value":"100","edit":"0"},
 {"name":"display_percentage","type":"string","value":"1","edit":"0"},
-{"name":"period","type":"select","value":"","label":"Period","options":[
-{"label":"Use Time Widget","value":""},
-{"label":"Last 1 Hour","value":"last1hr"},
-{"label":"Last 2 Hours","value":"last2hr"},
-{"label":"Last 3 Hours","value":"last3hr"},
-{"label":"Last 6 Hours","value":"last6hr"},
-{"label":"Last 12 Hours","value":"last12hr"},
-{"label":"Last 24 Hours","value":"last24hr"},
-{"label":"Yesterday","value":"yesterday"},
-{"label":"Last 7 Days","value":"last7d"},
-{"label":"Last 30 Days","value":"last30d"}
-]},
+{"name":"period","type":"custom","control":"period_control","value":"","label":"Period"},
 {"name":"metric","type":"select_multiple","value":"cpu_user_pcnt","label":"Metric","options":[
 {"label":"CPU System %","value":"cpu_system_pcnt"},
 {"label":"CPU User %","value":"cpu_user_pcnt"},

Modified: hadoop/chukwa/trunk/src/web/hicc/index.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/index.jsp?rev=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/index.jsp (original)
+++ hadoop/chukwa/trunk/src/web/hicc/index.jsp Wed May 13 00:54:46 2009
@@ -83,6 +83,8 @@
 <script type="text/javascript" src="/hicc/js/workspace/scriptaculous.js"></script>
 <script type="text/javascript" src="/hicc/js/workspace/effects.js"></script>
 <script type="text/javascript" src="/hicc/js/workspace/dragdrop.js"></script>
+<script type="text/javascript" src="/hicc/js/workspace/prototype.js"></script>
+<script type="text/javascript" src="/hicc/js/workspace/custom_edits.js"></script>
 <script type="text/javascript" src="/hicc/js/workspace/workspace.js"></script>
 <script type="text/javascript" src="/hicc/js/slider.js"></script>
 <script type="text/javascript" src="/hicc/js/swfobject.js"></script>

Added: hadoop/chukwa/trunk/src/web/hicc/js/workspace/custom_edits.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/js/workspace/custom_edits.js?rev=774159&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/js/workspace/custom_edits.js (added)
+++ hadoop/chukwa/trunk/src/web/hicc/js/workspace/custom_edits.js Wed May 13 00:54:46 2009
@@ -0,0 +1,167 @@
+/*
+ * 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.
+ */
+
+/*
+ * toggle the custom period control
+ */
+function togglePeriodControl(event) {
+  var element = Event.element(event);
+  value=$F(element.id);
+  if (value=='custom') {
+    $(element.id+'_custom_block').show();
+  } else {
+    $(element.id+'_custom_block').hide();
+  }
+}
+
+/*
+ * popup the online help
+ */
+function popup_help(event) {
+  var element = Event.element(event);
+  window.open("/hicc/jsp/help.jsp?id="+element.id,
+	      "Help",
+	      "width=500,height=400");
+}
+
+/*
+ * For each custom control, you need to provide 3 plugins
+ *   * build_custom_edit - build the control's html 
+ *   * after_build_custom_edits - setup the control's javascript and notification (optional)
+ *   * get_custom_edit_value - return the custom control's value
+ */
+
+/*
+ * external function to build custom edit component in the widget.
+ *
+ * param will have all the information to build this edit control
+ */
+function build_custom_edit(control_id, param) {
+  var content='';
+  if (param.control == 'period_control') {
+    // setup up the period control
+    time_options = [['Use Time Widget',''],
+		    ['Last 1 Hour','last1hr'],
+		    ['Last 2 Hour','last2hr'],
+		    ['Last 3 Hour','last3hr'],
+		    ['Last 6 Hour','last6hr'],
+		    ['Last 12 Hour','last12hr'],
+		    ['Last 24 Hour','last24hr'],
+		    ['Yesterday','yesterday'],
+		    ['Last 7 Days','last7d'],
+		    ['Last 30 Days','last30d'],
+		    ['Custom Period','custom'],
+		    ];
+
+    content+='<select class="formSelect periodControl" id="'+control_id+'" name="'+control_id+'"
>';
+    for (var j=0;j<time_options.length;j++) {
+      var option=time_options[j];
+      var selected=false;
+      var param_value=param.value;
+
+      if (param_value==option[1]) {
+	selected=true;
+      } else {
+	if ((option[1]=='custom') && (param_value.startsWith('custom;'))) {
+	  selected=true;
+	}
+      }
+      content+='<option '+((selected)?'selected':'')+' value="'+option[1]+'">'+option[0]+'</option>';
+    }
+    content+='</select>';
+    content+='<div id="'+control_id+'_custom_block" style="display:'+(param_value.startsWith('custom;')?'block':'none')+';">';
+    start_string='2 days ago';
+    end_string='now';
+    if (param_value.startsWith('custom;')) {
+      param_value_split=param_value.split(";");
+      if (param_value_split.length==3) { // custom;start;end
+	start_string=param_value_split[1];
+	end_string=param_value_split[2];
+      }
+    }
+    // setup the custom date stuff
+    content+='<br/>';
+    content+='<fieldset>';
+    content+='<legend>Custom Period</legend>';
+    content+='<table>';
+    content+='<tr><td>';
+    content+='<label for="start_period">Start Period:</label>';
+    content+='</td><td>';
+    content+='<input type="edit" name="'+control_id+'_start" id="'+control_id+'_start"
value="'+start_string+'"/>';
+    content+='</td><td>';
+    content+='<a href="#" id="help_edit_start_time" class="help_control">?</a>';
+    content+='</td></tr>';
+    content+='<tr><td>';
+    content+='<label for="end_period">End Period:</label>';
+    content+='</td><td>';
+    content+='<input type="edit" name="'+control_id+'_end" id="'+control_id+'_end" value="'+end_string+'"/>';
+    content+='</td><td>';
+    content+='<a href="#" id="help_edit_start_time" class="help_control">?</a>';
+    content+='</td></tr>';
+    content+='</table>';
+    content+='</fieldset>';
+
+    content+='</div>';
+  }
+  return content;
+}
+
+/*
+ * function to do post setup for the custom control. For example,
+ * hook up the event notification javascript
+ */
+function after_build_custom_edits(box) {
+  for (iCount=0;iCount<box.block_obj.parameters.length;iCount++) {
+    if (box.block_obj.parameters[iCount].edit!=0) {
+      var param_id='param_'+box.pageid+'_'+box.boxIndex + '_'+iCount;
+      var param=box.block_obj.parameters[iCount];
+      if (param.type=='custom') {
+
+	// setup the period control
+	if ("period_control" == param.control) {
+
+	  // hook up the event notification stuff
+	  period_control=document.getElementById(param_id);
+	  if (period_control != null) {
+	    period_control.observe('change',togglePeriodControl);
+	  }
+
+	  // hook up the help
+	  help_controls=document.getElementsByClassName("help_control");
+	  for (i=0;i<help_controls.length;i++) {
+	    help_controls[i].observe('click',popup_help);
+	  }
+	}
+      }
+    }
+  }
+}
+
+/*
+ * return the value for the custom control
+ */
+function get_custom_edit_value(control_id, param) {
+  var value='';
+  if (param.control == 'period_control') {
+    value=$F(control_id);
+    if (value == 'custom') {
+      value='custom;'+$F(control_id+'_start')+';'+$F(control_id+'_end');
+    }
+  }
+  return value;
+}

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=774159&r1=774158&r2=774159&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js (original)
+++ hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js Wed May 13 00:54:46 2009
@@ -434,7 +434,7 @@
 		    label=param.label;
 		}
 		label=label;
-	        content+='<tr><td>'+label+':<\/td><td>';
+	        content+='<tr><td valign="top">'+label+':<\/td><td>';
 	        if (param.type=='string') {
 		    content+='<input type="text" id="'+param_id+'" value="' + param.value + '" size="20"
maxlength="255"\/>'
 	        } else if (param.type=='text') {
@@ -536,6 +536,9 @@
 		    	content+='<option '+(param_selected ?'selected':'')+' value="'+option.value+'">'+option.label+'</option>';
 		    }
 		    content+='</select>';
+		} else if (param.type=='custom') {
+		  // build a custom widget
+		  content+=build_custom_edit(param_id, param);
 		}
 		content+='<\/td><\/tr>'
 	    }
@@ -550,7 +553,7 @@
 
    	editBox.innerHTML = content;
    
-   	parentObj.appendChild(editBox);		
+   	parentObj.appendChild(editBox);	
     },
 
     saveParameters: function() {
@@ -567,6 +570,8 @@
                 } else if (param.type=='select_multiple_callback') {
 		    selectAll(param_id);
 	            param.value=$F(param_id);
+		} else if (param.type=='custom') {
+		  param.value=get_custom_edit_value(param_id, param);
 		} else {
 	            param.value=$F(param_id);
 		}
@@ -702,6 +707,7 @@
    	}
 	this.obj=div;
 	this.parentObj=div.parentNode;
+	after_build_custom_edits(this);
     },
 
     addBoxHeader: function(parentObj) {

Added: hadoop/chukwa/trunk/src/web/hicc/jsp/help.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/jsp/help.jsp?rev=774159&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/jsp/help.jsp (added)
+++ hadoop/chukwa/trunk/src/web/hicc/jsp/help.jsp Wed May 13 00:54:46 2009
@@ -0,0 +1,29 @@
+<html>
+<head>
+<link href="css/default.css" rel="stylesheet" type="text/css">
+</head>
+<body>
+<!-- TODO: check the parameter ID and forward to the proper help content -->
+<h1>Custom Period Input String Format</h1>
+You can type in normal English time string or absolute time string to specify the date. For
example:
+<ul>
+<li>Time relative to now
+  <ul>
+     <li>2 months ago</li>
+     <li>3 weeks ago</li>
+     <li>2 hours ago</li>
+     <li>20 minutes ago</li>
+  </ul>
+</li>
+<li>Absolute Time
+  <ul>
+     <li>may 27 2009</li>
+     <li>may 27 5:00 pm</li>
+     <li>may 27 09 4:30</li>
+     <li>2009/04/12 04:30:50</li>
+     <li>2009-04-12 04:30:50</li>
+  </ul>
+</li>
+</ul>
+</body>
+</html>
\ No newline at end of file



Mime
View raw message