If the bolt class is

class XXXBolt {
    private int x;
}

builder.setBolt("xxx", new XXXBolt(), 10).setNumTasks(20);

In jstorm there is no thread-safe problem on the field x.

And if
builder.setBolt("xxx", new XXXBolt(), 10)

There is no thread-safe problem in both storm and storm. Is that right?


On Thu, Nov 26, 2015 at 6:18 PM, 封仲淹(纪君祥) <[email protected]>
wrote:

>
> Please read this page http://storm.apache.org/documentation/Concepts.html
> firstly.
>
> Let me explain several conception:
>
> In storm,  one worker means one process, one executor means one thread,
> one task means one bolt or spout instance.
> In jstorm, worker means process, task also means one thread and one bolt
> or spout instance.  there is no executor.
>
>
>
> builder.setBolt("xxx", new XXXBolt(), 10);
>
> In storm,  this will create 10 executor, due to not set task parallel, the
> default ratio of executor and task is 1, there are 10 tasks, . Every task
> will occupy one executor (thread).
> In jstorm, this will create 10 tasks. Every task occupy one thread
>
>
> builder.setBolt("xxx", new XXXBolt(), 10).setNumTasks(20);
> In storm,  this will create 10 executor, 20 tasks,  Every two tasks will
> occupy one executor (thread).
> In jstorm, this will create 10 tasks.  Every task will occupy one thread.
>
>
> There is a little confusion between Storm and JStorm, but later in Storm
> 2.0, we will unify them.
>
> regards
> Longda
>
>
>
>
>
>
> ------------------------------------------------------------------
> From:Dollyn <[email protected]>
> Send Time:2015年11月26日(星期四) 17:54
> To:user <[email protected]>
> Subject:Will Storm/JStorm new a separate bolt instance for every
> task/thread?
>
> For example:
>
> builder.setBolt("xxx", new XXXBolt(), 10)
>
>
> Assume that there is only one worker, how many XXXBolt's java object
> instance will be there? 1 or 10?
>
>
> In fact, I did some test by add the following code in the execute method:
>
> LOGGER.debug("BoltID: {}, ThreadID: {} - {}",
> System.identityHashCode(this), Thread.currentThread().getName(),
> Thread.currentThread().getId());
>
> The result is:
>
> BoltID: 558207946, ThreadID: analyze_bolt:4-BoltExecutors - 107
> BoltID: 1052936813, ThreadID: analyze_bolt:5-BoltExecutors - 103
>
> Seems that there is instance for every thread, but can't be sure that will
> or not bolt instance will be reused among tasks/threads, and the document
> does not make this clear either.
>
>
> --
> Dollyn
>
>


-- 
Dollyn

Reply via email to