View Javadoc

1   // Autogenerated Jamon implementation
2   // /var/tmp/hbase-0.94.16/src/main/jamon/org/apache/hadoop/hbase/tmpl/common/TaskMonitorTmpl.jamon
3   
4   package org.apache.hadoop.hbase.tmpl.common;
5   
6   // 21, 1
7   import java.util.*;
8   // 22, 1
9   import org.apache.hadoop.hbase.monitoring.*;
10  // 23, 1
11  import org.apache.hadoop.util.StringUtils;
12  
13  public class TaskMonitorTmplImpl
14    extends org.jamon.AbstractTemplateImpl
15    implements org.apache.hadoop.hbase.tmpl.common.TaskMonitorTmpl.Intf
16  
17  {
18    private final String format;
19    private final TaskMonitor taskMonitor;
20    private final String filter;
21    protected static org.apache.hadoop.hbase.tmpl.common.TaskMonitorTmpl.ImplData __jamon_setOptionalArguments(org.apache.hadoop.hbase.tmpl.common.TaskMonitorTmpl.ImplData p_implData)
22    {
23      if(! p_implData.getFormat__IsNotDefault())
24      {
25        p_implData.setFormat("html");
26      }
27      if(! p_implData.getTaskMonitor__IsNotDefault())
28      {
29        p_implData.setTaskMonitor(TaskMonitor.get());
30      }
31      if(! p_implData.getFilter__IsNotDefault())
32      {
33        p_implData.setFilter("general");
34      }
35      return p_implData;
36    }
37    public TaskMonitorTmplImpl(org.jamon.TemplateManager p_templateManager, org.apache.hadoop.hbase.tmpl.common.TaskMonitorTmpl.ImplData p_implData)
38    {
39      super(p_templateManager, __jamon_setOptionalArguments(p_implData));
40      format = p_implData.getFormat();
41      taskMonitor = p_implData.getTaskMonitor();
42      filter = p_implData.getFilter();
43    }
44    
45    public void renderNoFlush(@SuppressWarnings({"unused","hiding"}) final java.io.Writer jamonWriter)
46      throws java.io.IOException
47    {
48      // 30, 1
49      
50  List<? extends MonitoredTask> tasks = taskMonitor.getTasks();
51  Iterator<? extends MonitoredTask> iter = tasks.iterator();
52  // apply requested filter
53  while (iter.hasNext()) {
54    MonitoredTask t = iter.next();
55    if (filter.equals("general")) {
56      if (t instanceof MonitoredRPCHandler)
57        iter.remove();
58    } else if (filter.equals("handler")) {
59      if (!(t instanceof MonitoredRPCHandler))
60        iter.remove();
61    } else if (filter.equals("rpc")) {
62      if (!(t instanceof MonitoredRPCHandler) || 
63          !((MonitoredRPCHandler) t).isRPCRunning())
64        iter.remove();
65    } else if (filter.equals("operation")) {
66      if (!(t instanceof MonitoredRPCHandler) || 
67          !((MonitoredRPCHandler) t).isOperationRunning())
68        iter.remove();
69    }
70  }
71  long now = System.currentTimeMillis();
72  Collections.reverse(tasks);
73  boolean first = true;
74  
75      // 56, 1
76      if (format.equals("json"))
77      {
78        // 56, 29
79        jamonWriter.write("\n[");
80        // 57, 2
81        for (MonitoredTask task : tasks)
82        {
83          // 57, 36
84          if (first)
85          {
86            // 57, 48
87            first = false;
88          }
89          // 57, 77
90          else
91          {
92            // 57, 84
93            jamonWriter.write(",");
94          }
95          // 57, 91
96          org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(task.toJSON()), jamonWriter);
97        }
98        // 57, 117
99        jamonWriter.write("]\n");
100     }
101     // 58, 1
102     else
103     {
104       // 58, 8
105       jamonWriter.write("\n<h2>Tasks</h2>\n  <div id=\"tasks_menu\">\n    <a href=\"?filter=all\">Show All Monitored Tasks</a>\n    <a href=\"?filter=general\">Show non-RPC Tasks</a>\n    <a href=\"?filter=handler\">Show All RPC Handler Tasks</a>\n    <a href=\"?filter=rpc\">Show Active RPC Calls</a>\n    <a href=\"?filter=operation\">Show Client Operations</a>\n    <a href=\"?format=json&filter=");
106       // 66, 34
107       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(filter), jamonWriter);
108       // 66, 46
109       jamonWriter.write("\">View as JSON</a>\n  </div>\n  ");
110       // 68, 3
111       if (tasks.isEmpty())
112       {
113         // 68, 25
114         jamonWriter.write("\n    No tasks currently running on this node.\n  ");
115       }
116       // 70, 3
117       else
118       {
119         // 70, 10
120         jamonWriter.write("\n    <table>\n    <tr>\n      <th>Start Time</th>\n      <th>Description</th>\n      <th>State</th>\n      <th>Status</th>\n    </tr>\n    ");
121         // 78, 5
122         for (MonitoredTask task : tasks )
123         {
124           // 78, 40
125           jamonWriter.write("\n    <tr class=\"task-monitor-");
126           // 79, 29
127           org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(task.getState()), jamonWriter);
128           // 79, 50
129           jamonWriter.write("\">\n      <td>");
130           // 80, 11
131           org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(new Date(task.getStartTime())), jamonWriter);
132           // 80, 46
133           jamonWriter.write("</td>\n      <td>");
134           // 81, 11
135           org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(task.getDescription()), jamonWriter);
136           // 81, 38
137           jamonWriter.write("</td>\n      <td>");
138           // 82, 11
139           org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(task.getState()), jamonWriter);
140           // 82, 32
141           jamonWriter.write("\n          (since ");
142           // 83, 18
143           org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(StringUtils.formatTimeDiff(now, task.getStateTime())), jamonWriter);
144           // 83, 76
145           jamonWriter.write(" ago)\n      </td>\n      <td>");
146           // 85, 11
147           org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(task.getStatus()), jamonWriter);
148           // 85, 33
149           jamonWriter.write("\n          (since ");
150           // 86, 18
151           org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(StringUtils.formatTimeDiff(now, task.getStatusTime())), jamonWriter);
152           // 86, 77
153           jamonWriter.write(" \n          ago)</td>\n    </tr>\n    ");
154         }
155         // 89, 12
156         jamonWriter.write("\n    </table>\n\n  ");
157       }
158       // 92, 9
159       jamonWriter.write("\n");
160     }
161     // 93, 7
162     jamonWriter.write("\n");
163   }
164   
165   
166 }