View Javadoc

1   // Autogenerated Jamon implementation
2   // /jenkins/workspace/hbase_generate_website/hbase/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    @Override public void renderNoFlush(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 totalRITs = rit.size();
71  int toRemove = rit.size() - limit;
72  int removed = 0;
73  if (toRemove > 0) {
74    // getRegionsInTransition returned a copy, so we can mutate it
75    for (Iterator<Map.Entry<String, RegionState>> it = rit.entrySet().iterator();
76         it.hasNext() && toRemove > 0;
77         ) {
78      Map.Entry<String, RegionState> e = it.next();
79      if (HRegionInfo.FIRST_META_REGIONINFO.getEncodedName().equals(
80            e.getKey()) ||
81           regionIDForOldestRIT.equals(e.getKey())) {
82        // don't remove the meta & the oldest rit regions, they're too interesting!
83        continue;
84      } 
85      it.remove();
86      toRemove--;
87      removed++;
88    }
89  }
90  
91  
92      // 78, 1
93      if (!rit.isEmpty() )
94      {
95        // 78, 23
96        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            ");
97        // 83, 13
98        for (Map.Entry<String, RegionState> entry : rit.entrySet() )
99        {
100         // 83, 75
101         jamonWriter.write("\n            ");
102         // 84, 13
103         if (regionIDForOldestRIT.equals(entry.getKey()) )
104         {
105           // 84, 64
106           jamonWriter.write("\n                    <tr BGCOLOR=\"#FE2E2E\" >\n            ");
107         }
108         // 86, 13
109         else
110         {
111           // 86, 20
112           jamonWriter.write("\n                    <tr>\n            ");
113         }
114         // 88, 19
115         jamonWriter.write("\n            <td>");
116         // 89, 17
117         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(entry.getKey()), jamonWriter);
118         // 89, 37
119         jamonWriter.write("</td><td>\n            ");
120         // 90, 13
121         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(
122             entry.getValue(), conf)), jamonWriter);
123         // 91, 39
124         jamonWriter.write("</td>\n    <td>");
125         // 92, 9
126         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((currentTime - entry.getValue().getStamp())), jamonWriter);
127         // 92, 58
128         jamonWriter.write(" </td></tr>\n            ");
129       }
130       // 93, 20
131       jamonWriter.write("\n            ");
132       // 94, 13
133       if (numOfRITOverThreshold > 0 )
134       {
135         // 94, 46
136         jamonWriter.write("\n                    <tr BGCOLOR=\"#D7DF01\" >\n            ");
137       }
138       // 96, 13
139       else
140       {
141         // 96, 20
142         jamonWriter.write("\n                    <tr>\n            ");
143       }
144       // 98, 19
145       jamonWriter.write("\n            <td>Total number of Regions in Transition for more than ");
146       // 99, 69
147       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(ritThreshold), jamonWriter);
148       // 99, 87
149       jamonWriter.write(" milliseconds</td><td> ");
150       // 99, 110
151       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITOverThreshold), jamonWriter);
152       // 99, 137
153       jamonWriter.write("</td><td></td>\n            </tr>\n    <tr> <td> Total number of Regions in Transition</td><td>");
154       // 101, 61
155       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(totalRITs), jamonWriter);
156       // 101, 76
157       jamonWriter.write(" </td><td></td>\n    </table>\n    ");
158       // 103, 5
159       if (removed > 0 )
160       {
161         // 103, 24
162         jamonWriter.write("\n    (");
163         // 104, 6
164         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(removed), jamonWriter);
165         // 104, 19
166         jamonWriter.write(" more regions in transition not shown)\n    ");
167       }
168       // 105, 11
169       jamonWriter.write("\n    </section>\n");
170     }
171     // 107, 7
172     jamonWriter.write("\n\n");
173   }
174   
175   
176 }