- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.4k
HBASE-26532 Replication could choose the same named group if it is exist in the target cluster #3911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 💔 -1 overall 
 This message was automatically generated. | 
| 💔 -1 overall 
 This message was automatically generated. | 
| 💔 -1 overall 
 
 This message was automatically generated. | 
540eed8    to
    61598ce      
    Compare
  
    | 💔 -1 overall 
 This message was automatically generated. | 
| 💔 -1 overall 
 
 This message was automatically generated. | 
| 💔 -1 overall 
 
 This message was automatically generated. | 
61598ce    to
    cc7143d      
    Compare
  
    | 💔 -1 overall 
 
 This message was automatically generated. | 
…ist in the target cluster
cc7143d    to
    244b9ad      
    Compare
  
    | 🎊 +1 overall 
 
 This message was automatically generated. | 
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| 💔 -1 overall 
 
 This message was automatically generated. | 
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| // Ratio of total number of potential peer region servers to be used | ||
| private float ratio; | ||
|  | ||
| private float groupRatio; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here can add some descriptions/comments as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please add some explaination.
| } | ||
| }; | ||
|  | ||
| public boolean getIsGroup() { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. redundant space
| if (children == null) { | ||
| return Collections.emptyList(); | ||
| } | ||
| StringBuffer sb = new StringBuffer(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use StringBuilder here?
| } | ||
| if (LOG.isDebugEnabled()) { | ||
| LOG.debug( | ||
| "Find " + addresses.size() + " child znodes from target cluster zk. " + sb.toString()); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use parameterized logging, and elsewhere.
| LOG.debug("Use replication rsgroup choose policy..."); | ||
| } | ||
| Map<String, String> serverNameHostPortMapping = new HashMap<>(); | ||
| for (String serverName : children) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can reuse parseServerNameFromList(children) ? then the followings can just user ServerName#getHost and ServerName#getPort.
| getGroupServerListFromTargetZkCluster(groupName, zkw, serverNameHostPortMapping); | ||
| if (serverList.size() > 0) { | ||
| // if target cluster open group balancer, serverList must has server(s) | ||
| LOG.debug("group list > 0"); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can log which group > 0?
| try { | ||
| rsGroupInfo = getRSGroupInfoOfServer(conn.toConnection(), hostServerName.getAddress()); | ||
| }catch (IOException e) { | ||
| e.printStackTrace(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still neede.printStackTrace();?
| } | ||
| else { | ||
| // if not, choose sinkers from all regionservers | ||
| LOG.debug("target group list <= 0"); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto. Please add check LOG.isDebugEnabled() {} and elsewhere
| LOG.debug("groupInfos == null"); | ||
| } | ||
| return Collections.emptyList(); | ||
| }else{ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. spaces between else {} are needed
|  | ||
| int numSinks = (int) Math.ceil(slaveAddresses.size() * actualRatio); | ||
| this.sinkServers = slaveAddresses.subList(0, numSinks); | ||
| StringBuffer sb = new StringBuffer(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
| ping @Apache9, you probably would want to take a look at this one? | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems there are still some legacy code, which is for the old rs group implementation. Better provide a simple design doc first, we can discuss the approach first, and then you can modify the PR here.
Thanks~
| */ | ||
| @InterfaceAudience.Private | ||
| public interface ReplicationService { | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid touching unnecessary file.
| // Ratio of total number of potential peer region servers to be used | ||
| private float ratio; | ||
|  | ||
| private float groupRatio; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please add some explaination.
|  | ||
| private List<ServerName> sinkServers = new ArrayList<>(0); | ||
|  | ||
| private static ThreadLocal<AtomicBoolean> threadLocal = new ThreadLocal<AtomicBoolean>() { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to use AtomicBoolean for a thread local variable?
| Configuration conf = HBaseConfiguration.create(); | ||
|  | ||
| /** if use other balancer, return all regionservers */ | ||
| if (!conf.get(HConstants.HBASE_MASTER_LOADBALANCER_CLASS) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On master this is not the case now. The balancer will always be a RSGroupBasedLoadBalancer, if we do not enable rs group feature, DisabledRSGroupInfoManager will be used and there will be only one group, which will act as there is no rs group. So I think here we should check for RSGroupUtil.isRSGroupEnabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And another problem is do we need to check the configuration here? I think it is the version at the source cluster, but we need to check the target cluster?
| return addresses; | ||
| } | ||
|  | ||
| protected List<ServerName> getGroupServerListFromTargetZkCluster(String groupName, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On master branch we do not use zk for storing the rs group any more...
| 
 Yes, actually i did this on 1.x... | 
https://issues.apache.org/jira/browse/HBASE-26532