001// Autogenerated Jamon implementation
002// /home/jenkins/jenkins-slave/workspace/hbase_generate_website/hbase/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 id=\"baseStatsTable\" class=\"tablesorter table table-striped\">\n    <thead>\n        <tr>\n            <th>Region Name</th>\n            <th>Start Key</th>\n            <th>End Key</th>\n            <th>ReplicaID</th>\n        </tr>\n    </thead>\n\n    <tbody>\n        ");
122    // 102, 9
123    for (RegionInfo r: onlineRegions )
124    {
125      // 102, 45
126      jamonWriter.write("\n        <tr>\n            ");
127      // 104, 13
128      
129             String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
130               regionServer.getConfiguration());
131            
132      // 108, 13
133      jamonWriter.write("<td><a href=\"region.jsp?name=");
134      // 108, 42
135      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
136      // 108, 66
137      jamonWriter.write("\">");
138      // 108, 68
139      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
140      // 108, 85
141      jamonWriter.write("</a></td>\n            <td>");
142      // 109, 17
143      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(Bytes.toStringBinary(RegionInfoDisplay.getStartKeyForDisplay(r,
144                                        regionServer.getConfiguration()))), jamonWriter);
145      // 110, 77
146      jamonWriter.write("</td>\n            <td>");
147      // 111, 17
148      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(Bytes.toStringBinary(RegionInfoDisplay.getEndKeyForDisplay(r,
149                                        regionServer.getConfiguration()))), jamonWriter);
150      // 112, 77
151      jamonWriter.write("</td>\n            <td>");
152      // 113, 17
153      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getReplicaId()), jamonWriter);
154      // 113, 39
155      jamonWriter.write("</td>\n        </tr>\n        ");
156    }
157    // 115, 16
158    jamonWriter.write("\n    </tbody>\n    </table>\n");
159  }
160  
161  
162  // 228, 1
163  private void __jamon_innerUnit__compactStats(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
164    throws java.io.IOException
165  {
166    // 232, 5
167    jamonWriter.write("<table id=\"compactionStatsTable\" class=\"tablesorter table table-striped\">\n    <thead>\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 data-date-format=\"yyyymmdd hhmm zz\">Last Major Compaction</th>\n        </tr>\n    </thead>\n\n    <tbody>\n        ");
168    // 244, 9
169    for (RegionInfo r: onlineRegions )
170    {
171      // 244, 45
172      jamonWriter.write("\n\n        <tr>\n        ");
173      // 247, 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      // 264, 13
192      jamonWriter.write("<td><a href=\"region.jsp?name=");
193      // 264, 42
194      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
195      // 264, 66
196      jamonWriter.write("\">");
197      // 264, 68
198      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
199      // 264, 85
200      jamonWriter.write("</a></td>\n            ");
201      // 265, 13
202      if (load != null )
203      {
204        // 265, 33
205        jamonWriter.write("\n            <td>");
206        // 266, 17
207        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(String.format("%,1d", load.getTotalCompactingKVs())), jamonWriter);
208        // 266, 74
209        jamonWriter.write("</td>\n            <td>");
210        // 267, 17
211        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(String.format("%,1d", load.getCurrentCompactedKVs())), jamonWriter);
212        // 267, 75
213        jamonWriter.write("</td>\n            <td>");
214        // 268, 17
215        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(percentDone), jamonWriter);
216        // 268, 34
217        jamonWriter.write("</td>\n            <td>");
218        // 269, 17
219        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(compactTime), jamonWriter);
220        // 269, 34
221        jamonWriter.write("</td>\n            ");
222      }
223      // 270, 19
224      jamonWriter.write("\n        </tr>\n        ");
225    }
226    // 272, 16
227    jamonWriter.write("\n    </tbody>\n    </table>\n");
228  }
229  
230  
231  // 277, 1
232  private void __jamon_innerUnit__memstoreStats(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
233    throws java.io.IOException
234  {
235    // 281, 5
236    jamonWriter.write("<table id=\"memstoreStatsTable\" class=\"tablesorter table table-striped\">\n    <thead>\n        <tr>\n            <th>Region Name</th>\n            <th>Memstore Size</th>\n        </tr>\n    </thead>\n\n    <tbody>\n        ");
237    // 290, 9
238    for (RegionInfo r: onlineRegions )
239    {
240      // 290, 45
241      jamonWriter.write("\n\n        <tr>\n        ");
242      // 293, 9
243      
244            final String ZEROMB = "0 MB";
245            String memStoreSizeMBStr = ZEROMB;
246            RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
247            String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
248              regionServer.getConfiguration());
249              if (load != null) {
250              long memStoreSizeMB = load.getMemStoreSizeMB();
251              if (memStoreSizeMB > 0) {
252              memStoreSizeMBStr = TraditionalBinaryPrefix.long2String(
253                         memStoreSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
254               }
255             }
256        
257      // 307, 13
258      jamonWriter.write("<td><a href=\"region.jsp?name=");
259      // 307, 42
260      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
261      // 307, 66
262      jamonWriter.write("\">");
263      // 307, 68
264      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
265      // 307, 85
266      jamonWriter.write("</a></td>\n            ");
267      // 308, 13
268      if (load != null )
269      {
270        // 308, 33
271        jamonWriter.write("\n            <td>");
272        // 309, 17
273        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(memStoreSizeMBStr), jamonWriter);
274        // 309, 40
275        jamonWriter.write("</td>\n            ");
276      }
277      // 310, 19
278      jamonWriter.write("\n        </tr>\n        ");
279    }
280    // 312, 16
281    jamonWriter.write("\n    </tbody>\n    </table>\n");
282  }
283  
284  
285  // 120, 1
286  private void __jamon_innerUnit__requestStats(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
287    throws java.io.IOException
288  {
289    // 124, 5
290    jamonWriter.write("<table id=\"requestStatsTable\" class=\"tablesorter table table-striped\">\n    <thead>\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    </thead>\n\n    <tbody>\n        ");
291    // 135, 9
292    for (RegionInfo r: onlineRegions )
293    {
294      // 135, 45
295      jamonWriter.write("\n\n        <tr>\n        ");
296      // 138, 9
297      
298            RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
299            String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
300              regionServer.getConfiguration());
301        
302      // 143, 13
303      jamonWriter.write("<td><a href=\"region.jsp?name=");
304      // 143, 42
305      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
306      // 143, 66
307      jamonWriter.write("\">");
308      // 143, 68
309      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
310      // 143, 85
311      jamonWriter.write("</a></td>\n            ");
312      // 144, 13
313      if (load != null )
314      {
315        // 144, 33
316        jamonWriter.write("\n            <td>");
317        // 145, 17
318        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(String.format("%,1d", load.getReadRequestsCount())), jamonWriter);
319        // 145, 73
320        jamonWriter.write("</td>\n            <td>");
321        // 146, 17
322        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(String.format("%,1d", load.getFilteredReadRequestsCount())), jamonWriter);
323        // 146, 81
324        jamonWriter.write("</td>\n            <td>");
325        // 147, 17
326        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(String.format("%,1d", load.getWriteRequestsCount())), jamonWriter);
327        // 147, 74
328        jamonWriter.write("</td>\n            ");
329      }
330      // 148, 19
331      jamonWriter.write("\n        </tr>\n        ");
332    }
333    // 150, 16
334    jamonWriter.write("\n    </tbody>\n    </table>\n");
335  }
336  
337  
338  // 156, 1
339  private void __jamon_innerUnit__storeStats(final java.io.Writer jamonWriter, final List<RegionInfo> onlineRegions)
340    throws java.io.IOException
341  {
342    // 160, 5
343    jamonWriter.write("<table id=\"storeStatsTable\" class=\"tablesorter table table-striped\">\n    <thead>\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    </thead>\n\n    <tbody>\n        ");
344    // 175, 9
345    for (RegionInfo r: onlineRegions )
346    {
347      // 175, 45
348      jamonWriter.write("\n\n        <tr>\n        ");
349      // 178, 9
350      
351            final String ZEROMB = "0 MB";
352            final String ZEROKB = "0 KB";
353            String uncompressedStorefileSizeStr = ZEROMB;
354            String storefileSizeStr = ZEROMB;
355            String indexSizeStr = ZEROKB;
356            String bloomSizeStr = ZEROKB;
357            RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
358            String displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(r,
359              regionServer.getConfiguration());
360             if (load != null) {
361             long uncompressedStorefileSize  = load.getStoreUncompressedSizeMB();
362             long storefileSize  = load.getStorefileSizeMB();
363             long indexSize  = load.getTotalStaticIndexSizeKB();
364             long bloomSize  = load.getTotalStaticBloomSizeKB();
365             if (uncompressedStorefileSize > 0) {
366                uncompressedStorefileSizeStr = TraditionalBinaryPrefix.long2String(
367                    uncompressedStorefileSize * TraditionalBinaryPrefix.MEGA.value, "B", 1);
368             }
369             if (storefileSize > 0) {
370                storefileSizeStr = TraditionalBinaryPrefix.long2String(storefileSize
371                             * TraditionalBinaryPrefix.MEGA.value, "B", 1);
372             }
373             if(indexSize > 0) {
374               indexSizeStr = TraditionalBinaryPrefix.long2String(indexSize
375                                              * TraditionalBinaryPrefix.KILO.value, "B", 1);
376             }
377             if (bloomSize > 0) {
378               bloomSizeStr = TraditionalBinaryPrefix.long2String(bloomSize
379                                              * TraditionalBinaryPrefix.KILO.value, "B", 1);
380              }
381           }
382        
383      // 211, 13
384      jamonWriter.write("<td><a href=\"region.jsp?name=");
385      // 211, 42
386      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(r.getEncodedName()), jamonWriter);
387      // 211, 66
388      jamonWriter.write("\">");
389      // 211, 68
390      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(displayName), jamonWriter);
391      // 211, 85
392      jamonWriter.write("</a></td>\n            ");
393      // 212, 13
394      if (load != null )
395      {
396        // 212, 33
397        jamonWriter.write("\n            <td>");
398        // 213, 17
399        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(String.format("%,1d", load.getStores())), jamonWriter);
400        // 213, 62
401        jamonWriter.write("</td>\n            <td>");
402        // 214, 17
403        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(String.format("%,1d", load.getStorefiles())), jamonWriter);
404        // 214, 66
405        jamonWriter.write("</td>\n            <td>");
406        // 215, 17
407        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(uncompressedStorefileSizeStr), jamonWriter);
408        // 215, 51
409        jamonWriter.write("</td>\n            <td>");
410        // 216, 17
411        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(storefileSizeStr), jamonWriter);
412        // 216, 39
413        jamonWriter.write("</td>\n            <td>");
414        // 217, 17
415        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(indexSizeStr), jamonWriter);
416        // 217, 35
417        jamonWriter.write("</td>\n            <td>");
418        // 218, 17
419        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(bloomSizeStr), jamonWriter);
420        // 218, 35
421        jamonWriter.write("</td>\n            <td>");
422        // 219, 17
423        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(load.getDataLocality()), jamonWriter);
424        // 219, 45
425        jamonWriter.write("</td>\n            ");
426      }
427      // 220, 19
428      jamonWriter.write("\n        </tr>\n        ");
429    }
430    // 222, 16
431    jamonWriter.write("\n    </tbody>\n    </table>\n");
432  }
433  
434  
435}