简体   繁体   English

在OSGI中检查捆绑包是否仍在正常运行

[英]Checking in OSGI if a bundle is still operating normally

I'm currently making a watchdog to check if all bundles in a pipeline are still functioning properly. 我目前正在做一个看门狗,以检查管道中的所有捆绑包是否仍然正常运行。 (This will be in a distributed environment so failure can be a network failure, software failure, one of the servers failing, ...) (这将在分布式环境中,因此故障可能是网络故障,软件故障,其中一台服务器发生故障,...)

Because a bundle can be bound to N amount of services, N arbitrary, the checking should will happen recursively using the following methodology: 由于捆绑包可以绑定到N个服务数量(任意N个),因此应使用以下方法递归进行检查:

START at the first step in the pipeline
Use getServicesInUse to get the services references of the next step
use getBundle() on the gathered ServiceRerefence objects
REPEAT until we arrive at the bundle we want to stop at

So that way I can get all the bundle objects of the pipeline (I assume) now to check if they are functioning correctly (or just if they are still reachable) I was wondering if 这样一来,我现在就可以获取管道的所有捆绑对象(我假设)来检查它们是否正常运行(或者是否仍然可以访问),我想知道是否

Bundle b = ...
if(b.getState() == Bundle.ACTIVE) ...;

will do the trick? 会成功吗? Ofcourse also surrounding this with the necessary try catch clauses to detect hardware/network failure. 当然,这也包含必要的try catch子句以检测硬件/网络故障。

Can you clarify what you mean by "all bundles in a pipeline"? 您能否阐明“管道中的所有捆绑包”的含义?

You are right that a bundle can provide and consume zero or more services, but if I were to create a watchdog for an OSGi system I would use one of two approaches: 没错,捆绑包可以提供和使用零个或多个服务,但是如果我要为OSGi系统创建看门狗,则可以使用以下两种方法之一:

  1. If the nodes in your distributed system provide mainly REST services, I would write a separate "watchdog" program that monitors these REST services to see if they still respond (on any of the nodes in my distributed system). 如果您的分布式系统中的节点主要提供REST服务,我将编写一个单独的“看门狗”程序来监视这些REST服务,以查看它们是否仍然响应(在我的分布式系统中的任何节点上)。 You can either make "real" calls or just request some HEAD and see if you get a response. 您可以进行“真实”调用,也可以仅请求一些HEAD,然后查看是否得到响应。
  2. If the nodes in your distributed system provide mainly OSGi services, I would write a watchdog bundle and deploy that to each node. 如果您的分布式系统中的节点主要提供OSGi服务,我将编写一个看门狗捆绑包并将其部署到每个节点。 I would then add a REST endpoint to my watchdog to allow me to monitor it remotely (by another watchdog, similar to approach #1). 然后,我将REST端点添加到我的看门狗中,以允许我远程监视它(通过另一个看门狗,类似于方法1)。

Checking the active state of a bundle will tell you nothing. 检查包的活动状态不会告诉您任何信息。 Bundles will remain active once started, but the services they provide could be unresponsive. 捆绑包一旦启动,将保持活动状态,但是它们提供的服务可能没有响应。

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

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