On Fri, May 23, 2014 at 3:25 PM, Shazni Nazeer <[email protected]> wrote:

> Hi All,
>
> With the above mentioned code block in HazelcastClusteringAgent and adding
> List<CoordinatedActivity> to the
> org.wso2.carbon.clustering.internal.DataHolder (which isn't yet
> implemented), I could get the cache invalidation work properly in a GREG
> cluster in two domains. I also could check when the coordinator goes down,
> another node becomes the coordinator with the above code block mentioned by
> Azeez. The coordinated activity also needs to be added when the
> CacheInvalidationPublisher is created, which will eventually be added to
> List<CoordinatedActivity> in the DataHolder.
>
> @Azeez :  The org.wso2.carbon.clustering.internal.DataHolder is an
> internal package and is not getting exported.
>

internal packages are not supposed to be exported. Those are private
packages that are visible only within the scope of the bundle.


> Above code block uses it. I could only get this to work by exporting this
> package.
> How can we cope up with this?
>
>
> Shazni Nazeer
>
> Senior Software Engineer
>
> Mob : +94 715 440 607
> LinkedIn : http://lk.linkedin.com/in/shazninazeer
> Blog : http://shazninazeer.blogspot.com
>
>
> On Wed, May 21, 2014 at 8:35 PM, Afkham Azeez <[email protected]> wrote:
>
>> When clustering is initialized, it spawns a thread, which tries to
>> acquire the coordinator lock. The relevant code segment from
>> HazelcastClusteringAgent is as follows:
>>
>> // Try to acquire the coordinator lock for the cluster
>>         new Thread("cluster-coordinator") {
>>
>>             @Override
>>             public void run() {
>>                 
>> *hazelcastInstance.getLock("$$cluster#coordinator$#lock").lock();
>> // code will block here until lock is acquired*
>>                 isCoordinator = true;
>>                 logger.info("Local member is the coordinator");
>>                 // Notify all OSGi services which are waiting for this
>> member to become the coordinator
>>                 List<CoordinatedActivity> coordinatedActivities =
>> DataHolder.getInstance().getCoordinatedActivities();
>>                 *for (CoordinatedActivity coordinatedActivity :
>> coordinatedActivities) {*
>> *                    coordinatedActivity.execute();*
>> *                }*
>>             }
>>         }.start();
>>
>>
>> Pay special attention to the bold lines above. This thread will block if
>> it cannot acquire the lock. Only one member in the entire cluster will be
>> able to acquire this distributed lock, and will become the coordinator. All
>> others will block at the first line in the run method. Suppose the
>> coordinator dies, then another member will acquire the lock, and it will
>> unblock from that line, and then go on to call all CoordinatedActivity OSGi
>> services.
>>
>> So, in your code that relies on doing things if you are the coordinator,
>> first you need to do a ClusteringAgent.isCoordinator check and execute the
>> relevant code, when your bundle gets activated. You also need to implement
>> a CoordinatedActivity so that you can get notified if the original
>> coordinator dies, and another member becomes the coordinator.
>>
>> HTH
>> Azeez
>>
>>
>> On Wed, May 21, 2014 at 5:47 PM, Amal Gunatilake <[email protected]> wrote:
>>
>>> Hi Azeez,
>>>
>>> Since now we have done the implementation based on the
>>> CoordinatedActivity interface 
>>> [1]<https://github.com/wso2/carbon-kernel/blob/development/modules/clustering/src/main/java/org/wso2/carbon/clustering/api/CoordinatedActivity.java>,
>>> Please enlighten us on how, the execute() method triggering mechanism work?
>>> Has it been implemented and committed to git hub? Please let us know the
>>> code snippet location which triggers the execute() method.
>>>
>>> Then we can debug the code to check whether the notification mechanism
>>> works properly to auto subscribe the cache invalidation bundle.
>>>
>>> [1]
>>> https://github.com/wso2/carbon-kernel/blob/development/modules/clustering/src/main/java/org/wso2/carbon/clustering/api/CoordinatedActivity.java
>>>
>>> Thank you  & Best regards,
>>>
>>> *Amal Gunatilake*
>>>  Software Engineer
>>> WSO2 Inc.; http://wso2.com
>>> lean.enterprise.middleware
>>>
>>
>>
>>
>> --
>> *Afkham Azeez*
>> Director of Architecture; WSO2, Inc.; http://wso2.com
>> Member; Apache Software Foundation; http://www.apache.org/
>> * <http://www.apache.org/>*
>> *email: **[email protected]* <[email protected]>
>> * cell: +94 77 3320919 <%2B94%2077%203320919> blog: *
>> *http://blog.afkham.org* <http://blog.afkham.org>
>> *twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
>> * linked-in: **http://lk.linkedin.com/in/afkhamazeez
>> <http://lk.linkedin.com/in/afkhamazeez>*
>>
>> *Lean . Enterprise . Middleware*
>>
>
>


-- 
*Afkham Azeez*
Director of Architecture; WSO2, Inc.; http://wso2.com
Member; Apache Software Foundation; http://www.apache.org/
* <http://www.apache.org/>*
*email: **[email protected]* <[email protected]>
* cell: +94 77 3320919 blog: **http://blog.afkham.org*<http://blog.afkham.org>
*twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
* linked-in: **http://lk.linkedin.com/in/afkhamazeez
<http://lk.linkedin.com/in/afkhamazeez>*

*Lean . Enterprise . Middleware*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to