Using task id is a good idea. I don't recall if 0 or 1 is the lowest, but it's probably a good to use the lowest possible one for intialization, just in case you ever run a topology with only 1 bolt.
On Mon, Jul 27, 2015 at 8:02 AM, Denis DEBARBIEUX <[email protected]> wrote: > Dear all, > > I am writting a bolt. It is in charge of saving information in some > database (cassandra). In its prepare method, I am creating the table (CQL > query like CREATE TABLE IF NOT EXISTS ...). > > When I run my topology with many workers, I got a concurrent access > exception. Indeed, all my workers are creating the same table at the same > time. How to avoid this? > > My first idea is to elect one worker (e.g. base on the taskId) that will > create the table. Other worker will wait until the job is done. Is it a > good design? > > Thanks for your help. > > Denis > > --- > L'absence de virus dans ce courrier électronique a été vérifiée par le > logiciel antivirus Avast. > https://www.avast.com/antivirus > >
