Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-11707

Using Map instead of list in FailedServers of RpcClient

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.0
    • Client
    • None
    • Reviewed

    Description

      Currently, FailedServers uses a list to record the black list of servers and iterate the list to check if a server is in list. It's not efficient when the list is very large. And the list is not thread safe for the add and iteration operations.

      RpcClient.java#175

            // iterate, looking for the search entry and cleaning expired entries
            Iterator<Pair<Long, String>> it = failedServers.iterator();
            while (it.hasNext()) {
              Pair<Long, String> cur = it.next();
               if (cur.getFirst() < now) {
                it.remove();
              } else {
                if (lookup.equals(cur.getSecond())) {
                  return true;
                }
              }
      

      A simple change is to change this list to ConcurrentHashMap.

      Attachments

        1. HBASE-11707.master.001.patch
          3 kB
          Michael Stack
        2. HBASE-11707-trunk-v1.diff
          3 kB
          Shaohui Liu
        3. HBASE-11707-trunk-v2.diff
          3 kB
          Shaohui Liu

        Issue Links

          Activity

            People

              liushaohui Shaohui Liu
              liushaohui Shaohui Liu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: