Unable to figure out how to shutdown netty

509 views
Skip to first unread message

Dhananjay Nene

unread,
Aug 9, 2011, 2:08:23 AM8/9/11
to akka...@googlegroups.com
I am having a difficulty shutting down (most likely) netty threads.

I've started an embedded OSGi container in two different apps (one client / one server), the server starts an actor, the client sends messages to it (at the moment messaging is only one way).

I issue framework shutdown, which in turn issues bundle shutdowns which in turn on the server triggers a Actor.remote.unregister, actor.stop, and actor.shutdownAll, after which even the OSGi call to waitForStop() returns successfully (thus all OSGi tasks are now also over). Presumably at this stage both the processes should've shutdown. Yet both of them have running threads which now get into trouble (in this case specifically since even the classloaders can no longer work since OSGi has as well shutdown).

Question : Do I need to do anything in addition to unregister/stop/and shutdownAll ? Especially for netty since the active thread seems to be a netty thread.

I did attempt to look up akka documentation but could not find anything specific.

Akka version : 1.1.3
Scala : 2.9.0.1

Thanks
Dhananjay

Logs for reference appended below.

--------------------- Server Log -------------------------
OSGi Framework stopped
ERROR: Bundle akka-combined [1] Unable to get module class path. (java.lang.IllegalStateException: zip file closed)
java.lang.IllegalStateException: zip file closed
        at java.util.zip.ZipFile.ensureOpen(ZipFile.java:416)
        at java.util.zip.ZipFile.getEntry(ZipFile.java:161)
        at org.apache.felix.framework.util.ZipFileX.getEntry(ZipFileX.java:52)
        at org.apache.felix.framework.cache.JarContent.getEntryAsContent(JarContent.java:231)
        at org.apache.felix.framework.ModuleImpl.calculateContentPath(ModuleImpl.java:620)
        at org.apache.felix.framework.ModuleImpl.initializeContentPath(ModuleImpl.java:571)
        at org.apache.felix.framework.ModuleImpl.getContentPath(ModuleImpl.java:557)
        at org.apache.felix.framework.ModuleImpl.access$800(ModuleImpl.java:72)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1850)
        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:752)
        at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at akka.dispatch.MessageDispatcher$$anon$1.run(MessageHandling.scala:167)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)

---------------- Client log -----------------
OSGi Framework stopped
ERROR: Bundle akka-combined [1] Unable to get module class path. (java.lang.IllegalStateException: zip file closed)
java.lang.IllegalStateException: zip file closed
ERROR: Bundle akka-combined [1] Unable to get module class path. (java.lang.IllegalStateException: zip file closed)
        at java.util.zip.ZipFile.ensureOpen(ZipFile.java:416)
        at java.util.zip.ZipFile.getEntry(ZipFile.java:161)
        at org.apache.felix.framework.util.ZipFileX.getEntry(ZipFileX.java:52)
        at org.apache.felix.framework.cache.JarContent.getEntryAsContent(JarContent.java:231)
        at org.apache.felix.framework.ModuleImpl.calculateContentPath(ModuleImpl.java:620)
        at org.apache.felix.framework.ModuleImpl.initializeContentPath(ModuleImpl.java:571)
        at org.apache.felix.framework.ModuleImpl.getContentPath(ModuleImpl.java:557)
        at org.apache.felix.framework.ModuleImpl.access$800(ModuleImpl.java:72)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1850)
        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:752)
        at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
        at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
        at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
        at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:519)
        at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:440)
        at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:379)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at java.lang.Thread.run(Thread.java:662)
java.lang.IllegalStateException: zip file closed
        at java.util.zip.ZipFile.ensureOpen(ZipFile.java:416)
        at java.util.zip.ZipFile.getEntry(ZipFile.java:161)
        at org.apache.felix.framework.util.ZipFileX.getEntry(ZipFileX.java:52)
        at org.apache.felix.framework.cache.JarContent.getEntryAsContent(JarContent.java:231)
        at org.apache.felix.framework.ModuleImpl.calculateContentPath(ModuleImpl.java:620)
        at org.apache.felix.framework.ModuleImpl.initializeContentPath(ModuleImpl.java:571)
        at org.apache.felix.framework.ModuleImpl.getContentPath(ModuleImpl.java:557)
        at org.apache.felix.framework.ModuleImpl.access$800(ModuleImpl.java:72)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1850)
        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:752)
        at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
        at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:239)
        at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:519)
        at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:440)
        at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:379)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at java.lang.Thread.run(Thread.java:662)
9 Aug, 2011 11:26:03 AM org.jboss.netty.util.HashedWheelTimer
WARNING: An exception was thrown by TimerTask.
java.lang.NullPointerException
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1853)
        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:752)
        at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
        at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:239)
        at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:519)
        at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:440)
        at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:379)
        at java.lang.Thread.run(Thread.java:662)

--
----------------------------------------------------------------------------------------------------------------------------------
http://blog.dhananjaynene.com twitter: @dnene google plus: http://gplus.to/dhananjaynene

√iktor Ҡlang

unread,
Aug 9, 2011, 3:14:10 AM8/9/11
to akka...@googlegroups.com
Actor.remote.shutdown ?


--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.



--
Viktor Klang

Akka Tech Lead
Typesafe - Enterprise-Grade Scala from the Experts

Twitter: @viktorklang

Dhananjay Nene

unread,
Aug 9, 2011, 3:37:00 AM8/9/11
to akka...@googlegroups.com
Viktor,

Didn't help. :(

Whats the right order of invoking the following? I have it currently set up as the following. I think I have all the steps .. don't know if they are in the correct order

      Actor.remote.unregister("my.package.actor")
      actor.stop()
      Actor.registry.shutdownAll()
      Actor.remote.shutdown();

Also the client process right now does not start an actor. - it only does

actor = Actor.remote.actorFor("my.package.actor", "localhost", 2552)
actor ! message

Any cleanup steps required here for the client ?

Dhananjay

2011/8/9 √iktor Ҡlang <viktor...@gmail.com>

√iktor Ҡlang

unread,
Aug 9, 2011, 3:41:35 AM8/9/11
to akka...@googlegroups.com
On Tue, Aug 9, 2011 at 9:37 AM, Dhananjay Nene <dhananj...@gmail.com> wrote:
Viktor,

Didn't help. :(

Whats the right order of invoking the following? I have it currently set up as the following. I think I have all the steps .. don't know if they are in the correct order

      Actor.remote.unregister("my.package.actor")
      actor.stop()
      Actor.registry.shutdownAll()
      Actor.remote.shutdown();

Also the client process right now does not start an actor. - it only does

actor = Actor.remote.actorFor("my.package.actor", "localhost", 2552)
actor ! message

Any cleanup steps required here for the client ?

Actor.remote.shutdown?

I'm sorry, I don't understand what you're trying to achieve, could you reiterate?
 

Dhananjay Nene

unread,
Aug 9, 2011, 3:48:06 AM8/9/11
to akka...@googlegroups.com


2011/8/9 √iktor Ҡlang <viktor...@gmail.com>



On Tue, Aug 9, 2011 at 9:37 AM, Dhananjay Nene <dhananj...@gmail.com> wrote:
Viktor,

Didn't help. :(

Whats the right order of invoking the following? I have it currently set up as the following. I think I have all the steps .. don't know if they are in the correct order

      Actor.remote.unregister("my.package.actor")
      actor.stop()
      Actor.registry.shutdownAll()
      Actor.remote.shutdown();

Also the client process right now does not start an actor. - it only does

actor = Actor.remote.actorFor("my.package.actor", "localhost", 2552)
actor ! message

Any cleanup steps required here for the client ?

Actor.remote.shutdown?

I'm sorry, I don't understand what you're trying to achieve, could you reiterate?

a. I have two independent separate processes - eventually they will send messages to each other. For now only one of them sends messages (therefore I call one client & the other server)
b. Each process starts an OSGi container
c. The OSGi container starts a bunch of bundles. In this case the server bundle starts an actor and registers it. The client bundle looks up the remote actor reference and sends it a message.
d. Now upon both processes getting shutdown, I am facing a situation where the actor shutdown and then the osgi framework shutdown both get invoked and completed. However at least one thread continues to run in each case. I am now trying to ensure that shutdown ensures everything gets shutdown cleanly and the processes terminate (not continue with some threads still running .. which in this case they do, and keep failing because the OSGi container has already shutdown thus classloading being no longer feasible).

Dhananjay
Reply all
Reply to author
Forward
0 new messages