test_class.declarator: zkServer
test_class.modifier: private
test_class.original_string: private TestingServer zkServer;
test_class.type: TestingServer
test_class.var_name: zkServer
test_class.declarator: zookeeperClient
test_class.modifier: private
test_class.original_string: private ZookeeperClient zookeeperClient;
test_class.type: ZookeeperClient
test_class.var_name: zookeeperClient
test_class.declarator: abstractZookeeperTransporter
test_class.modifier: private
test_class.original_string: private AbstractZookeeperTransporter abstractZookeeperTransporter;
test_class.type: AbstractZookeeperTransporter
test_class.var_name: abstractZookeeperTransporter
test_class.declarator: zkServerPort
test_class.modifier: private
test_class.original_string: private int zkServerPort;
test_class.type: int
test_class.var_name: zkServerPort
test_class.file: dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporterTest.java
test_class.identifier: AbstractZookeeperTransporterTest
test_case.body: @Test
      public void testSameHostWithDifferentUser() throws Exception {
          int zkPort1 = NetUtils.getAvailablePort();
          int zkPort2 = NetUtils.getAvailablePort();
          try (TestingServer zkServer1 = new TestingServer(zkPort1, true)) {
              try (TestingServer zkServer2 = new TestingServer(zkPort2, true)) {
                  URL url1 = URL.valueOf("zookeeper://us1:pw1@127.0.0.1:" + zkPort1 + "/path1");
                  URL url2 = URL.valueOf("zookeeper://us2:pw2@127.0.0.1:" + zkPort1 + "/path2");
  
                  ZookeeperClient client1 = abstractZookeeperTransporter.connect(url1);
                  ZookeeperClient client2 = abstractZookeeperTransporter.connect(url2);
  
                  assertThat(client1, not(client2));
              }
          }
      }
test_case.class_method_signature: AbstractZookeeperTransporterTest.testSameHostWithDifferentUser()
test_case.full_signature: @Test public void testSameHostWithDifferentUser()
test_case.identifier: testSameHostWithDifferentUser
test_case.invocations: getAvailablePort getAvailablePort valueOf valueOf connect connect assertThat not
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSameHostWithDifferentUser()
focal_class.declarator: logger = LoggerFactory.getLogger(ZookeeperTransporter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ZookeeperTransporter.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: zookeeperClientMap = new ConcurrentHashMap<>()
focal_class.modifier: private final
focal_class.original_string: private final Map<String, ZookeeperClient> zookeeperClientMap = new ConcurrentHashMap<>();
focal_class.type: Map<String, ZookeeperClient>
focal_class.var_name: zookeeperClientMap
focal_class.file: dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java
focal_class.identifier: AbstractZookeeperTransporter
focal_class.interfaces: implements ZookeeperTransporter
focal_class.class_method_signature: AbstractZookeeperTransporter.connect(URL url)
focal_class.full_signature: @Override public ZookeeperClient connect(URL url)
focal_class.identifier: connect
focal_class.modifiers: @Override public
focal_class.parameters: (URL url)
focal_class.return: ZookeeperClient
focal_class.signature: ZookeeperClient connect(URL url)
focal_class.class_method_signature: AbstractZookeeperTransporter.createZookeeperClient(URL url)
focal_class.full_signature: protected abstract ZookeeperClient createZookeeperClient(URL url)
focal_class.identifier: createZookeeperClient
focal_class.modifiers: protected abstract
focal_class.parameters: (URL url)
focal_class.return: ZookeeperClient
focal_class.signature: ZookeeperClient createZookeeperClient(URL url)
focal_class.class_method_signature: AbstractZookeeperTransporter.fetchAndUpdateZookeeperClientCache(List<String> addressList)
focal_class.full_signature:  ZookeeperClient fetchAndUpdateZookeeperClientCache(List<String> addressList)
focal_class.identifier: fetchAndUpdateZookeeperClientCache
focal_class.parameters: (List<String> addressList)
focal_class.return: ZookeeperClient
focal_class.signature: ZookeeperClient fetchAndUpdateZookeeperClientCache(List<String> addressList)
focal_class.class_method_signature: AbstractZookeeperTransporter.getURLBackupAddress(URL url)
focal_class.full_signature:  List<String> getURLBackupAddress(URL url)
focal_class.identifier: getURLBackupAddress
focal_class.parameters: (URL url)
focal_class.return: List<String>
focal_class.signature: List<String> getURLBackupAddress(URL url)
focal_class.class_method_signature: AbstractZookeeperTransporter.writeToClientMap(List<String> addressList, ZookeeperClient zookeeperClient)
focal_class.full_signature:  void writeToClientMap(List<String> addressList, ZookeeperClient zookeeperClient)
focal_class.identifier: writeToClientMap
focal_class.parameters: (List<String> addressList, ZookeeperClient zookeeperClient)
focal_class.return: void
focal_class.signature: void writeToClientMap(List<String> addressList, ZookeeperClient zookeeperClient)
focal_class.class_method_signature: AbstractZookeeperTransporter.toClientURL(URL url)
focal_class.full_signature:  URL toClientURL(URL url)
focal_class.identifier: toClientURL
focal_class.parameters: (URL url)
focal_class.return: URL
focal_class.signature: URL toClientURL(URL url)
focal_class.class_method_signature: AbstractZookeeperTransporter.getZookeeperClientMap()
focal_class.full_signature:  Map<String, ZookeeperClient> getZookeeperClientMap()
focal_class.identifier: getZookeeperClientMap
focal_class.parameters: ()
focal_class.return: Map<String, ZookeeperClient>
focal_class.signature: Map<String, ZookeeperClient> getZookeeperClientMap()
focal_method.body: @Override
      public ZookeeperClient connect(URL url) {
          ZookeeperClient zookeeperClient;
          // address format: {[username:password@]address}
          List<String> addressList = getURLBackupAddress(url);
          // The field define the zookeeper server , including protocol, host, port, username, password
          if ((zookeeperClient = fetchAndUpdateZookeeperClientCache(addressList)) != null && zookeeperClient.isConnected()) {
              logger.info("find valid zookeeper client from the cache for address: " + url);
              return zookeeperClient;
          }
          // avoid creating too many connections， so add lock
          synchronized (zookeeperClientMap) {
              if ((zookeeperClient = fetchAndUpdateZookeeperClientCache(addressList)) != null && zookeeperClient.isConnected()) {
                  logger.info("find valid zookeeper client from the cache for address: " + url);
                  return zookeeperClient;
              }
  
              zookeeperClient = createZookeeperClient(url);
              logger.info("No valid zookeeper client found from cache, therefore create a new client for url. " + url);
              writeToClientMap(addressList, zookeeperClient);
          }
          return zookeeperClient;
      }
focal_method.class_method_signature: AbstractZookeeperTransporter.connect(URL url)
focal_method.full_signature: @Override public ZookeeperClient connect(URL url)
focal_method.identifier: connect
focal_method.invocations: getURLBackupAddress fetchAndUpdateZookeeperClientCache isConnected info fetchAndUpdateZookeeperClientCache isConnected info createZookeeperClient info writeToClientMap
focal_method.modifiers: @Override public
focal_method.parameters: (URL url)
focal_method.return: ZookeeperClient
focal_method.signature: ZookeeperClient connect(URL url)