OSGi 功能卸载有效,但捆绑包仍然安装

发布于 2024-10-09 18:53:09 字数 1885 浏览 4 评论 0原文

编辑:用最新信息更新了这个问题...

我在运行依赖功能的连续“features:uninstall”命令时遇到问题。 OSGi 回复“状态更改正在进行中...”,但是通过接受其他请求,我们遇到了问题。

奇怪的是,这会导致功能卸载成功,但捆绑包卸载失败。我们正在通过尝试适当地排序卸载请求并在步骤之间添加延迟来解决此问题,但我希望有一个更强大的解决方案。

正如建议的那样,我还尝试在步骤之间添加“osgi:refresh”......相同的行为。是否有另一种方法可以检测“刷新包”仍在运行以延迟后续请求等?

这是详细信息...

karaf@root> features:uninstall PolicyUtil  
karaf@root> features:uninstall Policy1  
karaf@root> features:uninstall Policy2    
State change in progress for bundle "file:/policy2.jar" by thread "Refresh Packages".  
karaf@root> features:uninstall Policy3  
State change in progress for bundle "file:/policy3.jar" by thread "Refresh Packages".  
karaf@root> features:uninstall Policy4  
karaf@root> features:uninstall Enabler1    
State change in progress for bundle "file:/enabler1.jar" by thread "Refresh Packages".    
karaf@root> features:uninstall Enabler2  
State change in progress for bundle "file:/enabler2.jar" by thread "Refresh Packages".  

afterwards...we end up with features uninstalled (correct), but some bundles still installed (incorrect)

osgi:list

[ 277] [Installed  ] [            ] [       ] [   60] Policy2  
[ 278] [Installed  ] [            ] [       ] [   60] Policy3  
[ 280] [Installed  ] [            ] [       ] [   60] Enabler1  
[ 281] [Installed  ] [            ] [       ] [   60] Enabler2  

features:list

[uninstalled] [1.0                 ] PolicyUtil                           repo-0  
[uninstalled] [1.0                 ] Policy1                              repo-0  
[uninstalled] [1.0                 ] Policy2                              repo-0  
[uninstalled] [1.0                 ] Policy3                              repo-0  
[uninstalled] [1.0                 ] Enabler1                             repo-0  
[uninstalled] [1.0                 ] Enabler2                             repo-0  

EDIT: updated this question with latest information...

I'm having issues running back-to-back "features:uninstall" commands for dependent features. OSGi responds back with "State change in progress...", but by accepting other requests, we run into issues.

Strangely, this results in successful feature uninstalls, but unsuccessful bundle uninstalls. We are addressing this by trying to order uninstall requests appropriately and adding a delay between steps, but I'm hoping for a more robust solution.

As suggested, I also tried adding "osgi:refresh" in between steps...same behavior. Is there another way to detect that "Refresh Packages" is still running to delay subsequent requests, etc?

Here are the details...

karaf@root> features:uninstall PolicyUtil  
karaf@root> features:uninstall Policy1  
karaf@root> features:uninstall Policy2    
State change in progress for bundle "file:/policy2.jar" by thread "Refresh Packages".  
karaf@root> features:uninstall Policy3  
State change in progress for bundle "file:/policy3.jar" by thread "Refresh Packages".  
karaf@root> features:uninstall Policy4  
karaf@root> features:uninstall Enabler1    
State change in progress for bundle "file:/enabler1.jar" by thread "Refresh Packages".    
karaf@root> features:uninstall Enabler2  
State change in progress for bundle "file:/enabler2.jar" by thread "Refresh Packages".  

afterwards...we end up with features uninstalled (correct), but some bundles still installed (incorrect)

osgi:list

[ 277] [Installed  ] [            ] [       ] [   60] Policy2  
[ 278] [Installed  ] [            ] [       ] [   60] Policy3  
[ 280] [Installed  ] [            ] [       ] [   60] Enabler1  
[ 281] [Installed  ] [            ] [       ] [   60] Enabler2  

features:list

[uninstalled] [1.0                 ] PolicyUtil                           repo-0  
[uninstalled] [1.0                 ] Policy1                              repo-0  
[uninstalled] [1.0                 ] Policy2                              repo-0  
[uninstalled] [1.0                 ] Policy3                              repo-0  
[uninstalled] [1.0                 ] Enabler1                             repo-0  
[uninstalled] [1.0                 ] Enabler2                             repo-0  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

夜空下最亮的亮点 2024-10-16 18:53:09

我不确定你会得到什么样的异常,但你应该知道一件事:当你使用 shell 命令(如 osgi:uninstall)卸载捆绑包时,你实际上调用了 Bundle.uninstall()< /a>.正如您可以在 Javadoc 中读到的那样,这并不是故事的全部。

该框架倾向于对框架其余部分影响最小的操作,因此它可以卸载捆绑包,而无需删除所有相关包。如果您确实想删除所有这些,您应该使用 osgi:refresh 命令。有关详细信息,请参阅 菲利克斯常见问题解答

我能给出的最好建议是不要发出多个可能相互交叉的卸载请求。如果您想删除一组捆绑包,我会触发非交叉 uninstall() 请求,后跟单个 refreshPackages()。另外,我不会在单个系统中混合使用“常规”控制台和 Karaf 进行捆绑管理。

您还可以考虑使用外部管理器来安装和删除捆绑包。如果您想要远程管理,您可以选择 Apache ACE (声明:我是 Apache ACE 提交者)。

I'm not sure what kind of exception you will get, but you should be aware of one thing: when you uninstall a bundle using a shell command like osgi:uninstall, you effectively call Bundle.uninstall(). As you can read in the Javadoc there, this is not the entire story.

The framework favors operations that have minimal impact on the rest of the framework, so it can uninstall a bundle without removing all related packages. If you really want to remove all of them, you should use a osgi:refresh command. For more information on this, see the Felix FAQ.

The best advice I can give is to not issue multiple uninstall requests that can cross each other. If you want to remove a set of bundles, I would fire off non-crossing uninstall() requests, followed by a single refreshPackages(). Also, I would not mix bundle management using the 'regular' console and Karaf in a single system.

You could also consider using an external manager for installing and removing bundles. If you want remote management, you could go for Apache ACE (disclosure: I'm an Apache ACE committer).

往昔成烟 2024-10-16 18:53:09

或者...您可以使用以下命令简单地卸载您的应用程序:

karaf 2.2.x:

osgi:uninstall --force yourapp-feature/0.0.1.SNAPSHOT

Oor ... you can simple uninstall your app with this command:

karaf 2.2.x:

osgi:uninstall --force yourapp-feature/0.0.1.SNAPSHOT

梦途 2024-10-16 18:53:09

好吧,我一直在研究这个问题,我想我理解这个问题和选项......感谢您的回复。

当执行“features:uninstall [name]”时,它会为功能中的每个包调用bundle.uninstall(),然后调用refreshPackages()。然后,在卸载所有捆绑包后,它会为所有捆绑包调用refreshPackages()。问题是,refreshPackages() 是异步的(根据 OSGi 规范)并将包留在解决状态。后续卸载解析功能/捆绑包的请求无法按预期完成。

如果卸载之间有足够的延迟,或者如果稍后执行卸载(在refreshPackages()完成之后)...一切都会按预期进行。

选项...

  1. 卸载期间顺序相关的功能/捆绑包(难以控制)
  2. 在卸载命令之间设置延迟(不准确)
  3. 验证预期的功能/捆绑包是否已卸载(或继续等待)
  4. 侦听 FrameworkEvent.PACKAGES_REFRESHED 事件(复杂且不能保证 )因为事件是容器范围的,请参阅此示例
  5. 修改Karaf/Felix 支持同步刷新包的选项(请参阅此问题/解决方案对于卡拉夫 2.1.3)

Alright, I've been digging into this and I think I understand the issue and the options...thanks for the responses.

When "features:uninstall [name]" is executed, it calls bundle.uninstall(), then refreshPackages() for each bundle in the features. Then, after all bundles are uninstalled, it calls refreshPackages() for all bundles. The issue is that refreshPackages() is asynchronous (per the OSGi spec) and leaves bundles in a resolving state. Subsequent requests to uninstall resolving features/bundles fail to complete as expected.

If there is sufficient delay in between uninstalls or if a later uninstall is executed (after the refreshPackages() has completed)...everything works as expected.

Options...

  1. order dependent features/bundles during uninstallation (difficult to control)
  2. put a delay in between uninstall commands (not exact)
  3. verify expected features/bundles are uninstalled (or continue waiting)
  4. listen for FrameworkEvent.PACKAGES_REFRESHED events (complex and not guaranteed because events are container wide, see this example)
  5. modify Karaf/Felix to support an option for synchronously refreshing packages (see this issue/resolution for Karaf 2.1.3)
掌心的温暖 2024-10-16 18:53:09

根据我的经验,当一个包的资源仍然被另一个包引用或使用时,就会发生这种情况。在这种情况下,框架无法删除捆绑包,并且整个 jar 文件仍由 VM 处理。

查看并确保所有引用均已删除。一个常见的错误是仍在捆绑中实例化的对象之一中运行线程。这也算作仍在使用的资源广告,无法删除。

In my experience this happens when a resource of a bundle is still referenced or used by another bundle. In this case the framework is not able to remove the bundle and the whole jar file is still processed by the VM.

Have a look and be sure that all references are removed. A common mistake is also still running thread in one of the objects instantiated in the bundle. This also counts as a resource still in use ad which cannot be removed.

七七 2024-10-16 18:53:09

就我而言,我已经卸载了该功能并注意到悬挂的捆绑包编号,然后关闭了 karaf (3.x)。然后我删除了文件夹 [karaf-install]/data/cache/[hanging-bundle-number] 的子文件夹。
现在我重新启动 karaf 并且捆绑包战争未显示在捆绑包:列表中。

In my case i have uninstalled the feature and noticed the hanging bundle numbers and then shutdown karaf (3.x). Then i have removed the subfolders of folder [karaf-install]/data/cache/[hanging-bundle-number].
Now i restart karaf and the bundle wars not shown in the bundle:list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文