java


1. 如何标示一行log输入哪一个函数?

简单点儿的:

this.getClass().getName();
this.getClass().getCanonicalName();

使用StackTrace, 获得调用该函数时的stack,取某一个位置上的,就是自己了,应该是栈顶, 即element[0].

void getStackTrace() {
        StackTraceElement[] element =new Throwable().getStackTrace();
        for (int i=0; i<element.length; ++i){
            logger.error(element[i].toString());
//            Object.class
//            public final native Class<?> getClass();
//            System.out.println("i=" + i + ", className: "+  element[i].getClassName());
//            System.out.println("i=" + i + ", LineNO: "+ element[i].getLineNumber());
//            System.out.println("i=" + i + ", FileName: "+ element[i].getFileName());
//            System.out.println("i=" + i + ", MethodName: "+ element[i].getMethodName());
        }

2.  Exception:  GC overhead limit exceeded

java.lang.OutOfMemoryError: GC overhead limit exceeded
分析:这个是JDK6新添的错误类型。是发生在GC占用大量时间为释放很小空间的时候发生的,是一种保护机制。解决方案是,关闭该功能,可以添加JVM的启动参数来限制使用内存: -XX:-UseGCOverheadLimit
添加位置是:mapred-site.xml 里新增项:mapred.child.java.opts 内容:-XX:-UseGCOverheadLimit
java.lang.OutOfMemoryError: Java heap space
出现这种异常,明显是jvm内存不够得原因,要修改所有的datanode的jvm内存大小。
Java -Xms1024m -Xmx4096m
一般jvm的最大内存使用应该为总内存大小的一半,我们使用的8G内存,所以设置为4096m,这一值可能依旧不是最优的值。(其实对于最好设置为真实物理内存大小的0.8


更权威的:http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html


链接:http://blog.sina.com.cn/s/blog_959d2248010194x0.html

##### ERROR------------------------------------------------------------------------------------------
##### ERROR stack trace
org.broadinstitute.sting.utils.exceptions.ReviewedStingException:An error occurred during the traversal. Message=GC overhead limit exceeded
              atorg.broadinstitute.sting.gatk.executive.HierarchicalMicroSchedul er.toRuntimeException(HierarchicalMicroSchedul er.java:368)
              atorg.broadinstitute.sting.gatk.executive.HierarchicalMicroSchedul er.notifyOfTraversalError(HierarchicalMicroSchedul er.java:359)
              atorg.broadinstitute.sting.gatk.executive.ShardTraverser.call(ShardTraverser.java:84)
              atjava.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
              at java.util.concurrent.FutureTask.run(FutureTask.java:166)
              atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
              atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
              at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.OutOfMemoryError: GC overhead limitexceeded
              atorg.broadinstitute.sting.gatk.walkers.genotyper.AlleleFrequencyCalculati onModel$ExactACset.(AlleleFrequencyCalculati onModel.java:190)
              atorg.broadinstitute.sting.gatk.walkers.genotyper.ExactAFCalculationModel.updateACset(ExactAFCalculationModel.java:242)
              atorg.broadinstitute.sting.gatk.walkers.genotyper.ExactAFCalculationModel.calculateAlleleCountConf ormation(ExactAFCalculationModel.java:225)
              atorg.broadinstitute.sting.gatk.walkers.genotyper.ExactAFCalculationModel.linearExactMultiAllelic(ExactAFCalculationModel.java:139)
              atorg.broadinstitute.sting.gatk.walkers.genotyper.ExactAFCalculationModel.getLog10PNonRef(ExactAFCalculationModel.java:64)
              atorg.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyperEngine.calculateGenotypes(UnifiedGenotyperEngine.java:470)
              atorg.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyperEngine.calculateLikelihoodsAndG enotypes(UnifiedGenotyperEngine.java:192)
              atorg.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyper.map(UnifiedGenotyper.java:353)
              atorg.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyper.map(UnifiedGenotyper.java:119)
              atorg.broadinstitute.sting.gatk.traversals.TraverseLoci.traverse(TraverseLoci.java:65)
              atorg.broadinstitute.sting.gatk.traversals.TraverseLoci.traverse(TraverseLoci.java:18)
              atorg.broadinstitute.sting.gatk.executive.ShardTraverser.call(ShardTraverser.java:70)
              ... 5 more
##### ERROR------------------------------------------------------------------------------------------
##### ERROR A GATK RUNTIME ERROR has occurred (version2.0-35-gb3e7fbe):
##### ERROR
##### ERROR Please visit the wiki to see if this is a knownproblem
##### ERROR If not, please post the error, with stack trace, to theGATK forum
##### ERROR Visit our website and forum for extensive documentationand answers to
##### ERROR commonly asked questions http://www.broadinstitute.org/gatk
##### ERROR
##### ERROR MESSAGE: An error occurred during thetraversal.  Message=GC overhead limitexceeded
##### ERROR------------------------------------------------------------------------------------------
finish at time 2012-10-22 21:02
 

问题产生原因:

根据sun的说法: "if too much time is being spent in garbagecollection: if more than 98% of the total time is spent in garbagecollection and less than 2% of the heap is recovered, anOutOfMemoryError will be thrown."

jvm gc行为中超过98%以上的时间去释放小于2%的堆空间时会报这个错误。

处理方法:

1. 在jvm启动参数中添加"-XX:-UseGCOverheadLimit",该参数在JDK6中默认启用("-XX:+UseGCOverheadLimit")。

  调整后的生产环境中使用的参数为:   

JAVA_OPTS='-Xms512m -Xmx4096m -XX:MaxPermSize=128m -XX:-UseGCOverheadLimit -XX:+UseConcMarkSweepGC'

2. 检查是否有使用了大量内存的代码或死循环

3. 使用jstat命令监控gc行为是否正常

  jstat监控gc的命令格式为:

  jstat -gcutil [-t] [-h] [[]] 

  vmid为JVM进程id,可以用ps -ef 或 jps -lv命令查找。

  以下命令为每1秒钟输出一次gc状态,共输入5次

  S0     S1                YGC     YGCT    FGC    FGCT     GCT   

  0.00  93.34  85.63  82.95  59.73   1085   33.351    58    4.396   37.748

 98.42   0.00  31.89  83.52  59.73   1088   33.487    58    4.396   37.883

100.00  85.65 100.00  84.08  59.73   1091   33.554    58    4.396   37.950

  0.00 100.00  54.30  84.49  59.73   1093   33.660    58    4.396   38.057

 98.25   0.00  10.46  85.11  59.73   1096   33.768    58    4.396   38.164
  经过一段时间的观察,确认是否正确

3. jstat 命令:


4. http://jtidy.sourceforge.net/apidocs/org/w3c/tidy/ant/JTidyTask.html

http://jtidy.sourceforge.net/howto.html

http://www.infoq.com/articles/introductionOozie

http://simile.mit.edu/wiki/Piggy_Bank

piggybank


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值