stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajkumar Rajaratnam <rajkum...@wso2.com>
Subject Re: Bug in round-robin partition selection algorithm
Date Tue, 03 Mar 2015 17:45:32 GMT
Problem is lowestInstanceCount is initially taking 0. Instead it should
take the non terminated member count of 1st partition.

To Fix,

        int selectedIndex = 0;
        int lowestInstanceCount =
partitionContexts[0].getNonTerminatedMemberCount();

wdyt?

Thanks.

On Tue, Mar 3, 2015 at 10:57 PM, Rajkumar Rajaratnam <rajkumarr@wso2.com>
wrote:

> Hi Lahiru,
>
> Actually, current logic is not working as your example. This logic only
> uses the first partition. This will never use any other partitions. See my
> comments within the following code.
>
>     public PartitionContext
> getNextScaleUpPartitionContext(PartitionContext[] partitionContexts) {
>
>         int selectedIndex = 0;
>         int lowestInstanceCount = 0;
>
>         for(int partitionIndex = 0; partitionIndex <
> partitionContexts.length - 1; partitionIndex++) {
>
>
> if(partitionContexts[partitionIndex].getNonTerminatedMemberCount() <
> lowestInstanceCount) {
>
> *//  this if condition is always false, because non terminated count is
> always >=0*
>
>                 lowestInstanceCount =
> partitionContexts[partitionIndex].getNonTerminatedMemberCount();
>                 selectedIndex = partitionIndex;
>             }
>         }
>
> *//  selected index is 0 always, so round-robin will always use first
> partition*
>         if(partitionContexts[selectedIndex].getNonTerminatedMemberCount()
> < partitionContexts[selectedIndex].getMax()) {
>
>             if(log.isDebugEnabled()){
>                 log.debug(String.format("[round-robin algorithm]
> [scale-up] [partition] %s has space to create members. " +
>                         "[non terminated count] %s [max] %s"
>                         ,
> partitionContexts[selectedIndex].getPartitionId(),
>
> partitionContexts[selectedIndex].getNonTerminatedMemberCount(),
>                         partitionContexts[selectedIndex].getMax()));
>             }
>             return partitionContexts[selectedIndex];
>         } else {
>
>             return null;
>         }
>     }
>
> May be I am missing something here.
>
> Thanks.
>
> On Tue, Mar 3, 2015 at 10:42 PM, Lahiru Sandaruwan <lahirus@wso2.com>
> wrote:
>
>> Hi Raj,
>>
>> Earlier in 4.0.0 release, we have been using the partition index. If that
>> to be worked correctly we should persist the index for each cluster.
>>
>> IMO there is a better way to execute the round-robin method as follows,
>>
>> The intention of round robin algorithm is to distribute the members in
>> the partitions equally. Current method works as per the following example.
>>
>> Say we have 3 partitions, p1, p2, and p3 and max of each partition is 2.
>>
>> So according to the algorithm, it will select the first partition who has
>> the lowest member count.
>>
>> Iteration1: It will select p1.
>> Iteration2: It will select p2.
>> Iteration3: It will select p3.
>> Iteration4: It will select p1.
>> Iteration5: It will select p2.
>> ....
>>
>> Thanks.
>>
>>
>>
>> On Tue, Mar 3, 2015 at 10:22 PM, Rajkumar Rajaratnam <rajkumarr@wso2.com>
>> wrote:
>>
>>> Hi Devs,
>>>
>>> It seems to me that there is a bug in round-robin implementation of
>>> partition algorithm.
>>>
>>>
>>> https://github.com/apache/stratos/blob/0b7734f4c9f1444d064fec93bf9ac59a5883faf2/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java#L43-L64
>>>
>>> Shouldn't it work based on current partition index? For example, if the
>>> most recent instance was spin up in partition-1, the next instance should
>>> be spin up in partition-2 and so on. According to current logic what is
>>> happening is, all the instance are spin up in partition-1.
>>>
>>> Please correct me If I am wrong.
>>>
>>> Thanks.
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>> Mobile : +94777568639
>>> Blog : rajkumarr.com
>>>
>>
>>
>>
>> --
>> --
>> Lahiru Sandaruwan
>> Committer and PMC member, Apache Stratos,
>> Senior Software Engineer,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>
> Mobile : +94777568639
> Blog : rajkumarr.com
>



-- 
Rajkumar Rajaratnam
Committer & PMC Member, Apache Stratos
Software Engineer, WSO2

Mobile : +94777568639
Blog : rajkumarr.com

Mime
View raw message