001// Autogenerated Jamon implementation
002// /Users/peter.somogyi/Cloudera/repos/hbase-upstream/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheViewTmpl.jamon
003
004package org.apache.hadoop.hbase.tmpl.regionserver;
005
006// 28, 1
007import java.util.*;
008// 29, 1
009import org.apache.hadoop.conf.Configuration;
010// 30, 1
011import org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile;
012// 31, 1
013import org.apache.hadoop.hbase.io.hfile.BlockCacheUtil;
014// 32, 1
015import org.apache.hadoop.hbase.io.hfile.CachedBlock;
016// 33, 1
017import org.apache.hadoop.hbase.io.hfile.CacheConfig;
018// 34, 1
019import org.apache.hadoop.hbase.io.hfile.BlockCache;
020// 35, 1
021import org.apache.hadoop.hbase.io.hfile.bucket.BucketCacheStats;
022// 36, 1
023import org.apache.hadoop.hbase.io.hfile.bucket.BucketCache;
024// 37, 1
025import org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator;
026// 38, 1
027import org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.Bucket;
028// 39, 1
029import org.apache.hadoop.util.StringUtils;
030
031public class BlockCacheViewTmplImpl
032  extends org.jamon.AbstractTemplateImpl
033  implements org.apache.hadoop.hbase.tmpl.regionserver.BlockCacheViewTmpl.Intf
034
035{
036  private final CacheConfig cacheConfig;
037  private final Configuration conf;
038  private final String bcn;
039  private final String bcv;
040  protected static org.apache.hadoop.hbase.tmpl.regionserver.BlockCacheViewTmpl.ImplData __jamon_setOptionalArguments(org.apache.hadoop.hbase.tmpl.regionserver.BlockCacheViewTmpl.ImplData p_implData)
041  {
042    return p_implData;
043  }
044  public BlockCacheViewTmplImpl(org.jamon.TemplateManager p_templateManager, org.apache.hadoop.hbase.tmpl.regionserver.BlockCacheViewTmpl.ImplData p_implData)
045  {
046    super(p_templateManager, __jamon_setOptionalArguments(p_implData));
047    cacheConfig = p_implData.getCacheConfig();
048    conf = p_implData.getConf();
049    bcn = p_implData.getBcn();
050    bcv = p_implData.getBcv();
051  }
052  
053  @Override public void renderNoFlush(final java.io.Writer jamonWriter)
054    throws java.io.IOException
055  {
056    // 41, 1
057    
058  BlockCache bc = cacheConfig == null ? null : cacheConfig.getBlockCache();
059  BlockCache [] bcs = bc == null ? null : bc.getBlockCaches();
060  if (bcn.equals("L1")) {
061    bc = bcs == null || bcs.length == 0? bc: bcs[0];
062  } else {
063    if (bcs == null || bcs.length < 2) {
064      System.out.println("There is no L2 block cache");
065      return;
066    }
067    bc = bcs[1];
068  }
069  if (bc == null) {
070    System.out.println("There is no block cache");
071    return;
072  }
073  CachedBlocksByFile cbsbf = BlockCacheUtil.getLoadedCachedBlocksByFile(conf, bc);
074
075    // 59, 1
076    if (bcv.equals("file") )
077    {
078      // 59, 27
079      {
080        // 59, 27
081        __jamon_innerUnit__bc_by_file(jamonWriter, cbsbf);
082      }
083    }
084    // 59, 59
085    else
086    {
087      // 59, 66
088      jamonWriter.write("[ ");
089      // 59, 68
090      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(BlockCacheUtil.toJSON(bc)), jamonWriter);
091      // 59, 99
092      jamonWriter.write(", ");
093      // 59, 101
094      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(BlockCacheUtil.toJSON(cbsbf)), jamonWriter);
095      // 59, 135
096      jamonWriter.write(" ]");
097    }
098    // 59, 143
099    jamonWriter.write("\n");
100    // 60, 1
101    
102cbsbf = null;
103
104  }
105  
106  
107  // 64, 1
108  private void __jamon_innerUnit__bc_by_file(final java.io.Writer jamonWriter, final CachedBlocksByFile cbsbf)
109    throws java.io.IOException
110  {
111    // 68, 1
112    jamonWriter.write("[");
113    // 68, 2
114    for (Map.Entry<String, NavigableSet<CachedBlock>> e: cbsbf.getCachedBlockStatsByFile().entrySet() )
115    {
116      // 68, 103
117      org.jamon.escaping.Escaping.HTML.write(org.jamon.emit.StandardEmitter.valueOf(BlockCacheUtil.toJSON(e.getKey(), e.getValue())), jamonWriter);
118    }
119    // 68, 163
120    jamonWriter.write("]\n");
121  }
122  
123  
124}