View Javadoc

1   // Autogenerated Jamon implementation
2   // /Users/stack/checkouts/hbase.git.commit/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
3   
4   package org.apache.hadoop.hbase.tmpl.master;
5   
6   // 20, 1
7   import org.apache.hadoop.hbase.HRegionInfo;
8   // 21, 1
9   import org.apache.hadoop.hbase.master.AssignmentManager;
10  // 22, 1
11  import org.apache.hadoop.hbase.master.RegionState;
12  // 23, 1
13  import org.apache.hadoop.conf.Configuration;
14  // 24, 1
15  import org.apache.hadoop.hbase.HBaseConfiguration;
16  // 25, 1
17  import org.apache.hadoop.hbase.HConstants;
18  // 26, 1
19  import java.util.Iterator;
20  // 27, 1
21  import java.util.Map;
22  
23  public class AssignmentManagerStatusTmplImpl
24    extends org.jamon.AbstractTemplateImpl
25    implements org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.Intf
26  
27  {
28    private final AssignmentManager assignmentManager;
29    private final int limit;
30    protected static org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData __jamon_setOptionalArguments(org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData p_implData)
31    {
32      if(! p_implData.getLimit__IsNotDefault())
33      {
34        p_implData.setLimit(100);
35      }
36      return p_implData;
37    }
38    public AssignmentManagerStatusTmplImpl(org.jamon.TemplateManager p_templateManager, org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData p_implData)
39    {
40      super(p_templateManager, __jamon_setOptionalArguments(p_implData));
41      assignmentManager = p_implData.getAssignmentManager();
42      limit = p_implData.getLimit();
43    }
44    
45    public void renderNoFlush(@SuppressWarnings({"unused","hiding"}) final java.io.Writer jamonWriter)
46      throws java.io.IOException
47    {
48      // 33, 1
49      
50  Map<String, RegionState> rit = assignmentManager
51    .getRegionStates().getRegionsInTransition();
52  // process the map to find region in transition details
53  Configuration conf = HBaseConfiguration.create();
54  int ritThreshold = conf.getInt(HConstants.METRICS_RIT_STUCK_WARNING_THRESHOLD, 60000);
55  int numOfRITOverThreshold = 0;
56  long maxRITTime = Long.MIN_VALUE;
57  long currentTime = System.currentTimeMillis();
58  String regionIDForOldestRIT = ""; // avoiding null
59  for (Map.Entry<String, RegionState> e : rit.entrySet()) {
60    long ritTime = currentTime - e.getValue().getStamp();
61    if(ritTime > ritThreshold) {
62       numOfRITOverThreshold++;
63     }
64     if(maxRITTime < ritTime) {
65       maxRITTime = ritTime;
66       regionIDForOldestRIT = e.getKey();
67     }
68  }
69  
70  int toRemove = rit.size() - limit;
71  int removed = 0;
72  if (toRemove > 0) {
73    // getRegionsInTransition returned a copy, so we can mutate it
74    for (Iterator<Map.Entry<String, RegionState>> it = rit.entrySet().iterator();
75         it.hasNext() && toRemove > 0;
76         ) {
77      Map.Entry<String, RegionState> e = it.next();
78      if (HRegionInfo.FIRST_META_REGIONINFO.getEncodedName().equals(
79            e.getKey()) ||
80           regionIDForOldestRIT.equals(e.getKey())) {
81        // don't remove the meta & the oldest rit regions, they're too interesting!
82        continue;
83      } 
84      it.remove();
85      toRemove--;
86      removed++;
87    }
88  }
89  
90  
91      // 77, 1
92      if (!rit.isEmpty() )
93      {
94        // 77, 23
95        jamonWriter.write("\n    <section>\n    <h2>Regions in Transition</h2>\n    <table class=\"table table-striped\">\n            <tr><th>Region</th><th>State</th><th>RIT time (ms)</th></tr>\n            ");
96        // 82, 13
97        for (Map.Entry<String, RegionState> entry : rit.entrySet() )
98        {
99          // 82, 75
100         jamonWriter.write("\n            ");
101         // 83, 13
102         if (regionIDForOldestRIT.equals(entry.getKey()) )
103         {
104           // 83, 64
105           jamonWriter.write("\n                    <tr BGCOLOR=\"#FE2E2E\" >\n            ");
106         }
107         // 85, 13
108         else
109         {
110           // 85, 20
111           jamonWriter.write("\n                    <tr>\n            ");
112         }
113         // 87, 19
114         jamonWriter.write("\n            <td>");
115         // 88, 17
116         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(entry.getKey()), jamonWriter);
117         // 88, 37
118         jamonWriter.write("</td><td>");
119         // 88, 46
120         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(entry.getValue().toDescriptiveString()), jamonWriter);
121         // 88, 90
122         jamonWriter.write("</td>\n    <td>");
123         // 89, 9
124         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((currentTime - entry.getValue().getStamp())), jamonWriter);
125         // 89, 58
126         jamonWriter.write(" </td></tr>\n            ");
127       }
128       // 90, 20
129       jamonWriter.write("\n            <tr BGCOLOR=\"#D7DF01\"> <td>Total number of Regions in Transition for more than ");
130       // 91, 92
131       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(ritThreshold), jamonWriter);
132       // 91, 110
133       jamonWriter.write(" milliseconds</td><td> ");
134       // 91, 133
135       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITOverThreshold), jamonWriter);
136       // 91, 160
137       jamonWriter.write("</td><td></td>\n            </tr>\n    <tr> <td> Total number of Regions in Transition</td><td>");
138       // 93, 61
139       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(rit.size()), jamonWriter);
140       // 93, 77
141       jamonWriter.write(" </td><td></td>\n    </table>\n    ");
142       // 95, 5
143       if (removed > 0 )
144       {
145         // 95, 24
146         jamonWriter.write("\n    (");
147         // 96, 6
148         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(removed), jamonWriter);
149         // 96, 19
150         jamonWriter.write(" more regions in transition not shown)\n    ");
151       }
152       // 97, 11
153       jamonWriter.write("\n    </section>\n");
154     }
155     // 99, 7
156     jamonWriter.write("\n\n");
157   }
158   
159   
160 }