001// Autogenerated Jamon implementation
002// /Users/petersomogyi/projects/hbase-upstream/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
003
004package org.apache.hadoop.hbase.tmpl.master;
005
006// 20, 1
007import java.util.Map;
008// 21, 1
009import java.util.Set;
010// 22, 1
011import java.util.SortedSet;
012// 23, 1
013import java.util.concurrent.atomic.AtomicInteger;
014// 24, 1
015import java.util.stream.Collectors;
016// 25, 1
017import org.apache.hadoop.conf.Configuration;
018// 26, 1
019import org.apache.hadoop.hbase.HBaseConfiguration;
020// 27, 1
021import org.apache.hadoop.hbase.HConstants;
022// 28, 1
023import org.apache.hadoop.hbase.ServerName;
024// 29, 1
025import org.apache.hadoop.hbase.client.RegionInfo;
026// 30, 1
027import org.apache.hadoop.hbase.client.RegionInfoDisplay;
028// 31, 1
029import org.apache.hadoop.hbase.master.RegionState;
030// 32, 1
031import org.apache.hadoop.hbase.master.assignment.AssignmentManager;
032// 33, 1
033import org.apache.hadoop.hbase.master.assignment.AssignmentManager.RegionInTransitionStat;
034// 34, 1
035import org.apache.hadoop.hbase.master.assignment.RegionStates.RegionFailedOpen;
036// 35, 1
037import org.apache.hadoop.hbase.util.Pair;
038
039public class AssignmentManagerStatusTmplImpl
040  extends org.jamon.AbstractTemplateImpl
041  implements org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.Intf
042
043{
044  private final AssignmentManager assignmentManager;
045  private final int limit;
046  protected static org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData __jamon_setOptionalArguments(org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData p_implData)
047  {
048    if(! p_implData.getLimit__IsNotDefault())
049    {
050      p_implData.setLimit(100);
051    }
052    return p_implData;
053  }
054  public AssignmentManagerStatusTmplImpl(org.jamon.TemplateManager p_templateManager, org.apache.hadoop.hbase.tmpl.master.AssignmentManagerStatusTmpl.ImplData p_implData)
055  {
056    super(p_templateManager, __jamon_setOptionalArguments(p_implData));
057    assignmentManager = p_implData.getAssignmentManager();
058    limit = p_implData.getLimit();
059  }
060  
061  @Override public void renderNoFlush(final java.io.Writer jamonWriter)
062    throws java.io.IOException
063  {
064    // 42, 1
065    
066SortedSet<RegionState> rit = assignmentManager.getRegionStates()
067    .getRegionsInTransitionOrderedByTimestamp();
068
069    // 47, 1
070    if (!rit.isEmpty() )
071    {
072      // 47, 23
073      jamonWriter.write("\n");
074      // 48, 1
075      
076long currentTime = System.currentTimeMillis();
077RegionInTransitionStat ritStat = assignmentManager.computeRegionInTransitionStat();
078
079int numOfRITs = rit.size();
080int ritsPerPage = Math.min(5, numOfRITs);
081int numOfPages = (int) Math.ceil(numOfRITs * 1.0 / ritsPerPage);
082
083      // 56, 5
084      jamonWriter.write("<section>\n    <h2><a name=\"rit\">Regions in Transition</a></h2>\n     <p><a href=\"/rits.jsp\">");
085      // 58, 29
086      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITs), jamonWriter);
087      // 58, 44
088      jamonWriter.write(" region(s) in transition.</a>\n     ");
089      // 59, 6
090      if (ritStat.hasRegionsTwiceOverThreshold()  )
091      {
092        // 59, 53
093        jamonWriter.write("\n         <span class=\"label label-danger\" style=\"font-size:100%;font-weight:normal\">\n     ");
094      }
095      // 61, 6
096      else if (ritStat.hasRegionsOverThreshold() )
097      {
098        // 61, 51
099        jamonWriter.write("\n         <span class=\"label label-warning\" style=\"font-size:100%;font-weight:normal\">\n     ");
100      }
101      // 63, 6
102      else
103      {
104        // 63, 13
105        jamonWriter.write("\n         <span>\n     ");
106      }
107      // 65, 12
108      jamonWriter.write("\n         ");
109      // 66, 10
110      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(ritStat.getTotalRITsOverThreshold()), jamonWriter);
111      // 66, 51
112      jamonWriter.write(" region(s) in transition for\n             more than ");
113      // 67, 24
114      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(ritStat.getRITThreshold()), jamonWriter);
115      // 67, 55
116      jamonWriter.write(" milliseconds.\n         </span>\n     </p>\n     <div class=\"tabbable\">\n         <div class=\"tab-content\">\n         ");
117      // 72, 10
118      int recordItr = 0; 
119      // 73, 10
120      for (RegionState rs : rit )
121      {
122        // 73, 39
123        jamonWriter.write("\n             ");
124        // 74, 14
125        if ((recordItr % ritsPerPage) == 0 )
126        {
127          // 74, 52
128          jamonWriter.write("\n                 ");
129          // 75, 18
130          if (recordItr == 0 )
131          {
132            // 75, 40
133            jamonWriter.write("\n             <div class=\"tab-pane active\" id=\"tab_rits");
134            // 76, 55
135            org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((recordItr / ritsPerPage) + 1), jamonWriter);
136            // 76, 90
137            jamonWriter.write("\">\n                 ");
138          }
139          // 77, 18
140          else
141          {
142            // 77, 25
143            jamonWriter.write("\n             <div class=\"tab-pane\" id=\"tab_rits");
144            // 78, 48
145            org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((recordItr / ritsPerPage) + 1), jamonWriter);
146            // 78, 83
147            jamonWriter.write("\">\n                 ");
148          }
149          // 79, 24
150          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             ");
151        }
152        // 82, 20
153        jamonWriter.write("\n\n             ");
154        // 84, 14
155        if (ritStat.isRegionTwiceOverThreshold(rs.getRegion()) )
156        {
157          // 84, 72
158          jamonWriter.write("\n                     <tr class=\"alert alert-danger\" role=\"alert\">\n             ");
159        }
160        // 86, 14
161        else if (ritStat.isRegionOverThreshold(rs.getRegion()) )
162        {
163          // 86, 71
164          jamonWriter.write("\n                     <tr class=\"alert alert-warning\" role=\"alert\">\n            ");
165        }
166        // 88, 13
167        else
168        {
169          // 88, 20
170          jamonWriter.write("\n                    <tr>\n            ");
171        }
172        // 90, 19
173        jamonWriter.write("\n                        ");
174        // 91, 25
175        
176                          String retryStatus = "0";
177                          RegionFailedOpen regionFailedOpen = assignmentManager
178                            .getRegionStates().getFailedOpen(rs.getRegion());
179                          if (regionFailedOpen != null) {
180                            retryStatus = Integer.toString(regionFailedOpen.getRetries());
181                          } else if (rs.getState() ==  RegionState.State.FAILED_OPEN) {
182                            retryStatus = "Failed";
183                          }
184                        
185        // 101, 25
186        jamonWriter.write("<td>");
187        // 101, 29
188        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(rs.getRegion().getEncodedName()), jamonWriter);
189        // 101, 66
190        jamonWriter.write("</td><td>\n                        ");
191        // 102, 25
192        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(RegionInfoDisplay.getDescriptiveNameFromRegionStateForDisplay(rs,
193                            assignmentManager.getConfiguration())), jamonWriter);
194        // 103, 69
195        jamonWriter.write("</td>\n                        <td>");
196        // 104, 29
197        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((currentTime - rs.getStamp())), jamonWriter);
198        // 104, 64
199        jamonWriter.write(" </td>\n                        <td> ");
200        // 105, 30
201        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(retryStatus), jamonWriter);
202        // 105, 47
203        jamonWriter.write(" </td>\n                     </tr>\n                     ");
204        // 107, 22
205        recordItr++; 
206        // 108, 14
207        if ((recordItr % ritsPerPage) == 0 )
208        {
209          // 108, 52
210          jamonWriter.write("\n                 </table>\n             </div>\n         ");
211        }
212        // 111, 16
213        jamonWriter.write("\n         ");
214      }
215      // 112, 17
216      jamonWriter.write("\n\n         ");
217      // 114, 10
218      if ((recordItr % ritsPerPage) != 0 )
219      {
220        // 114, 48
221        jamonWriter.write("\n             ");
222        // 115, 14
223        for (; (recordItr % ritsPerPage) != 0 ; recordItr++ )
224        {
225          // 115, 69
226          jamonWriter.write("\n             <tr><td colspan=\"3\" style=\"height:61px\"></td></tr>\n             ");
227        }
228        // 117, 21
229        jamonWriter.write("\n                   </table>\n             </div>\n         ");
230      }
231      // 120, 16
232      jamonWriter.write("\n         </div>\n         <nav>\n             <ul class=\"nav nav-pills pagination\">\n             ");
233      // 124, 14
234      for (int i = 1 ; i <= numOfPages; i++ )
235      {
236        // 124, 55
237        jamonWriter.write("\n                 ");
238        // 125, 18
239        if (i == 1 )
240        {
241          // 125, 32
242          jamonWriter.write("\n                 <li class=\"active\">\n                 ");
243        }
244        // 127, 18
245        else
246        {
247          // 127, 25
248          jamonWriter.write("\n                 <li>\n                 ");
249        }
250        // 129, 24
251        jamonWriter.write("\n                 <a href=\"#tab_rits");
252        // 130, 36
253        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(i), jamonWriter);
254        // 130, 43
255        jamonWriter.write("\">");
256        // 130, 45
257        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(i), jamonWriter);
258        // 130, 52
259        jamonWriter.write("</a></li>\n             ");
260      }
261      // 131, 21
262      jamonWriter.write("\n             </ul>\n         </nav>\n     </div>\n   </section>\n ");
263    }
264    // 136, 8
265    jamonWriter.write("\n\n");
266  }
267  
268  
269}