I want to fly higher
programming Explorer
posts - 114,comments - 263,trackbacks - 0
1.我为什么用JRebel ?
    Becuase Spring-Loaded 1.2.3 can't reload classes packaged in JAR files. This is coming in the next release, 1.2.4.
        即Spring-Loaded 1.2.3不支持reload jar,而这个特性是我最关心的

2.JRebel在eclipse reload class的话和spring-loaded基本一致,可参考我写的这篇文章:http://www.blogjava.net/landon/archive/2015/06/19/425797.html
    VmArguments:
        -agentpath:C:\Users\pc\Desktop\jrebel-6.2.0-crack\lib\jrebel64.dll -noverify
    注:1.本人用的是6.2.0的破解版本,如何获取该版本,我不予置评。
          2.对于-javaagent模式,我本地测试并卵,所以用了-agentpath模式,测试Ok.

3.如何确定JRebel启动成功并reload了classes
    这是我在eclipse中测试的一个输出:
  六月 26, 2015 10:40:26 上午 java.util.prefs.WindowsPreferences <init>
  WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx() returned error code 5.
  2015-06-26 10:40:29 JRebel:  
  2015-06-26 10:40:29 JRebel:  #############################################################
  2015-06-26 10:40:29 JRebel:  
  2015-06-26 10:40:29 JRebel:  JRebel Agent 6.2.0 (201505201205)
  2015-06-26 10:40:29 JRebel:  (c) Copyright ZeroTurnaround AS, Estonia, Tartu.
  2015-06-26 10:40:29 JRebel:  
  2015-06-26 10:40:29 JRebel:  Over the last 1 days JRebel prevented
  2015-06-26 10:40:29 JRebel:  at least 1 redeploys/restarts saving you about 0 hours.
  2015-06-26 10:40:29 JRebel:  
  2015-06-26 10:40:29 JRebel:  Licensed to anonymous-user
  2015-06-26 10:40:29 JRebel:   with the following restrictions: 
  2015-06-26 10:40:29 JRebel:   ####### Cracked by anonymous-user, For FUN! Unlimited! Enjoy! ######
  2015-06-26 10:40:29 JRebel:  
  2015-06-26 10:40:29 JRebel:  License type: perpetual
  2015-06-26 10:40:29 JRebel:  
  2015-06-26 10:40:29 JRebel:  
  2015-06-26 10:40:29 JRebel:  #############################################################
  2015-06-26 10:40:29 JRebel:  
  2015-06-26 10:40:29 JRebel: 
  2015-06-26 10:40:29 JRebel: A newer version '6.2.1' is available for download 
  2015-06-26 10:40:29 JRebel: from http://zeroturnaround.com/software/jrebel/download/
  2015-06-26 10:40:29 JRebel: 
  reload
  reload
  reload
  reload
  reload
  reload
  reload
  2015-06-26 10:40:49 JRebel: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx() returned error code 5.
  reload
  2015-06-26 10:40:51 JRebel: Reloading class 'com.mavsplus.example.springloaded.Reload'.
  load
  load
  load

4.JRebel如何reload classes in jar
    这个是我关心的重点,因为我做的是游戏服务器开发,线上部署的通常是一个jar,然后指定jvm参数,脚本启动。如线上可以分为一个mainLaunch.jar,一个reloadLogic.jar,后者jar为可reload的逻辑代码。那么问题就是线上如果需要更新reloadLogic.jar,怎么办?用JRebel.
    1. startup.bat 启动脚本(脱离eclipse)
@echo off

cd /d %~dp0

java  -Drebel.dirs=E:\mavsplus\reload\classes
-Drebel.log=true 
-agentpath:C:\Users\pc\Desktop\jrebel-6.2.0-crack\lib\jrebel64.dll 
-noverify 
-cp mainLaunch.jar;reloadLogic.jar com.mavsplus.example.jrebel.JRebelExample   
     -Drebel.dirs用来指定Jrebel监视reloadLogic.jar的class变化,即如果我们线上想更新reloadLogic.jar时,可以打包新的reloadLogic.jar->上传到该目录->解压->classes至该目录
        -->该目录发生变化,则线上reloadLogic.jar的业务也会马上变化

5.JRebel是否可用于线上生产环境?
    1.引用JRebelWhitePaper2014.pdf的一段话:
        JRebel is a –javaagent plugin for the JVM. It's a downloadable .jar file, available as a standalone .zip distribution or as an IDE plugin for Eclipse, IntelliJ IDEA or NetBeans IDE. 【JRebel will cause around 10-15% performance overhead, however during development this is more or less unnoticeable, unlike in the production environment.】
        即JRebel会有很大的性能损失,所以不建议生产环境使用,只建议开发环境,方便部署和调试。
    2.那么我就想用JRebel在线上生产环境怎么办?
        zeroturnaround公司之前还有一个产品叫做liverebel,可用于线上环境。但是由于未能引起足够的消费者关注,所以在2014年11月也停止了。。。
    3.其实JRebel和Spring-Loaded就是一个开发环境下的利器,skip build and redeploy process,大大提升了工作效率!而非生产环境的利器。。。因为线上reload本来风险就很大。

6. 其他相关
    1. https://docs.oracle.com/javase/8/docs/technotes/guides/jpda/
    2. https://wikis.oracle.com/display/mlvm/HotSwap
    3. http://www.hotswapagent.org/
    4. https://github.com/dcevm/dcevm

7.后续
   我会继续研究Java的HotSwap/HotDeploy/HotReplace/OSGI等
posted on 2015-06-26 18:48 landon 阅读(4648) 评论(0)  编辑  收藏 所属分类: JVMHotSwap

只有注册用户登录后才能发表评论。


网站导航: