: Hello - i need to run a thread on a single instance of a cloud so need 
: to find out if current node is the overseer. I know we can already 
: programmatically find out if this replica is the leader of a shard via 
: isLeader(). I have looked everywhere but i cannot find an isOverseer. I 

At one point, i woked up a utility method to give internal plugins 
access to an "isOverseer()" type utility method...

   https://issues.apache.org/jira/browse/SOLR-5823

...but ultimately i abandoned this because i was completley forgetting 
(until much much too late) that there's really no reason to assume that 
any/all collections will have a single shard on the same node as the 
overseer -- so having a plugin that only does stuff if it's running on the 
overseer node is a really bad idea, because it might not run at all. (even 
if it's configured in every collection)


what i ultimately wound up doing (see SOLR-5795) is implementing a 
solution where every core (of each collection configured to want this 
functionality) has a thread running (a TimedExecutor) which would do 
nothing unless...
 * my slice is active? (ie: not in the process of being shut down)
 * my slice is 'first' in a sorted list of slices?
 * i am currently the leader of my slice?

...that way when the timer goes off ever X minutes, at *most* one thread 
fires (we might sporadically get no evens triggered if/when there is 
leader election in progress for the slice that matters)

the choice of "first" slice name alphabetically is purely becuase it's 
something cheap to compute and garunteeded to be unique.


If you truly want exactly one thread for the entire cluster, regardless of 
collection, you could do the same basic idea by just adding a "my 
collection is 'first' in a sorted list of collection names?"



-Hoss
http://www.lucidworks.com/

Reply via email to