001// Autogenerated Jamon implementation
002// /Users/peter.somogyi/Cloudera/repos/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>Regions in Transition</h2>\n     <p>");
085      // 58, 9
086      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITs), jamonWriter);
087      // 58, 24
088      jamonWriter.write(" region(s) in transition.\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>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, 30
197        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(retryStatus), jamonWriter);
198        // 104, 47
199        jamonWriter.write(" </td>\n                     </tr>\n                     ");
200        // 106, 22
201        recordItr++; 
202        // 107, 14
203        if ((recordItr % ritsPerPage) == 0 )
204        {
205          // 107, 52
206          jamonWriter.write("\n                 </table>\n             </div>\n         ");
207        }
208        // 110, 16
209        jamonWriter.write("\n         ");
210      }
211      // 111, 17
212      jamonWriter.write("\n\n         ");
213      // 113, 10
214      if ((recordItr % ritsPerPage) != 0 )
215      {
216        // 113, 48
217        jamonWriter.write("\n             ");
218        // 114, 14
219        for (; (recordItr % ritsPerPage) != 0 ; recordItr++ )
220        {
221          // 114, 69
222          jamonWriter.write("\n             <tr><td colspan=\"3\" style=\"height:61px\"></td></tr>\n             ");
223        }
224        // 116, 21
225        jamonWriter.write("\n                   </table>\n             </div>\n         ");
226      }
227      // 119, 16
228      jamonWriter.write("\n         </div>\n         <nav>\n             <ul class=\"nav nav-pills pagination\">\n             ");
229      // 123, 14
230      for (int i = 1 ; i <= numOfPages; i++ )
231      {
232        // 123, 55
233        jamonWriter.write("\n                 ");
234        // 124, 18
235        if (i == 1 )
236        {
237          // 124, 32
238          jamonWriter.write("\n                 <li class=\"active\">\n                 ");
239        }
240        // 126, 18
241        else
242        {
243          // 126, 25
244          jamonWriter.write("\n                 <li>\n                 ");
245        }
246        // 128, 24
247        jamonWriter.write("\n                 <a href=\"#tab_rits");
248        // 129, 36
249        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(i), jamonWriter);
250        // 129, 43
251        jamonWriter.write("\">");
252        // 129, 45
253        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(i), jamonWriter);
254        // 129, 52
255        jamonWriter.write("</a></li>\n             ");
256      }
257      // 130, 21
258      jamonWriter.write("\n             </ul>\n         </nav>\n     </div>\n   </section>\n ");
259    }
260    // 135, 8
261    jamonWriter.write("\n\n");
262  }
263  
264  
265}