Hi!
I am trying to restart a bundle (within the very same bundle)
programmatically. For this purpose, I come up with two solutions.
First one is a manual stop-and-start approach:
Bundle bundle = bundleContext.getBundle();
bundle.stop();
if (bundle.getState() == Bundle.RESOLVED)
bundle.start();
And second one uses bundle.update() mechanism:
bundleContext.getBundle().update();
I call these methods (within the very same bundle) from a separate
Thread as follows.
new Thread(new Runnable() {
@Override
public void run() {
logger.warn("Restarting the OSGi bundle...");
// restart code goes here
}
}).start();
The problem is, while stopping the bundle, I receive
o.s.o.e.i.u.c.RunnableTimedExecution errors.
16:21:32.566 [Thread-14] WARN n.b.cluster.LifecycleOperator -
Restarting the OSGi bundle...
16:21:32.578 [Spring DM context shutdown thread] INFO
n.b.cluster.LifecycleOperator - Shutdown.
16:21:32.579 [Spring DM context shutdown thread] INFO
n.b.cluster.RouteOperator - Stopped.
16:21:32.579 [Spring DM context shutdown thread] INFO
n.b.cluster.TopologyOperator - Stopped.
16:21:32.579 [Spring DM context shutdown thread] INFO
n.b.cluster.DeviceOperator - Stopped.
16:21:32.702 [hz._hzInstance_1_openflow-cluster.cached.thread-4]
DEBUG n.b.cluster.ZoneOperator - Controller 192.168.56.102 joins the
cluster.
16:21:32.819 [Spring DM context shutdown thread] INFO
n.b.cluster.ZoneOperator - Stopped.
16:21:32.819 [Spring DM context shutdown thread] DEBUG
n.b.cluster.SwitchOperator - Stopped.
16:21:35.614 [Thread-14] ERROR
o.s.o.e.i.u.c.RunnableTimedExecution - Closing runnable for context
OsgiBundleXmlApplicationContext(bundle=no.beef.cluster,
config=osgibundle:/META-INF/spring/*.xml) did not finish in 10000ms;
consider taking a snapshot and then shutdown the VM in case the thread
still hangs
But as above message output indicates, it does not even wait for
10000ms. Restart initiated at 16:21:32 and RunnableTimedExecution is
thrown at 16:21:35, that is, there is a period of ~3 seconds, not 10.
What might I be missing? I am probably leaving something behind and it
blocks to whole execution to RunnableTimedExecution. How can I further
diagnose the error? Is it possible to increase the verbosity level of
the RunnableTimedExecution errors?
Regards.
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev