If the data is not too big, I guess you may use Zookeeper, it's already
there and it's supposed to allow exactly the use case you want to cover...

On 21 May 2015 at 19:13, applyhhj <[email protected]> wrote:

>  Very clear answer, I guest I need to find other ways. Thank you very
> much!!
>
> 2015-05-21
> ------------------------------
>  ------------------------------
>
> *发件人:*Dima Dragan <[email protected]>
> *发送时间:*2015-05-21 12:02
> *主题:*Re: sharing data between tasks in the same bolt or spout
> *收件人:*"user"<[email protected]>
> *抄送:*
>
>  Hi,
>
> for 1 worker you can create a class with your static thread-safe
> collection and thread-safe initialization method (Double Checked Locking
> & volatile, for example) which return collection reference . In bolt`s
> prepare() method run init(). In this way all bolts will have the same ref
> to collection.
>
> for case with more than 1 worker, previous option will not work, cause
> each of worker has it`s own JVM process. You  will have to persist your
> collection in external database and implement static access to connection
> pool. Each of worker will have it`s own pool.
>
> On Thu, May 21, 2015 at 7:41 PM, applyhhj <[email protected]> wrote:
>
>>   Hi,
>>     Is it possible to share data between tasks of the same bolt or spout.
>> For example, a string list is set as the shared data and referenced by all
>> tasks of a bolt. Thank you very much!!
>>
>>
>>  2015-05-21
>> ------------------------------
>>
>
>
>
> --
>  Best regards,
> Dmytro Dragan
>
>
>


-- 

Carlos Perelló Marínhttps://www.serverdensity.com

Reply via email to