Connects to the cluster.
558613
private CompletableFuture<Connection> connect() {
    // If the address selector has been reset then reset the connection.
    if (selector.state() == AddressSelector.State.RESET && connection != null) {
      if (connectFuture != null) {
        return connectFuture;
      }

      CompletableFuture<Connection> future = new OrderedCompletableFuture<>();
      future.whenComplete((r, e) -> this.connectFuture = null);
      this.connectFuture = future;

      Connection oldConnection = this.connection;
      this.connection = null;
      oldConnection.close();
      connect(future);
      return future;
    }

    // If a connection was already established then use that connection.
    if (connection != null) {
      return CompletableFuture.completedFuture(connection);
    }

    // If a connection is currently being established then piggyback on the connect future.
    if (connectFuture != null) {
      return connectFuture;
    }

    // Create a new connect future and connect to the first server in the cluster.
    CompletableFuture<Connection> future = new OrderedCompletableFuture<>();
    future.whenComplete((r, e) -> this.connectFuture = null);
    this.connectFuture = future;
    reset().connect(future);
    return future;
  }
1243954
def connect(self):
        
        HTTPConnection.connect(self)
        self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
64273
private function connect()
    {
        $this->conn = parent::getConn();
        $this->create = $this->conn->prepare($this->create);
    }
938630
public synchronized void connect() {
    if(executor == null) {
      executor = new ThreadPoolExecutor(0, processors, 10L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
      executor.allowCoreThreadTimeOut(true);
    }
    if(++connected == 1) {
      executor.allowCoreThreadTimeOut(false);
      executor.setCorePoolSize(executor.getMaximumPoolSize());
    }
  }
788327
def connectRelay(self):
        
        self.protocol = self.connector.buildProtocol(None)
        self.connected = True
        self.protocol.makeConnection(self)
195910
function Cluster(data) {
  var self = this;
  self.data = data;

  if (cluster.isMaster) {
    if (data.pid) {
      fs.writeFileSync(data.pid, process.pid);
    }
    let numCPUs = 1;
    if (data.count) {
      numCPUs = data.count;
    } else {
      numCPUs = require('os').cpus().length;
    }

    self.debug.log('Starting up %s workers.', numCPUs);
    for (var i = 0; i < numCPUs; i++) {
      cluster.fork();
    }

    cluster.on('online', function(worker) {
      self.debug.log('Worker %s is online', worker.process.pid);
    });

    cluster.on('exit', function(worker, code, signal) {
      self.debug.log('Worker %s died. code %s signal %s', worker.process.pid, code, signal);
      self.debug.log('Starting a new worker');
      cluster.fork();
    });

    cluster.on('listening', function(worker, address) {
      if (self.data.callbacks['init']) {
        self.data.callbacks['init'](cluster, worker, address);
      }
    });

    process.on('SIGINT', function() {
      self.debug.log('Caught interrupt signal');
      if (data.pid) {
        fs.unlinkSync(data.pid);
      }
      process.exit();
    });
  } else {
    var webServer = new WebHttp(self.data);

    process.on('SIGINT', function() {
      self.debug.worker('Caught interrupt signal');
      webServer.stop();
    });

    process.on('SIGTERM', function() {
        self.debug.worker('Caught termination signal');
        webServer.stop();
      }
    );
  }
  return cluster;
}
1340166
public static Cluster connectCluster(String host, int port) {
	Builder clusterBuilder = Cluster.builder();
	// Socket Options
	SocketOptions socketOptions = new SocketOptions();
	socketOptions.setConnectTimeoutMillis(60000);
	socketOptions.setKeepAlive(true);
	socketOptions.setReadTimeoutMillis(30000);
	return clusterBuilder.addContactPoint(host)
		.withSocketOptions(socketOptions).withPort(port).build();
    }
465802
private function _connect() 
    {

        if ($this->config['host'] && $this->config['port']) {
            // establish the memcache connection
            $this->memcache = new Memcache;
            $this->memcache->pconnect(
            	$this->config['host'], 
                $this->config['port']
            );

        } else {
            throw new Exception('Insufficient connection parameters');
        }
    }
336677
private function Connect()
    {
        $this->conn = parent::getConn();
        $this->delete = $this->conn->prepare($this->delete);
    }
1013418
def _Connect(self):
    """"""
    elastic_host = {'host': self._host, 'port': self._port}

    if self._url_prefix:
      elastic_host['url_prefix'] = self._url_prefix

    elastic_http_auth = None
    if self._username is not None:
      elastic_http_auth = (self._username, self._password)

    self._client = elasticsearch.Elasticsearch(
        [elastic_host],
        http_auth=elastic_http_auth,
        use_ssl=self._use_ssl,
        ca_certs=self._ca_certs
    )

    logger.debug(
        ('Connected to Elasticsearch server: {0:s} port: {1:d}'
         'URL prefix {2!s}.').format(self._host, self._port, self._url_prefix))
874445
public void connect() throws Exception {
        adminClients = new ArrayList<AdminClient>(urls.size());
        // bootstrap from two urls
        Map<String, Cluster> clusterMap = new HashMap<String, Cluster>(urls.size());
        Map<String, StoreDefinition> storeDefinitionMap = new HashMap<String, StoreDefinition>(urls.size());

        for(String url: urls) {
            /* connect to cluster through admin port */
            if(logger.isInfoEnabled()) {
                logger.info("Connecting to bootstrap server: " + url);
            }
            AdminClient adminClient = new AdminClient(url);
            adminClients.add(adminClient);
            /* get Cluster */
            Cluster cluster = adminClient.getAdminClientCluster();
            clusterMap.put(url, cluster);

            Integer nodeId = cluster.getNodeIds().iterator().next();
            /* get StoreDefinition */
            Versioned<List<StoreDefinition>> storeDefinitions = adminClient.metadataMgmtOps.getRemoteStoreDefList(nodeId);
            StoreDefinition storeDefinition = StoreDefinitionUtils.getStoreDefinitionWithName(storeDefinitions.getValue(),
                    storeName);
            storeDefinitionMap.put(url, storeDefinition);
        }

        /* confirm same number of partitions in all clusters. */
        int partitionCount = 0;
        for(Entry<String, Cluster> entry: clusterMap.entrySet()) {
            int currentPartitionCount = entry.getValue().getNumberOfPartitions();
            if(partitionCount == 0) {
                partitionCount = currentPartitionCount;
            }
            if(partitionCount != currentPartitionCount) {
                logger.error("Partition count of different clusters is not the same: "
                        + partitionCount + " vs " + currentPartitionCount);
                throw new VoldemortException("Will not connect because partition counts differ among clusters.");
            }
        }

        /* calculate nodes to scan */
        for(String url: urls) {
            StoreDefinition storeDefinition = storeDefinitionMap.get(url);
            Cluster cluster = clusterMap.get(url);
            Map<Integer, Integer> partitionToNodeMap = cluster.getPartitionIdToNodeIdMap();

            /* find list of nodeId hosting partition */
            List<Integer> partitionList = new RoutingStrategyFactory().updateRoutingStrategy(storeDefinition,
                    cluster)
                    .getReplicatingPartitionList(partitionId);
            for(int partition: partitionList) {
                Integer nodeId = partitionToNodeMap.get(partition);
                Node node = cluster.getNodeById(nodeId);
                clusterNodeList.add(new ClusterNode(urls.indexOf(url), node));
            }
        }

        /* print config info */
        if(logger.isInfoEnabled()) {
            StringBuilder configInfo = new StringBuilder();
            configInfo.append("TYPE,Store,PartitionId,Node,ZoneId,BootstrapUrl\n");
            for(ClusterNode clusterNode: clusterNodeList) {
                configInfo.append("CONFIG,");
                configInfo.append(storeName + ",");
                configInfo.append(partitionId + ",");
                configInfo.append(clusterNode.getNode().getId() + ",");
                configInfo.append(clusterNode.getNode().getZoneId() + ",");
                configInfo.append(urls.get(clusterNode.getPrefixId()) + "\n");
            }
            for(String line: configInfo.toString().split("\n")) {
                logger.info(line);
            }
        }

        /* calculate retention days and more */
        for(String url: urls) {
            StoreDefinition storeDefinition = storeDefinitionMap.get(url);
            /* retention */
            int storeRetentionDays = 0;
            if(storeDefinition.getRetentionDays() != null) {
                storeRetentionDays = storeDefinition.getRetentionDays().intValue();
            }
            if(retentionDays == null) {
                retentionDays = storeRetentionDays;
            }
            if(retentionDays != storeRetentionDays) {
                if(storeRetentionDays != 0 && (storeRetentionDays < retentionDays)) {
                    retentionDays = storeRetentionDays;
                }
                logger.warn("Retention-days is not consistent between clusters by urls. Will use the shorter.");
            }

            /* replication writes */
            replicationFactor += storeDefinition.getReplicationFactor();

            /* required writes */
            requiredWrites += storeDefinition.getRequiredWrites();
        }
        if(replicationFactor != clusterNodeList.size()) {
            logger.error("Replication factor is not consistent with number of nodes routed to.");
            throw new VoldemortException("Will not connect because replication factor does not accord with number of nodes routed to.");
        }
        retentionChecker = new RetentionChecker(retentionDays);
    }
1332467
async def _connect(self):
        
        if self._poller:
            self._poller.join()
        self._driver.connect(self._port)
        self._device_info = self._driver.get_device_info()
        self._poller = Poller(self._driver)
        self._poller.start()
1144874
def _connect(self):
        """"""
        while self.protocol:
            _LOGGER.info('Trying to connect to %s', self.port)
            try:
                ser = serial.serial_for_url(
                    self.port, self.baud, timeout=self.timeout)
            except serial.SerialException:
                _LOGGER.error('Unable to connect to %s', self.port)
                _LOGGER.info(
                    'Waiting %s secs before trying to connect again',
                    self.reconnect_timeout)
                time.sleep(self.reconnect_timeout)
            else:
                transport = serial.threaded.ReaderThread(
                    ser, lambda: self.protocol)
                transport.daemon = False
                poll_thread = threading.Thread(target=self._poll_queue)
                self._stop_event.clear()
                poll_thread.start()
                transport.start()
                transport.connect()
                return
542616
def connect(self):
        
        jobs = []
        self._socket.connect((self.host, self.port))
        try:
            jobs = [spawn(self._recv_loop), spawn(self._send_loop)]
            joinall(jobs)
        finally:
            killall(jobs)
1024346
public void connect(String secured) {
        buildCluster(secured);
        this.cassandraqueryUtils = new CassandraQueryUtils();
        this.metadata = this.cluster.getMetadata();
        LOGGER.debug("Connected to cluster (" + host + "): "
                + metadata.getClusterName() + "\n");
        this.session = this.cluster.connect();
    }
968817
private function connectToTheNode()
    {
        $this->connection->connect(
            $this->credentials->getConnectionTimeout(),
            $this->credentials->getResponseTimeout()
        );
    }
440242
async def cluster_meet(self, node_id, host, port):
        
        return await self.execute_command('CLUSTER MEET', host, port, node_id=node_id)