View Javadoc

1   // Autogenerated Jamon implementation
2   // /home/jenkins/jenkins-slave/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.HashSet;
20  // 27, 1
21  import java.util.SortedSet;
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      // 34, 1
49      SortedSet<RegionState> rit = assignmentManager
50    .getRegionStates().getRegionsInTransitionOrderedByTimestamp();
51      // 37, 1
52      if (!rit.isEmpty() )
53      {
54        // 37, 23
55        jamonWriter.write("\n");
56        // 38, 1
57
58  HashSet<String> ritsOverThreshold = new HashSet<String>();
59  HashSet<String> ritsTwiceThreshold = new HashSet<String>();
60  // process the map to find region in transition details
61  Configuration conf = HBaseConfiguration.create();
62  int ritThreshold = conf.getInt(HConstants.METRICS_RIT_STUCK_WARNING_THRESHOLD, 60000);
63  int numOfRITOverThreshold = 0;
64  long currentTime = System.currentTimeMillis();
65  for (RegionState rs : rit) {
66    long ritTime = currentTime - rs.getStamp();
67    if(ritTime > (ritThreshold * 2)) {
68       numOfRITOverThreshold++;
69       ritsTwiceThreshold.add(rs.getRegion().getEncodedName());
70    } else if (ritTime > ritThreshold) {
71       numOfRITOverThreshold++;
72       ritsOverThreshold.add(rs.getRegion().getEncodedName());
73    }
74  }
75
76  int numOfRITs = rit.size();
77  int ritsPerPage = Math.min(5, numOfRITs);
78  int numOfPages = (int) Math.ceil(numOfRITs * 1.0 / ritsPerPage);
79
80        // 61, 5
81        jamonWriter.write("<section>\n    <h2>Regions in Transition</h2>\n     <p>");
82        // 63, 9
83        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITs), jamonWriter);
84        // 63, 24
85        jamonWriter.write(" region(s) in transition.\n     ");
86        // 64, 6
87        if (!ritsTwiceThreshold.isEmpty()  )
88        {
89          // 64, 44
90          jamonWriter.write("\n         <span class=\"label label-danger\" style=\"font-size:100%;font-weight:normal\">\n     ");
91        }
92        // 66, 6
93        else if (!ritsOverThreshold.isEmpty() )
94        {
95          // 66, 46
96          jamonWriter.write("\n         <span class=\"label label-warning\" style=\"font-size:100%;font-weight:normal\">\n     ");
97        }
98        // 68, 6
99        else
100       {
101         // 68, 13
102         jamonWriter.write("\n         <span>\n     ");
103       }
104       // 70, 12
105       jamonWriter.write("\n         ");
106       // 71, 10
107       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITOverThreshold), jamonWriter);
108       // 71, 37
109       jamonWriter.write(" region(s) in transition for\n             more than ");
110       // 72, 24
111       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(ritThreshold), jamonWriter);
112       // 72, 42
113       jamonWriter.write(" milliseconds.\n         </span>\n     </p>\n     <div class=\"tabbable\">\n         <div class=\"tab-content\">\n         ");
114       // 77, 10
115       int recordItr = 0;
116       // 78, 10
117       for (RegionState rs : rit )
118       {
119         // 78, 39
120         jamonWriter.write("\n             ");
121         // 79, 14
122         if ((recordItr % ritsPerPage) == 0 )
123         {
124           // 79, 52
125           jamonWriter.write("\n                 ");
126           // 80, 18
127           if (recordItr == 0 )
128           {
129             // 80, 40
130             jamonWriter.write("\n             <div class=\"tab-pane active\" id=\"tab_rits");
131             // 81, 55
132             org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((recordItr / ritsPerPage) + 1), jamonWriter);
133             // 81, 90
134             jamonWriter.write("\">\n                 ");
135           }
136           // 82, 18
137           else
138           {
139             // 82, 25
140             jamonWriter.write("\n             <div class=\"tab-pane\" id=\"tab_rits");
141             // 83, 48
142             org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((recordItr / ritsPerPage) + 1), jamonWriter);
143             // 83, 83
144             jamonWriter.write("\">\n                 ");
145           }
146           // 84, 24
147           jamonWriter.write("\n                 <table class=\"table table-striped\" style=\"margin-bottom:0px;\"><tr><th>Region</th>\n                     <th>State</th><th>RIT time (ms)</th></tr>\n             ");
148         }
149         // 87, 20
150         jamonWriter.write("\n\n             ");
151         // 89, 14
152         if (ritsOverThreshold.contains(rs.getRegion().getEncodedName()) )
153         {
154           // 89, 81
155           jamonWriter.write("\n                     <tr class=\"alert alert-warning\" role=\"alert\">\n             ");
156         }
157         // 91, 14
158         else if (ritsTwiceThreshold.contains(rs.getRegion().getEncodedName()) )
159         {
160           // 91, 86
161           jamonWriter.write("\n                     <tr class=\"alert alert-danger\" role=\"alert\">\n            ");
162         }
163         // 93, 13
164         else
165         {
166           // 93, 20
167           jamonWriter.write("\n                    <tr>\n            ");
168         }
169         // 95, 19
170         jamonWriter.write("\n                        <td>");
171         // 96, 29
172         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(rs.getRegion().getEncodedName()), jamonWriter);
173         // 96, 66
174         jamonWriter.write("</td><td>\n                        ");
175         // 97, 25
176         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(rs, conf)), jamonWriter);
177         // 97, 96
178         jamonWriter.write("</td>\n                        <td>");
179         // 98, 29
180         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((currentTime - rs.getStamp())), jamonWriter);
181         // 98, 64
182         jamonWriter.write(" </td>\n                     </tr>\n                     ");
183         // 100, 22
184         recordItr++;
185         // 101, 14
186         if ((recordItr % ritsPerPage) == 0 )
187         {
188           // 101, 52
189           jamonWriter.write("\n                 </table>\n             </div>\n         ");
190         }
191         // 104, 16
192         jamonWriter.write("\n         ");
193       }
194       // 105, 17
195       jamonWriter.write("\n\n         ");
196       // 107, 10
197       if ((recordItr % ritsPerPage) != 0 )
198       {
199         // 107, 48
200         jamonWriter.write("\n             ");
201         // 108, 14
202         for (; (recordItr % ritsPerPage) != 0 ; recordItr++ )
203         {
204           // 108, 69
205           jamonWriter.write("\n             <tr><td colspan=\"3\" style=\"height:61px\"></td></tr>\n             ");
206         }
207         // 110, 21
208         jamonWriter.write("\n                   </table>\n             </div>\n         ");
209       }
210       // 113, 16
211       jamonWriter.write("\n         </div>\n         <nav>\n             <ul class=\"nav nav-pills pagination\">\n             ");
212       // 117, 14
213       for (int i = 1 ; i <= numOfPages; i++ )
214       {
215         // 117, 55
216         jamonWriter.write("\n                 ");
217         // 118, 18
218         if (i == 1 )
219         {
220           // 118, 32
221           jamonWriter.write("\n                 <li class=\"active\">\n                 ");
222         }
223         // 120, 18
224         else
225         {
226           // 120, 25
227           jamonWriter.write("\n                 <li>\n                 ");
228         }
229         // 122, 24
230         jamonWriter.write("\n                 <a href=\"#tab_rits");
231         // 123, 36
232         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(i), jamonWriter);
233         // 123, 43
234         jamonWriter.write("\">");
235         // 123, 45
236         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(i), jamonWriter);
237         // 123, 52
238         jamonWriter.write("</a></li>\n             ");
239       }
240       // 124, 21
241       jamonWriter.write("\n             </ul>\n         </nav>\n     </div>\n   </section>\n ");
242     }
243     // 129, 8
244     jamonWriter.write("\n\n");
245   }
246
247
248 }