The spouts also have a number you can access through TopologyContext.getThisTaskIndex().
The DRPCSpout code does this and can be a good example. https://git.corp.yahoo.com/storm/storm/blob/master-security/storm-core/src/ jvm/backtype/storm/drpc/DRPCSpout.java#L118-119 Bobby On 5/7/14, 2:28 AM, "padma priya chitturi" <[email protected]> wrote: >Hi, > > This could be the way of specifying spouts: > >builder.setSpout("word-reader1",new ApiStreamingSpout1(),1); >builder.setSpout("word-reader2",new ApiStreamingSpout2(),1); > >So, define word-reader-1 to read tuples from even numbered files. >And for word-reader-2 to read from odd numbered files. > > > > >On Wed, May 7, 2014 at 12:41 PM, padma priya chitturi < >[email protected]> wrote: > >> Hi, >> >> Specifying the spout as above won't let you write separate piece of code >> as the executors/spout tasks would be executing same nextTuple method. >> Instead, to have intended behavior i.e to let one spout task read from >>even >> numbered files and other read from odd numbered files, try specifying >>the >> spouts as below: >> >> builder.setSpout("word-reader1",new ApiStreamingSpout(),1); >> builder.setSpout("word-reader2",new ApiStreamingSpout(),1); >> >> Now, for word-reader-1, define nextTuple in such a way that it reads >>from >> even numbered files. >> And for word-reader-2, define nextTuple to read from odd numbered files. >> >> I guess the above way of defining the spouts would work. >> >> >> On Tue, May 6, 2014 at 4:27 PM, Lydia Ickler >><[email protected]>wrote: >> >>> Hi there, >>> my name is Lydia and i am writing a program for my course „Parallel >>> Programming and Distributed Computing“. >>> >>> for example if i have a spout like this: >>> builder.setSpout("word-reader",new ApiStreamingSpout(),2); >>> >>> Within the spout: Is there a way to address each worker separately? >>> Like to tell one to read in all files that are even numbered and the >>> other one to take the odd numbered…? >>> Thanks in advance! >>> >>> Best regards, >>> Lydia >>> >>> >>> >>> >>
