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  // 28, 1
23  import java.util.Map;
24  // 29, 1
25  import java.util.concurrent.atomic.AtomicInteger;
26
27  public class AssignmentManagerStatusTmplImpl
28    extends org.jamon.AbstractTemplateImpl
29    implements org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.Intf
30
31  {
32    private final AssignmentManager assignmentManager;
33    private final int limit;
34    protected static org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData __jamon_setOptionalArguments(org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData p_implData)
35    {
36      if(! p_implData.getLimit__IsNotDefault())
37      {
38        p_implData.setLimit(100);
39      }
40      return p_implData;
41    }
42    public AssignmentManagerStatusTmplImpl(org.jamon.TemplateManager p_templateManager, org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData p_implData)
43    {
44      super(p_templateManager, __jamon_setOptionalArguments(p_implData));
45      assignmentManager = p_implData.getAssignmentManager();
46      limit = p_implData.getLimit();
47    }
48
49    @Override public void renderNoFlush(final java.io.Writer jamonWriter)
50      throws java.io.IOException
51    {
52      // 36, 1
53      SortedSet<RegionState> rit = assignmentManager
54    .getRegionStates().getRegionsInTransitionOrderedByTimestamp();
55    Map<String, AtomicInteger> failedRegionTracker = assignmentManager.getFailedOpenTracker();
56
57      // 41, 1
58      if (!rit.isEmpty() )
59      {
60        // 41, 23
61        jamonWriter.write("\n");
62        // 42, 1
63
64  HashSet<String> ritsOverThreshold = new HashSet<String>();
65  HashSet<String> ritsTwiceThreshold = new HashSet<String>();
66  // process the map to find region in transition details
67  Configuration conf = HBaseConfiguration.create();
68  int ritThreshold = conf.getInt(HConstants.METRICS_RIT_STUCK_WARNING_THRESHOLD, 60000);
69  int numOfRITOverThreshold = 0;
70  long currentTime = System.currentTimeMillis();
71  for (RegionState rs : rit) {
72    long ritTime = currentTime - rs.getStamp();
73    if(ritTime > (ritThreshold * 2)) {
74       numOfRITOverThreshold++;
75       ritsTwiceThreshold.add(rs.getRegion().getEncodedName());
76    } else if (ritTime > ritThreshold) {
77       numOfRITOverThreshold++;
78       ritsOverThreshold.add(rs.getRegion().getEncodedName());
79    }
80  }
81
82  int numOfRITs = rit.size();
83  int ritsPerPage = Math.min(5, numOfRITs);
84  int numOfPages = (int) Math.ceil(numOfRITs * 1.0 / ritsPerPage);
85
86        // 65, 5
87        jamonWriter.write("<section>\n    <h2>Regions in Transition</h2>\n     <p>");
88        // 67, 9
89        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITs), jamonWriter);
90        // 67, 24
91        jamonWriter.write(" region(s) in transition.\n     ");
92        // 68, 6
93        if (!ritsTwiceThreshold.isEmpty()  )
94        {
95          // 68, 44
96          jamonWriter.write("\n         <span class=\"label label-danger\" style=\"font-size:100%;font-weight:normal\">\n     ");
97        }
98        // 70, 6
99        else if (!ritsOverThreshold.isEmpty() )
100       {
101         // 70, 46
102         jamonWriter.write("\n         <span class=\"label label-warning\" style=\"font-size:100%;font-weight:normal\">\n     ");
103       }
104       // 72, 6
105       else
106       {
107         // 72, 13
108         jamonWriter.write("\n         <span>\n     ");
109       }
110       // 74, 12
111       jamonWriter.write("\n         ");
112       // 75, 10
113       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITOverThreshold), jamonWriter);
114       // 75, 37
115       jamonWriter.write(" region(s) in transition for\n             more than ");
116       // 76, 24
117       org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(ritThreshold), jamonWriter);
118       // 76, 42
119       jamonWriter.write(" milliseconds.\n         </span>\n     </p>\n     <div class=\"tabbable\">\n         <div class=\"tab-content\">\n         ");
120       // 81, 10
121       int recordItr = 0;
122       // 82, 10
123       for (RegionState rs : rit )
124       {
125         // 82, 39
126         jamonWriter.write("\n             ");
127         // 83, 14
128         if ((recordItr % ritsPerPage) == 0 )
129         {
130           // 83, 52
131           jamonWriter.write("\n                 ");
132           // 84, 18
133           if (recordItr == 0 )
134           {
135             // 84, 40
136             jamonWriter.write("\n             <div class=\"tab-pane active\" id=\"tab_rits");
137             // 85, 55
138             org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((recordItr / ritsPerPage) + 1), jamonWriter);
139             // 85, 90
140             jamonWriter.write("\">\n                 ");
141           }
142           // 86, 18
143           else
144           {
145             // 86, 25
146             jamonWriter.write("\n             <div class=\"tab-pane\" id=\"tab_rits");
147             // 87, 48
148             org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((recordItr / ritsPerPage) + 1), jamonWriter);
149             // 87, 83
150             jamonWriter.write("\">\n                 ");
151           }
152           // 88, 24
153           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> <th>Retries </th></tr>\n             ");
154         }
155         // 91, 20
156         jamonWriter.write("\n\n             ");
157         // 93, 14
158         if (ritsOverThreshold.contains(rs.getRegion().getEncodedName()) )
159         {
160           // 93, 81
161           jamonWriter.write("\n                     <tr class=\"alert alert-warning\" role=\"alert\">\n             ");
162         }
163         // 95, 14
164         else if (ritsTwiceThreshold.contains(rs.getRegion().getEncodedName()) )
165         {
166           // 95, 86
167           jamonWriter.write("\n                     <tr class=\"alert alert-danger\" role=\"alert\">\n            ");
168         }
169         // 97, 13
170         else
171         {
172           // 97, 20
173           jamonWriter.write("\n                    <tr>\n            ");
174         }
175         // 99, 19
176         jamonWriter.write("\n                        ");
177         // 100, 25
178
179                           String retryStatus = "0";
180                           AtomicInteger numOpenRetries = failedRegionTracker.get(
181                               rs.getRegion().getEncodedName());
182                           if (numOpenRetries != null ) {
183                             retryStatus = Integer.toString(numOpenRetries.get());
184                           } else if (rs.getState() ==  RegionState.State.FAILED_OPEN) {
185                              retryStatus = "Failed";
186                           }
187
188         // 110, 25
189         jamonWriter.write("<td>");
190         // 110, 29
191         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(rs.getRegion().getEncodedName()), jamonWriter);
192         // 110, 66
193         jamonWriter.write("</td><td>\n                        ");
194         // 111, 25
195         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(rs, conf)), jamonWriter);
196         // 111, 96
197         jamonWriter.write("</td>\n                        <td>");
198         // 112, 29
199         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((currentTime - rs.getStamp())), jamonWriter);
200         // 112, 64
201         jamonWriter.write(" </td>\n                        <td> ");
202         // 113, 30
203         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(retryStatus), jamonWriter);
204         // 113, 47
205         jamonWriter.write(" </td>\n                     </tr>\n                     ");
206         // 115, 22
207         recordItr++;
208         // 116, 14
209         if ((recordItr % ritsPerPage) == 0 )
210         {
211           // 116, 52
212           jamonWriter.write("\n                 </table>\n             </div>\n         ");
213         }
214         // 119, 16
215         jamonWriter.write("\n         ");
216       }
217       // 120, 17
218       jamonWriter.write("\n\n         ");
219       // 122, 10
220       if ((recordItr % ritsPerPage) != 0 )
221       {
222         // 122, 48
223         jamonWriter.write("\n             ");
224         // 123, 14
225         for (; (recordItr % ritsPerPage) != 0 ; recordItr++ )
226         {
227           // 123, 69
228           jamonWriter.write("\n             <tr><td colspan=\"3\" style=\"height:61px\"></td></tr>\n             ");
229         }
230         // 125, 21
231         jamonWriter.write("\n                   </table>\n             </div>\n         ");
232       }
233       // 128, 16
234       jamonWriter.write("\n         </div>\n         <nav>\n             <ul class=\"nav nav-pills pagination\">\n             ");
235       // 132, 14
236       for (int i = 1 ; i <= numOfPages; i++ )
237       {
238         // 132, 55
239         jamonWriter.write("\n                 ");
240         // 133, 18
241         if (i == 1 )
242         {
243           // 133, 32
244           jamonWriter.write("\n                 <li class=\"active\">\n                 ");
245         }
246         // 135, 18
247         else
248         {
249           // 135, 25
250           jamonWriter.write("\n                 <li>\n                 ");
251         }
252         // 137, 24
253         jamonWriter.write("\n                 <a href=\"#tab_rits");
254         // 138, 36
255         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(i), jamonWriter);
256         // 138, 43
257         jamonWriter.write("\">");
258         // 138, 45
259         org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(i), jamonWriter);
260         // 138, 52
261         jamonWriter.write("</a></li>\n             ");
262       }
263       // 139, 21
264       jamonWriter.write("\n             </ul>\n         </nav>\n     </div>\n   </section>\n ");
265     }
266     // 144, 8
267     jamonWriter.write("\n\n");
268   }
269
270
271 }