View Javadoc

1   // Autogenerated Jamon implementation
2   // /Users/misty/git/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    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>\n            ");
119         // 89, 13
120         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(
121             entry.getValue(), conf)), jamonWriter);
122         // 90, 39
123         jamonWriter.write("</td>\n    <td>");
124         // 91, 9
125         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((currentTime - entry.getValue().getStamp())), jamonWriter);
126         // 91, 58
127         jamonWriter.write(" </td></tr>\n            ");
128       }
129       // 92, 20
130       jamonWriter.write("\n            <tr BGCOLOR=\"#D7DF01\"> <td>Total number of Regions in Transition for more than ");
131       // 93, 92
132       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(ritThreshold), jamonWriter);
133       // 93, 110
134       jamonWriter.write(" milliseconds</td><td> ");
135       // 93, 133
136       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITOverThreshold), jamonWriter);
137       // 93, 160
138       jamonWriter.write("</td><td></td>\n            </tr>\n    <tr> <td> Total number of Regions in Transition</td><td>");
139       // 95, 61
140       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(rit.size()), jamonWriter);
141       // 95, 77
142       jamonWriter.write(" </td><td></td>\n    </table>\n    ");
143       // 97, 5
144       if (removed > 0 )
145       {
146         // 97, 24
147         jamonWriter.write("\n    (");
148         // 98, 6
149         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(removed), jamonWriter);
150         // 98, 19
151         jamonWriter.write(" more regions in transition not shown)\n    ");
152       }
153       // 99, 11
154       jamonWriter.write("\n    </section>\n");
155     }
156     // 101, 7
157     jamonWriter.write("\n\n");
158   }
159   
160   
161 }