001// Autogenerated Jamon implementation
002// /Users/peter.somogyi/Cloudera/repos/hbase-upstream/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
003
004package org.apache.hadoop.hbase.tmpl.regionserver;
005
006// 24, 9
007import java.util.*;
008// 25, 9
009import org.apache.commons.lang3.time.FastDateFormat;
010// 26, 9
011import org.apache.hadoop.hbase.regionserver.HRegionServer;
012// 27, 9
013import org.apache.hadoop.hbase.util.Bytes;
014// 28, 9
015import org.apache.hadoop.hbase.client.RegionInfo;
016// 29, 9
017import org.apache.hadoop.hbase.client.RegionInfoDisplay;
018// 30, 9
019import org.apache.hadoop.hbase.regionserver.Region;
020// 31, 9
021import org.apache.hadoop.hbase.ServerName;
022// 32, 9
023import org.apache.hadoop.hbase.HBaseConfiguration;
024// 33, 9
025import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
026// 34, 9
027import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ServerInfo;
028// 35, 9
029import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad;
030// 36, 9
031import org.apache.hadoop.hbase.client.RegionReplicaUtil;
032// 37, 9
033import org.apache.hadoop.hbase.regionserver.MetricsRegionWrapper;
034// 38, 9
035import org.apache.hadoop.util.StringUtils.TraditionalBinaryPrefix;
036
037public class RegionListTmplImpl
038  extends org.jamon.AbstractTemplateImpl
039  implements org.apache.hadoop.hbase.tmpl.regionserver.RegionListTmpl.Intf
040
041{
042  private final HRegionServer regionServer;
043  private final List<RegionInfo> onlineRegions;
044  protected static org.apache.hadoop.hbase.tmpl.regionserver.RegionListTmpl.ImplData __jamon_setOptionalArguments(org.apache.hadoop.hbase.tmpl.regionserver.RegionListTmpl.ImplData p_implData)
045  {
046    return p_implData;
047  }
048  public RegionListTmplImpl(org.jamon.TemplateManager p_templateManager, org.apache.hadoop.hbase.tmpl.regionserver.RegionListTmpl.ImplData p_implData)
049  {
050    super(p_templateManager, __jamon_setOptionalArguments(p_implData));
051    regionServer = p_implData.getRegionServer();
052    onlineRegions = p_implData.getOnlineRegions();
053  }
054  
055  @Override public void renderNoFlush(final java.io.Writer jamonWriter)
056    throws java.io.IOException
057  {
058    // 40, 1
059    if ((onlineRegions != null && onlineRegions.size() > 0) )
060    {
061      // 40, 60
062      jamonWriter.write("\n\n    ");
063      // 42, 5
064      
065        Collections.sort(onlineRegions, RegionInfo.COMPARATOR);
066    
067      // 46, 5
068      jamonWriter.write("<div class=\"tabbable\">\n        <ul class=\"nav nav-pills\">\n            <li class=\"active\"><a href=\"#tab_regionBaseInfo\" data-toggle=\"tab\">Base Info</a> </li>\n            <li><a href=\"#tab_regionRequestStats\" data-toggle=\"tab\">Request metrics</a></li>\n            <li class=\"\"><a href=\"#tab_regionStoreStats\" data-toggle=\"tab\">Storefile Metrics</a></li>\n            <li class=\"\"><a href=\"#tab_regionMemstoreStats\" data-toggle=\"tab\">Memstore Metrics</a></li>\n            <li class=\"\"><a href=\"#tab_regionCompactStats\" data-toggle=\"tab\">Compaction Metrics</a></li>\n        </ul>\n        <div class=\"tab-content\" style=\"padding-bottom: 9px; border-bottom: 1px solid #ddd;\">\n            <div class=\"tab-pane active\" id=\"tab_regionBaseInfo\">\n                ");
069      // 56, 17
070      {
071        // 56, 17
072        __jamon_innerUnit__baseInfo(jamonWriter, onlineRegions);
073      }
074      // 56, 63
075      jamonWriter.write("\n            </div>\n            <div class=\"tab-pane\" id=\"tab_regionRequestStats\">\n                ");
076      // 59, 17
077      {
078        // 59, 17
079        __jamon_innerUnit__requestStats(jamonWriter, onlineRegions);
080      }
081      // 59, 67
082      jamonWriter.write("\n            </div>\n            <div class=\"tab-pane\" id=\"tab_regionStoreStats\">\n                ");
083      // 62, 17
084      {
085        // 62, 17
086        __jamon_innerUnit__storeStats(jamonWriter, onlineRegions);
087      }
088      // 62, 65
089      jamonWriter.write("\n            </div>\n            <div class=\"tab-pane\" id=\"tab_regionMemstoreStats\">\n                ");
090      // 65, 17
091      {
092        // 65, 17
093        __jamon_innerUnit__memstoreStats(jamonWriter, onlineRegions);
094      }
095      // 65, 68
096      jamonWriter.write("\n            </div>\n            <div class=\"tab-pane\" id=\"tab_regionCompactStats\">\n                ");
097      // 68, 17
098      {
099        // 68, 17
100        __jamon_innerUnit__compactStats(jamonWriter, onlineRegions);
101      }
102      // 68, 67
103      jamonWriter.write("\n            </div>\n        </div>\n    </div>\n    <p>Region names are made of the containing table's name, a comma,\n    the start key, a comma, and a randomly generated region id.  To illustrate,\n    the region named\n    <em>domains,apache.org,5464829424211263407</em> is party to the table\n    <em>domains</em>, has an id of <em>5464829424211263407</em> and the first key\n    in the region is <em>apache.org</em>.  The <em>hbase:meta</em> 'table' is an internal\n    system table (or a 'catalog' table in db-speak).\n    The hbase:meta table keeps a list of all regions in the system. The empty key is used to denote\n    table start and table end.  A region with an empty start key is the first region in a table.\n    If a region has both an empty start key and an empty end key, it's the only region in the\n    table. See <a href=\"http://hbase.apache.org\">HBase Home</a> for further explication.<p>\n");
104    }
105    // 83, 1
106    else
107    {
108      // 83, 8
109      jamonWriter.write("\n    <p>Not serving regions</p>\n");
110    }
111    // 85, 7
112    jamonWriter.write("\n\n");
113  }
114  
115  
116  // 87, 1
117  private void __jamon_innerUnit__baseInfo(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
118    throws java.io.IOException
119  {
120    // 91, 5
121    jamonWriter.write("<table class=\"table table-striped\">\n        <tr>\n            <th>Region Name</th>\n            <th>Start Key</th>\n            <th>End Key</th>\n            <th>ReplicaID</th>\n        </tr>\n\n        ");
122    // 99, 9
123    for (RegionInfo r: onlineRegions )
124    {
125      // 99, 45
126      jamonWriter.write("\n        <tr>\n            ");
127      // 101, 13
128      
129             String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
130               regionServer.getConfiguration());
131            
132      // 105, 13
133      jamonWriter.write("<td><a href=\"region.jsp?name=");
134      // 105, 42
135      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
136      // 105, 66
137      jamonWriter.write("\">");
138      // 105, 68
139      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
140      // 105, 85
141      jamonWriter.write("</a></td>\n            <td>");
142      // 106, 17
143      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(Bytes.toStringBinary(RegionInfoDisplay.getStartKeyForDisplay(r,
144                                        regionServer.getConfiguration()))), jamonWriter);
145      // 107, 77
146      jamonWriter.write("</td>\n            <td>");
147      // 108, 17
148      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(Bytes.toStringBinary(RegionInfoDisplay.getEndKeyForDisplay(r,
149                                        regionServer.getConfiguration()))), jamonWriter);
150      // 109, 77
151      jamonWriter.write("</td>\n            <td>");
152      // 110, 17
153      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getReplicaId()), jamonWriter);
154      // 110, 39
155      jamonWriter.write("</td>\n        </tr>\n        ");
156    }
157    // 112, 16
158    jamonWriter.write("\n    </table>\n");
159  }
160  
161  
162  // 192, 1
163  private void __jamon_innerUnit__compactStats(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
164    throws java.io.IOException
165  {
166    // 196, 5
167    jamonWriter.write("<table class=\"table table-striped\">\n        <tr>\n            <th>Region Name</th>\n            <th>Num. Compacting Cells</th>\n            <th>Num. Compacted Cells</th>\n            <th>Compaction Progress</th>\n            <th>Last Major Compaction</th>\n        </tr>\n\n        ");
168    // 205, 9
169    for (RegionInfo r: onlineRegions )
170    {
171      // 205, 45
172      jamonWriter.write("\n\n        <tr>\n        ");
173      // 208, 9
174      
175            RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
176            String percentDone = "";
177            String compactTime = "";
178            if  (load != null) {
179              if (load.getTotalCompactingKVs() > 0) {
180                percentDone = String.format("%.2f", 100 *
181                    ((float) load.getCurrentCompactedKVs() / load.getTotalCompactingKVs())) + "%";
182              }
183              if (load.getLastMajorCompactionTs() > 0) {
184                FastDateFormat fdf = FastDateFormat.getInstance("yyyy-MM-dd HH:mm ZZ");
185                compactTime = fdf.format(load.getLastMajorCompactionTs());
186              }
187            }
188            String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
189              regionServer.getConfiguration());
190        
191      // 225, 13
192      jamonWriter.write("<td><a href=\"region.jsp?name=");
193      // 225, 42
194      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
195      // 225, 66
196      jamonWriter.write("\">");
197      // 225, 68
198      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
199      // 225, 85
200      jamonWriter.write("</a></td>\n            ");
201      // 226, 13
202      if (load != null )
203      {
204        // 226, 33
205        jamonWriter.write("\n            <td>");
206        // 227, 17
207        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getTotalCompactingKVs()), jamonWriter);
208        // 227, 51
209        jamonWriter.write("</td>\n            <td>");
210        // 228, 17
211        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getCurrentCompactedKVs()), jamonWriter);
212        // 228, 52
213        jamonWriter.write("</td>\n            <td>");
214        // 229, 17
215        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(percentDone), jamonWriter);
216        // 229, 34
217        jamonWriter.write("</td>\n            <td>");
218        // 230, 17
219        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(compactTime), jamonWriter);
220        // 230, 34
221        jamonWriter.write("</td>\n            ");
222      }
223      // 231, 19
224      jamonWriter.write("\n        </tr>\n        ");
225    }
226    // 233, 16
227    jamonWriter.write("\n    </table>\n");
228  }
229  
230  
231  // 237, 1
232  private void __jamon_innerUnit__memstoreStats(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
233    throws java.io.IOException
234  {
235    // 241, 5
236    jamonWriter.write("<table class=\"table table-striped\">\n        <tr>\n            <th>Region Name</th>\n            <th>Memstore Size</th>\n        </tr>\n\n        ");
237    // 247, 9
238    for (RegionInfo r: onlineRegions )
239    {
240      // 247, 45
241      jamonWriter.write("\n\n        <tr>\n        ");
242      // 250, 9
243      
244            RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
245            String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
246              regionServer.getConfiguration());
247        
248      // 255, 13
249      jamonWriter.write("<td><a href=\"region.jsp?name=");
250      // 255, 42
251      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
252      // 255, 66
253      jamonWriter.write("\">");
254      // 255, 68
255      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
256      // 255, 85
257      jamonWriter.write("</a></td>\n            ");
258      // 256, 13
259      if (load != null )
260      {
261        // 256, 33
262        jamonWriter.write("\n            <td>");
263        // 257, 17
264        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(
265                load.getMemStoreSizeMB() * TraditionalBinaryPrefix.MEGA.value, "B", 1)), jamonWriter);
266        // 258, 90
267        jamonWriter.write("</td>\n            ");
268      }
269      // 259, 19
270      jamonWriter.write("\n        </tr>\n        ");
271    }
272    // 261, 16
273    jamonWriter.write("\n    </table>\n");
274  }
275  
276  
277  // 116, 1
278  private void __jamon_innerUnit__requestStats(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
279    throws java.io.IOException
280  {
281    // 120, 5
282    jamonWriter.write("<table class=\"table table-striped\">\n        <tr>\n            <th>Region Name</th>\n            <th>Read Request Count</th>\n            <th>Filtered Read Request Count</th>\n            <th>Write Request Count</th>\n        </tr>\n\n        ");
283    // 128, 9
284    for (RegionInfo r: onlineRegions )
285    {
286      // 128, 45
287      jamonWriter.write("\n\n        <tr>\n        ");
288      // 131, 9
289      
290            RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
291            String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
292              regionServer.getConfiguration());
293        
294      // 136, 13
295      jamonWriter.write("<td><a href=\"region.jsp?name=");
296      // 136, 42
297      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
298      // 136, 66
299      jamonWriter.write("\">");
300      // 136, 68
301      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
302      // 136, 85
303      jamonWriter.write("</a></td>\n            ");
304      // 137, 13
305      if (load != null )
306      {
307        // 137, 33
308        jamonWriter.write("\n            <td>");
309        // 138, 17
310        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getReadRequestsCount()), jamonWriter);
311        // 138, 50
312        jamonWriter.write("</td>\n            <td>");
313        // 139, 17
314        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getFilteredReadRequestsCount()), jamonWriter);
315        // 139, 58
316        jamonWriter.write("</td>\n            <td>");
317        // 140, 17
318        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getWriteRequestsCount()), jamonWriter);
319        // 140, 51
320        jamonWriter.write("</td>\n            ");
321      }
322      // 141, 19
323      jamonWriter.write("\n        </tr>\n        ");
324    }
325    // 143, 16
326    jamonWriter.write("\n    </table>\n");
327  }
328  
329  
330  // 148, 1
331  private void __jamon_innerUnit__storeStats(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
332    throws java.io.IOException
333  {
334    // 152, 5
335    jamonWriter.write("<table class=\"table table-striped\">\n        <tr>\n            <th>Region Name</th>\n            <th>Num. Stores</th>\n            <th>Num. Storefiles</th>\n            <th>Storefile Size Uncompressed</th>\n            <th>Storefile Size</th>\n            <th>Index Size</th>\n            <th>Bloom Size</th>\n            <th>Data Locality</th>\n        </tr>\n\n        ");
336    // 164, 9
337    for (RegionInfo r: onlineRegions )
338    {
339      // 164, 45
340      jamonWriter.write("\n\n        <tr>\n        ");
341      // 167, 9
342      
343            RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
344            String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
345              regionServer.getConfiguration());
346        
347      // 172, 13
348      jamonWriter.write("<td><a href=\"region.jsp?name=");
349      // 172, 42
350      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
351      // 172, 66
352      jamonWriter.write("\">");
353      // 172, 68
354      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
355      // 172, 85
356      jamonWriter.write("</a></td>\n            ");
357      // 173, 13
358      if (load != null )
359      {
360        // 173, 33
361        jamonWriter.write("\n            <td>");
362        // 174, 17
363        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getStores()), jamonWriter);
364        // 174, 39
365        jamonWriter.write("</td>\n            <td>");
366        // 175, 17
367        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getStorefiles()), jamonWriter);
368        // 175, 43
369        jamonWriter.write("</td>\n            <td>");
370        // 176, 17
371        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(load.getStoreUncompressedSizeMB()
372                * TraditionalBinaryPrefix.MEGA.value, "B", 1)), jamonWriter);
373        // 177, 64
374        jamonWriter.write("</td>\n            <td>");
375        // 178, 17
376        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(load.getStorefileSizeMB()
377                * TraditionalBinaryPrefix.MEGA.value, "B", 1)), jamonWriter);
378        // 179, 65
379        jamonWriter.write("</td>\n            <td>");
380        // 180, 17
381        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(load.getTotalStaticIndexSizeKB()
382                * TraditionalBinaryPrefix.KILO.value, "B", 1)), jamonWriter);
383        // 181, 65
384        jamonWriter.write("</td>\n            <td>");
385        // 182, 17
386        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(load.getTotalStaticBloomSizeKB()
387                * TraditionalBinaryPrefix.KILO.value, "B", 1)), jamonWriter);
388        // 183, 65
389        jamonWriter.write("</td>\n            <td>");
390        // 184, 17
391        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getDataLocality()), jamonWriter);
392        // 184, 45
393        jamonWriter.write("</td>\n            ");
394      }
395      // 185, 19
396      jamonWriter.write("\n        </tr>\n        ");
397    }
398    // 187, 16
399    jamonWriter.write("\n    </table>\n");
400  }
401  
402  
403}