You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Udara Liyanage <ud...@wso2.com> on 2013/11/27 09:32:46 UTC

How to get current member count in ClusterContext

What is the difference between  below two methods. What is the correct way
of doing $subject

 private int memberCount;
//This map will keep number of currently spawned instance count against
partitionId
    private Map<String, Integer> partitionCountMap;

public int getMemberCount() {
        return memberCount;
    }


public int getMemberCount(String partitionId){
        if(partitionCountMap.containsKey(partitionId)) {
            return partitionCountMap.get(partitionId);
        }
        return 0;
    }


-- 
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897

Re: How to get current member count in ClusterContext

Posted by Isuru Haththotuwa <is...@wso2.com>.
Looking at the code snippet, should be the total member count in the
cluster and the member count in the relevant partition.


On Wed, Nov 27, 2013 at 2:02 PM, Udara Liyanage <ud...@wso2.com> wrote:

> What is the difference between  below two methods. What is the correct way
> of doing $subject
>
>  private int memberCount;
> //This map will keep number of currently spawned instance count against
> partitionId
>     private Map<String, Integer> partitionCountMap;
>
> public int getMemberCount() {
>         return memberCount;
>     }
>
>
> public int getMemberCount(String partitionId){
>         if(partitionCountMap.containsKey(partitionId)) {
>             return partitionCountMap.get(partitionId);
>         }
>         return 0;
>     }
>
>
> --
> Udara Liyanage
> Software Engineer
> WSO2, Inc.: http://wso2.com
> lean. enterprise. middleware
>
> web: http://udaraliyanage.wordpress.com
> phone: +94 71 443 6897
>



-- 
Thanks and Regards,

Isuru H.
Software Engineer, WSO2 Inc.
+94 716 358 048* <http://wso2.com/>*

Re: How to get current member count in ClusterContext

Posted by Udara Liyanage <ud...@wso2.com>.
Thanks Lahiru n IsuruH for calarifications.


On Wed, Nov 27, 2013 at 3:46 AM, Lahiru Sandaruwan <la...@wso2.com> wrote:

>
>
>
> On Wed, Nov 27, 2013 at 2:02 PM, Udara Liyanage <ud...@wso2.com> wrote:
>
>> What is the difference between  below two methods. What is the correct
>> way of doing $subject
>>
>>  private int memberCount;
>> //This map will keep number of currently spawned instance count against
>> partitionId
>>     private Map<String, Integer> partitionCountMap;
>>
>> public int getMemberCount() {
>>         return memberCount;
>>     }
>>
>
> This is the number of members in this cluster.(all the members)
> For $subject you need this, hope you want to take overall count.
>
>
>>
>> public int getMemberCount(String partitionId){
>>         if(partitionCountMap.containsKey(partitionId)) {
>>             return partitionCountMap.get(partitionId);
>>         }
>>         return 0;
>>     }
>>
>
> This is the count in a particular partition.
>
>
>
>>
>> --
>> Udara Liyanage
>> Software Engineer
>>  WSO2, Inc.: http://wso2.com
>> lean. enterprise. middleware
>>
>> web: http://udaraliyanage.wordpress.com
>> phone: +94 71 443 6897
>>
>
>
>
> --
> --
> Lahiru Sandaruwan
> Software Engineer,
> Platform Technologies,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com cell: (+94) 773 325 954
> blog: http://lahiruwrites.blogspot.com/
> twitter: http://twitter.com/lahirus
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>


-- 
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897

Re: How to get current member count in ClusterContext

Posted by Lahiru Sandaruwan <la...@wso2.com>.
On Wed, Nov 27, 2013 at 2:02 PM, Udara Liyanage <ud...@wso2.com> wrote:

> What is the difference between  below two methods. What is the correct way
> of doing $subject
>
>  private int memberCount;
> //This map will keep number of currently spawned instance count against
> partitionId
>     private Map<String, Integer> partitionCountMap;
>
> public int getMemberCount() {
>         return memberCount;
>     }
>

This is the number of members in this cluster.(all the members)
For $subject you need this, hope you want to take overall count.


>
> public int getMemberCount(String partitionId){
>         if(partitionCountMap.containsKey(partitionId)) {
>             return partitionCountMap.get(partitionId);
>         }
>         return 0;
>     }
>

This is the count in a particular partition.



>
> --
> Udara Liyanage
> Software Engineer
>  WSO2, Inc.: http://wso2.com
> lean. enterprise. middleware
>
> web: http://udaraliyanage.wordpress.com
> phone: +94 71 443 6897
>



-- 
--
Lahiru Sandaruwan
Software Engineer,
Platform Technologies,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com cell: (+94) 773 325 954
blog: http://lahiruwrites.blogspot.com/
twitter: http://twitter.com/lahirus
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146