And if fact I used this for Lucene index rebuilds on VM failures.

Sent from my iPhone

> On 27 Jun 2015, at 14:44, Lyndon Adams <[email protected]> wrote:
> 
> Yes I have needed this before and written code to support this function.
> 
> Sent from my iPhone
> 
>> On 27 Jun 2015, at 14:40, Anthony Baker <[email protected]> wrote:
>> 
>> Has anyone used (or needed) an HAComponent pattern before?  The object would 
>> be instantiated on each member of the cluster but only “activated” on one 
>> node.  If that node fails or is shutdown another member will automatically 
>> activate its instance.  The distributed lock service could be used to 
>> arbitrate access something like this:
>> 
>> 
>>   /**
>>    * Invoke to activate a component. Only one instance of the component is
>>    * allowed to be active in the distributed system at any given time. This
>>    * method blocks until the component is activated on this member or the
>>    * component is released.
>>    * 
>>    * @param ds
>>    *          the distributed system
>>    * @param retryDelay
>>    *          the retry delay in millis
>>    */
>>   protected void activate(DistributedSystem ds, int retryDelay) {
>>     DistributedLockService dls = DistributedLockService.create(DLS_SERVICE, 
>> ds);
>>     while (!abort && !Thread.interrupted()) {
>>       if (dls.lock(getClass().getName(), retryDelay, -1)) {
>>         locked = true;
>>         return;
>>       }
>>     }
>>   }
>> 
>> 
>> Anthony
>> 

Reply via email to