[英]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系统创建看门狗,则可以使用以下两种方法之一:
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.