[ 
https://issues.apache.org/jira/browse/HBASE-24931?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mallikarjun updated HBASE-24931:
--------------------------------
    Description: 
Balance Candidate generators such as `LocalityBasedCandidateGenerator`, 
`RegionReplicaCandidateGenerator`,  `RegionReplicaRackCandidateGenerator`, etc 
uses helper method `getAction` to generate action is ignoring 0th index of 
`fromRegion` and `toRegion`. 
{code:java}
protected BaseLoadBalancer.Cluster.Action getAction(int fromServer, int 
fromRegion,
    int toServer, int toRegion) {
  if (fromServer < 0 || toServer < 0) {
    return BaseLoadBalancer.Cluster.NullAction;
  }
  if (fromRegion > 0 && toRegion > 0) {
    return new BaseLoadBalancer.Cluster.SwapRegionsAction(fromServer, 
fromRegion,
      toServer, toRegion);
  } else if (fromRegion > 0) {
    return new BaseLoadBalancer.Cluster.MoveRegionAction(fromRegion, 
fromServer, toServer);
  } else if (toRegion > 0) {
    return new BaseLoadBalancer.Cluster.MoveRegionAction(toRegion, toServer, 
fromServer);
  } else {
    return BaseLoadBalancer.Cluster.NullAction;
  }
}
{code}
Is this unintentional or there is some particular reason? 

  was:
Balance Candidate generators such as `LocalityBasedCandidateGenerator`, 
`RegionReplicaCandidateGenerator`,  `RegionReplicaRackCandidateGenerator`, etc 
uses helper method `getAction` to generate action is ignoring 0th index of 
`fromRegion` and `toRegion`. 
{code:java}
protected BaseLoadBalancer.Cluster.Action getAction(int fromServer, int 
fromRegion,
    int toServer, int toRegion) {
  if (fromServer < 0 || toServer < 0) {
    return BaseLoadBalancer.Cluster.NullAction;
  }
  if (fromRegion > 0 && toRegion > 0) {
    return new BaseLoadBalancer.Cluster.SwapRegionsAction(fromServer, 
fromRegion,
      toServer, toRegion);
  } else if (fromRegion > 0) {
    return new BaseLoadBalancer.Cluster.MoveRegionAction(fromRegion, 
fromServer, toServer);
  } else if (toRegion > 0) {
    return new BaseLoadBalancer.Cluster.MoveRegionAction(toRegion, toServer, 
fromServer);
  } else {
    return BaseLoadBalancer.Cluster.NullAction;
  }
}
{code}
Is this unintentional or is there some particular reason? 


> Candidate Generator helper getAction method ignoring 0th index region
> ---------------------------------------------------------------------
>
>                 Key: HBASE-24931
>                 URL: https://issues.apache.org/jira/browse/HBASE-24931
>             Project: HBase
>          Issue Type: Bug
>          Components: Balancer
>            Reporter: Mallikarjun
>            Assignee: Mallikarjun
>            Priority: Minor
>
> Balance Candidate generators such as `LocalityBasedCandidateGenerator`, 
> `RegionReplicaCandidateGenerator`,  `RegionReplicaRackCandidateGenerator`, 
> etc uses helper method `getAction` to generate action is ignoring 0th index 
> of `fromRegion` and `toRegion`. 
> {code:java}
> protected BaseLoadBalancer.Cluster.Action getAction(int fromServer, int 
> fromRegion,
>     int toServer, int toRegion) {
>   if (fromServer < 0 || toServer < 0) {
>     return BaseLoadBalancer.Cluster.NullAction;
>   }
>   if (fromRegion > 0 && toRegion > 0) {
>     return new BaseLoadBalancer.Cluster.SwapRegionsAction(fromServer, 
> fromRegion,
>       toServer, toRegion);
>   } else if (fromRegion > 0) {
>     return new BaseLoadBalancer.Cluster.MoveRegionAction(fromRegion, 
> fromServer, toServer);
>   } else if (toRegion > 0) {
>     return new BaseLoadBalancer.Cluster.MoveRegionAction(toRegion, toServer, 
> fromServer);
>   } else {
>     return BaseLoadBalancer.Cluster.NullAction;
>   }
> }
> {code}
> Is this unintentional or there is some particular reason? 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to