content: // Autogenerated Jamon implementation
  // /Users/jaywong/data/opensource/hadoop/wasp/github/wasp/src/main/jamon/./com/alibaba/wasp/tmpl/master/AssignmentManagerStatusTmpl.jamon
  
  package com.alibaba.wasp.tmpl.master;
  
  // 20, 1
  import com.alibaba.wasp.master.AssignmentManager;
  // 21, 1
  import com.alibaba.wasp.master.EntityGroupState;
  // 22, 1
  import org.apache.hadoop.conf.Configuration;
  // 23, 1
  import com.alibaba.wasp.conf.WaspConfiguration;
  // 24, 1
  import com.alibaba.wasp.FConstants;
  // 25, 1
  import java.util.Iterator;
  // 26, 1
  import java.util.Map;
  
  public class AssignmentManagerStatusTmplImpl
    extends org.jamon.AbstractTemplateImpl
    implements com.alibaba.wasp.tmpl.master.AssignmentManagerStatusTmpl.Intf
  
  {
    private final AssignmentManager assignmentManager;
    private final int limit;
    protected static com.alibaba.wasp.tmpl.master.AssignmentManagerStatusTmpl.ImplData __jamon_setOptionalArguments(com.alibaba.wasp.tmpl.master.AssignmentManagerStatusTmpl.ImplData p_implData)
    {
      if(! p_implData.getLimit__IsNotDefault())
      {
        p_implData.setLimit(100);
      }
      return p_implData;
    }
    public AssignmentManagerStatusTmplImpl(org.jamon.TemplateManager p_templateManager, com.alibaba.wasp.tmpl.master.AssignmentManagerStatusTmpl.ImplData p_implData)
    {
      super(p_templateManager, __jamon_setOptionalArguments(p_implData));
      assignmentManager = p_implData.getAssignmentManager();
      limit = p_implData.getLimit();
    }
    
    public void renderNoFlush(@SuppressWarnings({"unused","hiding"}) final java.io.Writer jamonWriter)
      throws java.io.IOException
    {
      // 32, 1
      
  Map<String, EntityGroupState> rit = assignmentManager
    .getEntityGroupStates().getEntityGroupsInTransition();
  // process the map to find region in transition details
  Configuration conf = WaspConfiguration.create();
  int ritThreshold = conf.getInt(FConstants.METRICS_EGIT_STUCK_WARNING_THRESHOLD, 60000);
  int numOfRITOverThreshold = 0;
  long maxRITTime = Long.MIN_VALUE;
  long currentTime = System.currentTimeMillis();
  String regionIDForOldestRIT = ""; // avoiding null
  for (Map.Entry<String, EntityGroupState> e : rit.entrySet()) {
    long ritTime = currentTime - e.getValue().getStamp();
    if(ritTime > ritThreshold) {
       numOfRITOverThreshold++;
     }
     if(maxRITTime < ritTime) {
       maxRITTime = ritTime;
       regionIDForOldestRIT = e.getKey();
     }
  }
  
  int toRemove = rit.size() - limit;
  int removed = 0;
  if (toRemove > 0) {
    // getRegionsInTransition returned a copy, so we can mutate it
    for (Iterator<Map.Entry<String, EntityGroupState>> it = rit.entrySet().iterator();
         it.hasNext() && toRemove > 0;
         ) {
      Map.Entry<String, EntityGroupState> e = it.next();
      it.remove();
      toRemove--;
      removed++;
    }
  }
  
  
      // 70, 1
      if (!rit.isEmpty() )
      {
        // 70, 23
        jamonWriter.write("\n    <section>\n    <h2>EntityGroups in Transition</h2>\n    <table class=\"table table-striped\">\n            <tr><th>EntityGroup</th><th>State</th><th>RIT time (ms)</th></tr>\n            ");
        // 75, 13
        for (Map.Entry<String, EntityGroupState> entry : rit.entrySet() )
        {
          // 75, 80
          jamonWriter.write("\n            ");
          // 76, 13
          if (regionIDForOldestRIT.equals(entry.getKey()) )
          {
            // 76, 64
            jamonWriter.write("\n                    <tr BGCOLOR=\"#FE2E2E\" >\n            ");
          }
          // 78, 13
          else
          {
            // 78, 20
            jamonWriter.write("\n                    <tr>\n            ");
          }
          // 80, 19
          jamonWriter.write("\n            <td>");
          // 81, 17
          org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(entry.getKey()), jamonWriter);
          // 81, 37
          jamonWriter.write("</td><td>");
          // 81, 46
          org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(entry.getValue().toDescriptiveString()), jamonWriter);
          // 81, 90
          jamonWriter.write("</td>\n    <td>");
          // 82, 9
          org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf((currentTime - entry.getValue().getStamp())), jamonWriter);
          // 82, 58
          jamonWriter.write(" </td></tr>\n            ");
        }
        // 83, 20
        jamonWriter.write("\n            <tr BGCOLOR=\"#D7DF01\"> <td>Total number of EntityGroups in Transition for more than ");
        // 84, 97
        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(ritThreshold), jamonWriter);
        // 84, 115
        jamonWriter.write(" milliseconds</td><td> ");
        // 84, 138
        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(numOfRITOverThreshold), jamonWriter);
        // 84, 165
        jamonWriter.write("</td><td></td>\n            </tr>\n    <tr> <td> Total number of EntityGroups in Transition</td><td>");
        // 86, 66
        org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(rit.size()), jamonWriter);
        // 86, 82
        jamonWriter.write(" </td><td></td>\n    </table>\n    ");
        // 88, 5
        if (removed > 0 )
        {
          // 88, 24
          jamonWriter.write("\n    (");
          // 89, 6
          org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(removed), jamonWriter);
          // 89, 19
          jamonWriter.write(" more regions in transition not shown)\n    ");
        }
        // 90, 11
        jamonWriter.write("\n    </section>\n");
      }
      // 92, 7
      jamonWriter.write("\n\n");
    }
    
    
  }
  