001// Autogenerated Jamon implementation 002// /Users/peter.somogyi/Cloudera/repos/hbase-upstream/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RegionServerListTmpl.jamon 003 004package org.apache.hadoop.hbase.tmpl.master; 005 006// 27, 9 007import java.util.*; 008// 28, 9 009import org.apache.hadoop.hbase.master.HMaster; 010// 29, 9 011import org.apache.hadoop.hbase.RegionMetrics; 012// 30, 9 013import org.apache.hadoop.hbase.ServerMetrics; 014// 31, 9 015import org.apache.hadoop.hbase.ServerName; 016// 32, 9 017import org.apache.hadoop.hbase.Size; 018// 33, 9 019import org.apache.hadoop.hbase.util.VersionInfo; 020// 34, 9 021import org.apache.hadoop.util.StringUtils.TraditionalBinaryPrefix; 022 023public class RegionServerListTmplImpl 024 extends org.jamon.AbstractTemplateImpl 025 implements org.apache.hadoop.hbase.tmpl.master.RegionServerListTmpl.Intf 026 027{ 028 private final HMaster master; 029 private final List<ServerName> servers; 030 protected static org.apache.hadoop.hbase.tmpl.master.RegionServerListTmpl.ImplData __jamon_setOptionalArguments(org.apache.hadoop.hbase.tmpl.master.RegionServerListTmpl.ImplData p_implData) 031 { 032 if(! p_implData.getServers__IsNotDefault()) 033 { 034 p_implData.setServers(null); 035 } 036 return p_implData; 037 } 038 public RegionServerListTmplImpl(org.jamon.TemplateManager p_templateManager, org.apache.hadoop.hbase.tmpl.master.RegionServerListTmpl.ImplData p_implData) 039 { 040 super(p_templateManager, __jamon_setOptionalArguments(p_implData)); 041 master = p_implData.getMaster(); 042 servers = p_implData.getServers(); 043 } 044 045 @Override public void renderNoFlush(final java.io.Writer jamonWriter) 046 throws java.io.IOException 047 { 048 // 38, 1 049 if ((servers != null && servers.size() > 0)) 050 { 051 // 38, 47 052 jamonWriter.write("\n\n"); 053 // 40, 1 054 055ServerName [] serverNames = servers.toArray(new ServerName[servers.size()]); 056Arrays.sort(serverNames); 057 058 // 45, 1 059 jamonWriter.write("<div class=\"tabbable\">\n <ul class=\"nav nav-pills\">\n <li class=\"active\"><a href=\"#tab_baseStats\" data-toggle=\"tab\">Base Stats</a></li>\n <li class=\"\"><a href=\"#tab_memoryStats\" data-toggle=\"tab\">Memory</a></li>\n <li class=\"\"><a href=\"#tab_requestStats\" data-toggle=\"tab\">Requests</a></li>\n <li class=\"\"><a href=\"#tab_storeStats\" data-toggle=\"tab\">Storefiles</a></li>\n <li class=\"\"><a href=\"#tab_compactStas\" data-toggle=\"tab\">Compactions</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_baseStats\">\n "); 060 // 55, 13 061 { 062 // 55, 13 063 __jamon_innerUnit__baseStats(jamonWriter, serverNames); 064 } 065 // 55, 56 066 jamonWriter.write("\n </div>\n <div class=\"tab-pane\" id=\"tab_memoryStats\">\n "); 067 // 58, 13 068 { 069 // 58, 13 070 __jamon_innerUnit__memoryStats(jamonWriter, serverNames); 071 } 072 // 58, 58 073 jamonWriter.write("\n </div>\n <div class=\"tab-pane\" id=\"tab_requestStats\">\n "); 074 // 61, 13 075 { 076 // 61, 13 077 __jamon_innerUnit__requestStats(jamonWriter, serverNames); 078 } 079 // 61, 59 080 jamonWriter.write("\n </div>\n <div class=\"tab-pane\" id=\"tab_storeStats\">\n "); 081 // 64, 13 082 { 083 // 64, 13 084 __jamon_innerUnit__storeStats(jamonWriter, serverNames); 085 } 086 // 64, 57 087 jamonWriter.write("\n </div>\n <div class=\"tab-pane\" id=\"tab_compactStas\">\n "); 088 // 67, 13 089 { 090 // 67, 13 091 __jamon_innerUnit__compactionStats(jamonWriter, serverNames); 092 } 093 // 67, 62 094 jamonWriter.write("\n </div>\n </div>\n</div>\n\n"); 095 } 096 // 72, 7 097 jamonWriter.write("\n\n"); 098 } 099 100 101 // 74, 1 102 private void __jamon_innerUnit__baseStats(final java.io.Writer jamonWriter, final ServerName[] serverNames) 103 throws java.io.IOException 104 { 105 // 78, 1 106 jamonWriter.write("<table class=\"table table-striped\">\n<tr>\n <th>ServerName</th>\n <th>Start time</th>\n <th>Last contact</th>\n <th>Version</th>\n <th>Requests Per Second</th>\n <th>Num. Regions</th>\n</tr>\n"); 107 // 87, 1 108 109 int totalRegions = 0; 110 int totalRequestsPerSecond = 0; 111 int inconsistentNodeNum = 0; 112 String masterVersion = VersionInfo.getVersion(); 113 for (ServerName serverName: serverNames) { 114 115 ServerMetrics sl = master.getServerManager().getLoad(serverName); 116 String version = master.getRegionServerVersion(serverName); 117 if (!masterVersion.equals(version)) { 118 inconsistentNodeNum ++; 119 } 120 121 double requestsPerSecond = 0.0; 122 int numRegionsOnline = 0; 123 long lastContact = 0; 124 125 if (sl != null) { 126 requestsPerSecond = sl.getRequestCountPerSecond(); 127 numRegionsOnline = sl.getRegionMetrics().size(); 128 totalRegions += sl.getRegionMetrics().size(); 129 totalRequestsPerSecond += sl.getRequestCountPerSecond(); 130 lastContact = (System.currentTimeMillis() - sl.getReportTimestamp())/1000; 131 } 132 long startcode = serverName.getStartcode(); 133 134 // 113, 1 135 jamonWriter.write("<tr>\n <td>"); 136 // 114, 9 137 { 138 // 114, 9 139 __jamon_innerUnit__serverNameLink(jamonWriter, serverName, sl); 140 } 141 // 114, 70 142 jamonWriter.write("</td>\n <td>"); 143 // 115, 9 144 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(new Date(startcode)), jamonWriter); 145 // 115, 34 146 jamonWriter.write("</td>\n <td>"); 147 // 116, 9 148 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(lastContact, "s", 1)), jamonWriter); 149 // 116, 71 150 jamonWriter.write("</td>\n <td>"); 151 // 117, 9 152 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(version), jamonWriter); 153 // 117, 22 154 jamonWriter.write("</td>\n <td>"); 155 // 118, 9 156 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(String.format("%.0f", requestsPerSecond)), jamonWriter); 157 // 118, 55 158 jamonWriter.write("</td>\n <td>"); 159 // 119, 9 160 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numRegionsOnline), jamonWriter); 161 // 119, 31 162 jamonWriter.write("</td>\n</tr>\n"); 163 // 121, 1 164 165} 166 167 // 124, 1 168 jamonWriter.write("<tr><td>Total:"); 169 // 124, 15 170 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(servers.size()), jamonWriter); 171 // 124, 35 172 jamonWriter.write("</td>\n<td></td>\n<td></td>\n"); 173 // 127, 1 174 if (inconsistentNodeNum > 0) 175 { 176 // 127, 31 177 jamonWriter.write("\n <td style=\"color:red;\">"); 178 // 128, 26 179 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(inconsistentNodeNum), jamonWriter); 180 // 128, 51 181 jamonWriter.write(" nodes with inconsistent version</td>\n"); 182 } 183 // 129, 1 184 else 185 { 186 // 129, 8 187 jamonWriter.write("\n <td></td>\n"); 188 } 189 // 131, 7 190 jamonWriter.write("\n<td>"); 191 // 132, 5 192 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(totalRequestsPerSecond), jamonWriter); 193 // 132, 33 194 jamonWriter.write("</td>\n<td>"); 195 // 133, 5 196 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(totalRegions), jamonWriter); 197 // 133, 23 198 jamonWriter.write("</td>\n</tr>\n</table>\n"); 199 } 200 201 202 // 285, 1 203 private void __jamon_innerUnit__compactionStats(final java.io.Writer jamonWriter, final ServerName[] serverNames) 204 throws java.io.IOException 205 { 206 // 289, 1 207 jamonWriter.write("<table class=\"table table-striped\">\n<tr>\n <th>ServerName</th>\n <th>Num. Compacting Cells</th>\n <th>Num. Compacted Cells</th>\n <th>Remaining Cells</th>\n <th>Compaction Progress</th>\n</tr>\n"); 208 // 297, 1 209 210for (ServerName serverName: serverNames) { 211 212ServerMetrics sl = master.getServerManager().getLoad(serverName); 213if (sl != null) { 214long totalCompactingCells = 0; 215long totalCompactedCells = 0; 216for (RegionMetrics rl : sl.getRegionMetrics().values()) { 217 totalCompactingCells += rl.getCompactingCellCount(); 218 totalCompactedCells += rl.getCompactedCellCount(); 219} 220String percentDone = ""; 221if (totalCompactingCells > 0) { 222 percentDone = String.format("%.2f", 100 * 223 ((float) totalCompactedCells / totalCompactingCells)) + "%"; 224} 225 226 // 314, 1 227 jamonWriter.write("<tr>\n<td>"); 228 // 315, 5 229 { 230 // 315, 5 231 __jamon_innerUnit__serverNameLink(jamonWriter, serverName, sl); 232 } 233 // 315, 66 234 jamonWriter.write("</td>\n<td>"); 235 // 316, 5 236 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(totalCompactingCells), jamonWriter); 237 // 316, 31 238 jamonWriter.write("</td>\n<td>"); 239 // 317, 5 240 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(totalCompactedCells), jamonWriter); 241 // 317, 30 242 jamonWriter.write("</td>\n<td>"); 243 // 318, 5 244 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(totalCompactingCells - totalCompactedCells), jamonWriter); 245 // 318, 53 246 jamonWriter.write("</td>\n<td>"); 247 // 319, 5 248 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(percentDone), jamonWriter); 249 // 319, 22 250 jamonWriter.write("</td>\n</tr>\n"); 251 // 321, 1 252 253 } else { 254 255 // 324, 1 256 { 257 // 324, 1 258 __jamon_innerUnit__emptyStat(jamonWriter, serverName); 259 } 260 // 324, 40 261 jamonWriter.write("\n"); 262 // 325, 1 263 264 } 265} 266 267 // 329, 1 268 jamonWriter.write("</table>\n"); 269 } 270 271 272 // 350, 1 273 private void __jamon_innerUnit__emptyStat(final java.io.Writer jamonWriter, final ServerName serverName) 274 throws java.io.IOException 275 { 276 // 354, 5 277 jamonWriter.write("<tr>\n <td>"); 278 // 355, 9 279 { 280 // 355, 9 281 __jamon_innerUnit__serverNameLink(jamonWriter, serverName, null); 282 } 283 // 355, 72 284 jamonWriter.write("</td>\n <td></td>\n <td></td>\n <td></td>\n <td></td>\n <td></td>\n <td></td>\n </tr>\n"); 285 } 286 287 288 // 138, 1 289 private void __jamon_innerUnit__memoryStats(final java.io.Writer jamonWriter, final ServerName[] serverNames) 290 throws java.io.IOException 291 { 292 // 142, 1 293 jamonWriter.write("<table class=\"table table-striped\">\n<tr>\n <th>ServerName</th>\n <th>Used Heap</th>\n <th>Max Heap</th>\n <th>Memstore Size</th>\n\n</tr>\n"); 294 // 150, 1 295 296for (ServerName serverName: serverNames) { 297 298 ServerMetrics sl = master.getServerManager().getLoad(serverName); 299 if (sl != null) { 300 long memStoreSizeMB = 0; 301 for (RegionMetrics rl : sl.getRegionMetrics().values()) { 302 memStoreSizeMB += rl.getMemStoreSize().get(Size.Unit.MEGABYTE); 303 } 304 305 // 160, 1 306 jamonWriter.write("<tr>\n <td>"); 307 // 161, 9 308 { 309 // 161, 9 310 __jamon_innerUnit__serverNameLink(jamonWriter, serverName, sl); 311 } 312 // 161, 70 313 jamonWriter.write("</td>\n <td>"); 314 // 162, 9 315 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String((long) sl.getUsedHeapSize().get(Size.Unit.MEGABYTE) 316 * TraditionalBinaryPrefix.MEGA.value, "B", 1)), jamonWriter); 317 // 163, 55 318 jamonWriter.write("</td>\n <td>"); 319 // 164, 9 320 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String((long) sl.getMaxHeapSize().get(Size.Unit.MEGABYTE) 321 * TraditionalBinaryPrefix.MEGA.value, "B", 1)), jamonWriter); 322 // 165, 55 323 jamonWriter.write("</td>\n <td>"); 324 // 166, 9 325 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(memStoreSizeMB 326 * TraditionalBinaryPrefix.MEGA.value, "B", 1)), jamonWriter); 327 // 167, 55 328 jamonWriter.write("</td>\n\n</tr>\n"); 329 // 170, 1 330 331 } else { 332 333 // 173, 1 334 { 335 // 173, 1 336 __jamon_innerUnit__emptyStat(jamonWriter, serverName); 337 } 338 // 173, 40 339 jamonWriter.write("\n"); 340 // 174, 1 341 342 } 343} 344 345 // 178, 1 346 jamonWriter.write("</table>\n"); 347 } 348 349 350 // 182, 1 351 private void __jamon_innerUnit__requestStats(final java.io.Writer jamonWriter, final ServerName[] serverNames) 352 throws java.io.IOException 353 { 354 // 186, 1 355 jamonWriter.write("<table class=\"table table-striped\">\n<tr>\n <th>ServerName</th>\n <th>Request Per Second</th>\n <th>Read Request Count</th>\n <th>Filtered Read Request Count</th>\n <th>Write Request Count</th>\n</tr>\n"); 356 // 194, 1 357 358for (ServerName serverName: serverNames) { 359 360ServerMetrics sl = master.getServerManager().getLoad(serverName); 361if (sl != null) { 362 long readRequestCount = 0; 363 long writeRequestCount = 0; 364 long filteredReadRequestCount = 0; 365 for (RegionMetrics rl : sl.getRegionMetrics().values()) { 366 readRequestCount += rl.getReadRequestCount(); 367 writeRequestCount += rl.getWriteRequestCount(); 368 filteredReadRequestCount += rl.getFilteredReadRequestCount(); 369 } 370 371 // 208, 1 372 jamonWriter.write("<tr>\n<td>"); 373 // 209, 5 374 { 375 // 209, 5 376 __jamon_innerUnit__serverNameLink(jamonWriter, serverName, sl); 377 } 378 // 209, 66 379 jamonWriter.write("</td>\n<td>"); 380 // 210, 5 381 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(sl.getRequestCountPerSecond()), jamonWriter); 382 // 210, 40 383 jamonWriter.write("</td>\n<td>"); 384 // 211, 5 385 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(readRequestCount), jamonWriter); 386 // 211, 27 387 jamonWriter.write("</td>\n<td>"); 388 // 212, 5 389 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(filteredReadRequestCount), jamonWriter); 390 // 212, 35 391 jamonWriter.write("</td>\n<td>"); 392 // 213, 5 393 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(writeRequestCount), jamonWriter); 394 // 213, 28 395 jamonWriter.write("</td>\n</tr>\n"); 396 // 215, 1 397 398 } else { 399 400 // 218, 1 401 { 402 // 218, 1 403 __jamon_innerUnit__emptyStat(jamonWriter, serverName); 404 } 405 // 218, 40 406 jamonWriter.write("\n"); 407 // 219, 1 408 409 } 410} 411 412 // 223, 1 413 jamonWriter.write("</table>\n"); 414 } 415 416 417 // 333, 1 418 private void __jamon_innerUnit__serverNameLink(final java.io.Writer jamonWriter, final ServerName serverName, final ServerMetrics serverLoad) 419 throws java.io.IOException 420 { 421 // 338, 9 422 423 int infoPort = master.getRegionServerInfoPort(serverName); 424 String url = "//" + serverName.getHostname() + ":" + infoPort + "/rs-status"; 425 426 // 343, 9 427 if (infoPort > 0) 428 { 429 // 343, 28 430 jamonWriter.write("\n <a href=\""); 431 // 344, 22 432 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(url), jamonWriter); 433 // 344, 31 434 jamonWriter.write("\">"); 435 // 344, 33 436 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(serverName.getServerName()), jamonWriter); 437 // 344, 65 438 jamonWriter.write("</a>\n "); 439 } 440 // 345, 9 441 else 442 { 443 // 345, 16 444 jamonWriter.write("\n "); 445 // 346, 13 446 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(serverName.getServerName()), jamonWriter); 447 // 346, 45 448 jamonWriter.write("\n "); 449 } 450 // 347, 15 451 jamonWriter.write("\n"); 452 } 453 454 455 // 227, 1 456 private void __jamon_innerUnit__storeStats(final java.io.Writer jamonWriter, final ServerName[] serverNames) 457 throws java.io.IOException 458 { 459 // 231, 1 460 jamonWriter.write("<table class=\"table table-striped\">\n<tr>\n <th>ServerName</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</tr>\n"); 461 // 241, 1 462 463for (ServerName serverName: serverNames) { 464 465ServerMetrics sl = master.getServerManager().getLoad(serverName); 466if (sl != null) { 467 long storeCount = 0; 468 long storeFileCount = 0; 469 long storeUncompressedSizeMB = 0; 470 long storeFileSizeMB = 0; 471 long totalStaticIndexSizeKB = 0; 472 long totalStaticBloomSizeKB = 0; 473 for (RegionMetrics rl : sl.getRegionMetrics().values()) { 474 storeCount += rl.getStoreCount(); 475 storeFileCount += rl.getStoreFileCount(); 476 storeUncompressedSizeMB += rl.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE); 477 storeFileSizeMB += rl.getStoreFileSize().get(Size.Unit.MEGABYTE); 478 totalStaticIndexSizeKB += rl.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE); 479 totalStaticBloomSizeKB += rl.getBloomFilterSize().get(Size.Unit.KILOBYTE); 480 } 481 482 // 261, 1 483 jamonWriter.write("<tr>\n<td>"); 484 // 262, 5 485 { 486 // 262, 5 487 __jamon_innerUnit__serverNameLink(jamonWriter, serverName, sl); 488 } 489 // 262, 66 490 jamonWriter.write("</td>\n<td>"); 491 // 263, 5 492 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(storeCount), jamonWriter); 493 // 263, 21 494 jamonWriter.write("</td>\n<td>"); 495 // 264, 5 496 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(storeFileCount), jamonWriter); 497 // 264, 25 498 jamonWriter.write("</td>\n<td>"); 499 // 265, 5 500 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String( 501 storeUncompressedSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1)), jamonWriter); 502 // 266, 75 503 jamonWriter.write("</td>\n<td>"); 504 // 267, 5 505 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(storeFileSizeMB 506 * TraditionalBinaryPrefix.MEGA.value, "B", 1)), jamonWriter); 507 // 268, 51 508 jamonWriter.write("</td>\n<td>"); 509 // 269, 5 510 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(totalStaticIndexSizeKB 511 * TraditionalBinaryPrefix.KILO.value, "B", 1)), jamonWriter); 512 // 270, 51 513 jamonWriter.write("</td>\n<td>"); 514 // 271, 5 515 org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(TraditionalBinaryPrefix.long2String(totalStaticBloomSizeKB 516 * TraditionalBinaryPrefix.KILO.value, "B", 1)), jamonWriter); 517 // 272, 51 518 jamonWriter.write("</td>\n</tr>\n"); 519 // 274, 1 520 521 } else { 522 523 // 277, 1 524 { 525 // 277, 1 526 __jamon_innerUnit__emptyStat(jamonWriter, serverName); 527 } 528 // 277, 40 529 jamonWriter.write("\n"); 530 // 278, 1 531 532 } 533} 534 535 // 282, 1 536 jamonWriter.write("</table>\n"); 537 } 538 539 540}