简体   繁体   English

OSGi中的隔离

[英]Isolation within OSGi

I'm trying to understand the benefits of OSGi and what I can't understand is what happens if one of the user-supplied components crashes (for example with OutOfMemory exception). 我试图了解OSGi的好处,而我无法理解的是,如果用户提供的组件之一崩溃(例如OutOfMemory异常)会发生什么。 Will this problem be isolated just to this component or the complete JVM will crash? 是否仅将这个问题隔离到此组件上,否则整个JVM将崩溃?

OSGi isolates components at classloader level, and an OutOfMemoryError occurs at JVM level. OSGi在类加载器级别隔离组件,并且在JVM级别发生OutOfMemoryError。 OSGi does not provide "memory isolation". OSGi不提供“内存隔离”。 To answer shortly: the whole JVM will crash. 简短地回答:整个JVM将崩溃。

OSGi does not provide memory or CPU isolation between bundles or components. OSGi不提供捆绑或组件之间的内存或CPU隔离。 All bundles in an OSGi Framework run inside a Java Virtual Machine, and Java itself does not have the capability to offer this kind of isolation. OSGi框架中的所有捆绑软件都在Java虚拟机中运行,而Java本身不具备提供这种隔离的能力。 OSGi can only do things that are possible within the standard Java architecture. OSGi只能执行标准Java体系结构中可能做的事情。

If you want greater isolation, then use separate OS processes. 如果要进一步隔离,请使用单独的OS进程。 Remember though: there is no such thing as perfect isolation. 但是请记住:没有完美的隔离之类的东西。 If you run as separate processes there is always the chance that a rogue process can take down the entire OS. 如果您作为单独的进程运行,则流氓进程总是有可能破坏整个操作系统。 Even if you run on a separate computer in the same datacentre, then the next power cut or tsunami will affect both computers. 即使您在同一数据中心的另一台计算机上运行,​​下一次停电或海啸也会影响两台计算机。 So you have to ask yourself how much isolation is needed, and what specific risks you need to mitigate. 因此,您必须问自己,需要多少隔离,以及需要减轻哪些特定风险。

For what it's worth, there was an attempt within Java a long time ago to provide memory and CPU isolation. 值得一提的是,很久以前,Java内曾尝试提供内存和CPU隔离。 This was JSR-121 (Application Isolation API) and it was never adopted into Java SE. 这是JSR-121(应用程序隔离API),它从未被Java SE所采用。 Some vendors such as IBM and Waratek implemented proprietary isolation/multitenancy, but these did not catch on (Waratek later pivoted to application security). 一些供应商(例如IBM和Waratek)实现了专有的隔离/多租户,但是并没有流行(Waratek后来转向应用程序安全性)。 Basically you end up implementing a process scheduler within the JVM, and what's the point when the OS already has a good one? 基本上,您最终在JVM中实现了一个进程调度程序,那么操作系统已经有了一个好的调度程序又意味着什么呢?

OSGi Isolation is related to the class resolution and class loading. OSGi隔离与类解析和类加载有关。 JVM process itself is shared. JVM进程本身是共享的。 So OOM Exception will affect your whole container 因此,OOM异常会影响您的整个容器

If you want to run a 3rd party component, you may want to create a new instance (managed from your root container), it runs as a separate OS process with separate JVM parameters. 如果要运行第3方组件,则可能需要创建一个新实例(由您的根容器管理),该实例作为具有单独JVM参数的单独OS进程运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM