热部署在内部如何工作? [英] How hot deployment works internally?

查看:113
本文介绍了热部署在内部如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eclipse服务器功能进行热代码部署。使用tomcat作为Web服务器。但我不知道它是如何工作的。我有自己的理解,如何必须
在内部工作。



我的理解: - 当开发人员在代码中进行更改(称为Employee类)时,Eclipse会将修改的编译类放在/发布在右侧位置(必须是特定的Web /应用服务器,可以在webserver下将其称为热部署目录(HDD))。现在Web服务器特定的类加载器将进入图片。它在HDD下找到新条目。现在,它发现类是否已经由classloader在perm代理空间中加载,webserver将从permgen空间卸载它,并在内部加载新的,而不重新启动服务器,从而反映出新的更改(字节代码)。作为重新加载的一部分,网络服务器还将将现有的Epmloyee对象与permBase空间中的
新类定义相链接,以反映新的更改。



我的理解是否正确?



某些链接,如这个表示,Eclipse热部署只是重新部署的自动化。我相信这意味着eclipse会自动停止服务器,重新发布并重新启动它,而无需开发人员的干预。我认为这是不正确的,因为与开始/发布/重新启动相比,这个过程真的很快。
如果它是真的,会话和其他活动对象将如何在重新启动后保持活动?可能这个链接在过去是真的,但现在我发现在jar中的类的热部署工作

解决方案

热代码部署取决于运行时功能。您链接的答案并不意味着自动化停止服务器部署新的代码并再次启动服务器。这将是浪费的。



相反,大多数Java应用程序服务器都能够重新部署应用程序。这意味着服务器将创建一个新的Web应用程序类加载器,通过这个新的类加载器加载新版本的应用程序,在某些情况下它将迁移状态(序列化/反序列化HTTP会话),并删除旧版本的应用程序。



现在,重新部署速度在很大程度上取决于应用程序本身 - 应用程序如何初始化。是否需要预热缓存?它是否必须满足依赖(a-las Spring,CDI)?是否必须初始化Hibernate SessionFactory?涉及很多因素。什么Eclipse WTP自然就是可以触发应用程序容器的重新部署过程 - 就是这样。一个小应用程序当然不需要很长的时间重新部署。



除非有一个特殊的运行时技术/容器/框架,还有一个为Eclipse开发的专用连接器的一个钩子,将触发针对该特定技术更新的热代码。一个很好的例子是OSGi运行时的 bndtools



只是为了消除一些混乱:



通常人们会混淆 HotSwap 热部署。第一个,HotSwap,是JVM在运行时更新类定义的能力。后者是热部署,是应用程序服务器自动部署应用程序(无论是否增量)的能力,而不重新启动JVM进程。



所以我的答案是关于热部署,而不是HotSwap。因此,我将热部署称为自动化,而不是平台的基本机制。


I am using eclipse server capability for hot code deployment. Using tomcat as web server. But i am not sure how it works. I have my own understanding how it must be working internally.

My understanding :- When developer make the changes in code(say class Employee), Eclipse will place/publish the modified compiled class at right location(must be specific web/app server. lets call it hot deploy directory(HDD)) under webserver. Now web server specific class loader will come in to picture. It finds the new entry under HDD. Now, it finds if class has been already loaded by classloader in perm gen space, webserver will unload it from permgen space and load the new the one internally without server restart so that new changes(byte code) is reflected . As part of reload, webserver will also link the existing Epmloyee objects with new class definition in perm gen space so that new changes are reflected.

Is my understanding correct ?

Some links like this says Eclipse hot deployment is just automation of redeployment. what i believe it means is that eclipse automatically stop the server , republish and restart it without developer intervention. Buti i think its not true as this process is really quick as compared to start/publish/restart. Also if it would have been true, how session and other live objects will remain live after restart ? May be this link was true in past but not now as I find hot deployment works for classes in jar also

解决方案

Hot code deployment depends on the runtime capabilities. The answer you linked to does not mean that the automation stops the server deploys the new code and starts the server again. This would have been wasteful.

Instead, most of the Java application servers are able to redeploy the application. It means that the server would create a new web application class loader, load the new version of the application by this new class loader, in some cases it will migrate state (serialize/deserialize HTTP session), and drop the old version of the application.

Now the redeploy speed depends very much on the application itself -- how the application is initialized. Does it have to warmup caches? Does it have to satisfy the dependencies (a-las Spring, CDI)? Does it have to initialize Hibernate SessionFactory? Many factors are involved.

What Eclipse WTP naturally does is that it can trigger the redeployment process for the application container - that's it. A small application will not take long to redeploy, of course.

Unless there's a special runtime technology/container/framework and there is a special connector developed for Eclipse to take advantage of a hook that would trigger hot code updated for that specific technology. A good example is bndtools for OSGi runtime.

And just to remove some confusion:

Often people confuse HotSwap and hot deployment. The first one, HotSwap, is the ability of JVM to update class definition at runtime. The latter one, hot deployment, is the ability of application server to automatically deploy application, either incrementally or not, without restarting the JVM process.

So my answer is about hot deployment, and not about HotSwap. Hence I refer to hot deployment as an "automation" rather than a fundamental mechanism of the platform.

这篇关于热部署在内部如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆