[ 
https://issues.apache.org/jira/browse/HBASE-16275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15390527#comment-15390527
 ] 

Yu Li commented on HBASE-16275:
-------------------------------

Checking TestProcedureManager in local, we will see below exception:
{noformat}
2016-07-23 12:17:05,583 FATAL [M:0;localhost:57006] master.HMaster(2154): 
Unhandled: inconsistent range
java.lang.IllegalArgumentException: inconsistent range
        at 
java.util.concurrent.ConcurrentSkipListMap$SubMap.<init>(ConcurrentSkipListMap.java:2506)
        at 
java.util.concurrent.ConcurrentSkipListMap.subMap(ConcurrentSkipListMap.java:1984)
        at 
org.apache.hadoop.hbase.master.ServerManager.findServerWithSameHostnamePortWithLock(ServerManager.java:448)
        at 
org.apache.hadoop.hbase.master.ServerManager.checkAndRecordNewServer(ServerManager.java:357)
        at 
org.apache.hadoop.hbase.master.ServerManager.regionServerStartup(ServerManager.java:267)
        at 
org.apache.hadoop.hbase.master.MasterRpcServices.regionServerStartup(MasterRpcServices.java:269)
        at 
org.apache.hadoop.hbase.regionserver.HRegionServer.reportForDuty(HRegionServer.java:2362)
        at 
org.apache.hadoop.hbase.regionserver.HRegionServer.run(HRegionServer.java:946)
{noformat}

Checking the code, the problem is that {{ServerName#compareTo}} will do a force 
cast when comparing startcode:
{code}
    return (int)(this.getStartcode() - other.getStartcode());
{code}
When we cast the result of {{0 - Long.MAX_VALUE}} to int, it will return 1, 
making fromKey larger than toKey when calling {{CSLM#subMap}}. Simply test
{code}
    long x = 0L - Long.MAX_VALUE;
    System.out.println(x);
    System.out.println((int) x);
{code}
and we could see below result:
{noformat}
-9223372036854775807
1
{noformat}

Please resolve the above problem (well, to be fair, this actually is a bug of 
{{ServerName#compareTo}}, but still...) and update the patch [~huaxiang], 
thanks.

> Change ServerManager#onlineServers from ConcurrentHashMap to 
> ConcurrentSkipListMap
> ----------------------------------------------------------------------------------
>
>                 Key: HBASE-16275
>                 URL: https://issues.apache.org/jira/browse/HBASE-16275
>             Project: HBase
>          Issue Type: Improvement
>            Reporter: huaxiang sun
>            Assignee: huaxiang sun
>            Priority: Minor
>         Attachments: HBASE-16275-v001.patch
>
>
> In Class ServerManager, onlineServers is declared as ConcurrentHashMap. In 
> findServerWithSameHostnamePortWithLock(), it has to do a loop to find if 
> there is a ServerName with same host:port pair. If replaced with 
> ConcurrentSkipListMap, findServerWithSameHostnamePortWithLock() can be 
> replaced with a O(logN) implementation. 
> I run some performance comparison(test the function only), it seems that 
> there is no difference if there are 1000 servers. With more servers, 
> ConcurrentSkipListMap implementation is going to win big.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to