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