Transient just tells java serialization that serialization should ignore the 
field mark as transient and does not play any role in deciding GC eligibility.

On worker side the bolt object's prepare method is called once during 
initialization of that object. The bolt object is just like any other instance 
so as long as the executors/tasks are running and referring to your instance, 
it should not be GC eligible.
If the worker dies and some other worker picks up the work it will call prepare 
again and you will get a new zookeeper instance.

Thanks
Parth


From: "Nick R. Katsipoulakis" 
<[email protected]<mailto:[email protected]>>
Date: Wednesday, January 28, 2015 at 3:44 PM
To: Parth Brahmbhatt 
<[email protected]<mailto:[email protected]>>
Cc: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: Non-serializable objects as Bolt members

I thought of transient, but the problem is that I want my ZooKeeper object to 
persist among consecutive invocations of the execute() function. Is the 
"transient" keyword going to guarantee the ZooKeeper object's persistence?

Reply via email to