Sets the connection state to open and records the
open time. No tests are performed.
190773
final void logicalOpen() {
      openTime = Clock.currTimeMillis;
      transactionState = TransactionState.NONE;
      if(debug) {
         lastTrace = Util.getFilteredStack();
      }
   }
912021
public void start() {
        IoFutureListener<ConnectFuture> tmpConnectListener;
        if (interval > 0) {
            tmpConnectListener = new IoFutureListener<ConnectFuture>() {
                @Override
                public void operationComplete(ConnectFuture future) {
                    heartbeatFilter.setServiceConnected(future.isConnected());
                    updateConnectTimes(future.isConnected());
                }
            };
        } else {
            tmpConnectListener = new IoFutureListener<ConnectFuture>() {
                @Override
                public void operationComplete(ConnectFuture future) {
                    updateConnectTimes(future.isConnected());
                }
            };
        }
        final IoFutureListener<ConnectFuture> connectListener = tmpConnectListener;

        // set a connection pool with GT 0 prepared connections in every worker thread as an optimization
        Worker[] workers = tcpAcceptor.getWorkers();
        assert preparedConnectionCount == 0 || preparedConnectionCount >= workers.length : "Prepared connection count must be 0, or >= number of IO threads";
        int minCountPerThread = preparedConnectionCount / workers.length;
        int remainder = preparedConnectionCount % workers.length;
        for (Worker worker : workers) {
            final int count = remainder-- > 0 ? minCountPerThread + 1 : minCountPerThread;
            Runnable startConnectionPoolTask = () -> {
                ConnectionPool currentPool = connectionPool.get();
                if (currentPool == null) {
                    // the first time the pool is started is needs to be created, subsequent times it should just be started
                    // without re-creating.
                    currentPool = new ConnectionPool(serviceCtx, connectHandler, connectURI, heartbeatFilter,
                            connectListener, count, true);
                    connectionPool.set(currentPool);
                }
                currentPool.start();
            };
            worker.executeInIoThread(startConnectionPoolTask);
        }
    }
479010
void open(TopologyContext context, SpoutOutputCollector collector,
              int checkpointInterval, KeyValueState<String, CheckPointState> checkpointState) {
        this.context = context;
        this.collector = collector;
        this.checkpointInterval = checkpointInterval;
        this.sleepInterval = checkpointInterval / 10;
        this.checkpointState = checkpointState;
        this.curTxState = checkpointState.get(TX_STATE_KEY);
        lastCheckpointTs = 0;
        recoveryStepInProgress = false;
        checkpointStepInProgress = false;
        recovering = true;
    }
993624
public void setConnectTimeout(long connectTimeout, TimeUnit unit) {
        this.connectTimeout = Duration.ofMillis(unit.toMillis(connectTimeout));
    }
759164
@Override
    public void sessionOpened(IoSession session) {
        // Set timeouts
        session.getConfig().setWriteTimeout(writeTimeout);
        session.getConfig().setIdleTime(IdleStatus.READER_IDLE, readTimeout);

        // Create streams
        InputStream in = new IoSessionInputStream();
        OutputStream out = new IoSessionOutputStream(session);
        session.setAttribute(KEY_IN, in);
        session.setAttribute(KEY_OUT, out);
        processStreamIo(session, in, out);
    }
153241
def _connectionEstablished(self, transport):
        ''''''
        self.transport = transport
        self.transport.writeOpen()
        self.heartbeater.schedule()
434826
async def on_open(self):
        """"""

        self.__ensure_barrier()
        while self.connected:
            try:
                if self.__lastping > self.__lastpong:
                    raise IOError("Last ping remained unanswered")

                self.send_message("2")
                self.send_ack()
                self.__lastping = time.time()
                await asyncio.sleep(self.ping_interval)
            except Exception as ex:
                LOGGER.exception("Failed to ping")
                try:
                    self.reraise(ex)
                except Exception:
                    LOGGER.exception(
                        "failed to force close connection after ping error"
                    )
                break
1201630
def open(self):
        
        self._wr_lock.acquire()
        self._rd_lock.acquire()
        try:
            self.data_in = EMPTY_BUFFER
            self._running.set()
            sock_addresses = self._get_socket_addresses()
            self.socket = self._find_address_and_connect(sock_addresses)
            self.poller = Poller(self.socket.fileno(), self._exceptions,
                                 timeout=self._parameters['timeout'])
            self._inbound_thread = self._create_inbound_thread()
        finally:
            self._wr_lock.release()
            self._rd_lock.release()
1207383
function open()
    {
        if (!$this->_opened) {
            /* Use the DSN and options to create a database connection. */
            $this->_db = &DB::connect($this->_dsn, $this->_options);
            if (DB::isError($this->_db)) {
                return false;
            }

            /* Create a prepared statement for repeated use in log(). */
            if (!$this->_prepareStatement()) {
                return false;
            }

            /* We now consider out connection open. */
            $this->_opened = true;
        }

        return $this->_opened;
    }
366065
private synchronized void open(Execution event, String dsn) throws SQLException, PersistenceException {
        try {
            Connection conn;
            
            if( connection != null ) {
                return;
            }
            state = "OPENING";
            try {
                InitialContext ctx = new InitialContext();
                DataSource ds;
                
                if( dsn == null ) {
                    dsn = event.getDataSource();
                }
                if (dsn == null) {
                    throw new PersistenceException("No data source name");
                }
                state = "LOOKING UP";
                ds = dsCache.get(dsn);
                if (ds == null) {
                    ds = (DataSource)ctx.lookup(dsn);
                    if (ds != null) {
                        dsCache.put(dsn, ds);
                    }
                }
                if (ds == null) {
                    throw new PersistenceException("Could not find data source: " + dsn);
                }
                conn = ds.getConnection();
                openTime = System.currentTimeMillis();
                if( logger.isDebugEnabled() ) {
                    logger.debug("DPTRANSID-" + transactionId + " connection.get - dsn='" + dsn + '\'');
                }
                state = "CONNECTED";
            }
            catch( NamingException e ) {
                logger.error("Problem with datasource: " + e.getMessage());
                throw new PersistenceException(e.getMessage());
            }
            conn.setAutoCommit(false);
            conn.setReadOnly(readOnly);
            connection = conn;
            if (tracking) {
                connections.incrementAndGet();
                transactions.put(new Integer(transactionId), this);
            }
        }
        finally {
        }
    }
358651
protected synchronized void setConnection (PresentsConnection conn)
    {
        long now = System.currentTimeMillis();
        if (_conn != null) {
            // if our connection is being cleared out, record the amount of time we were connected
            // to our total connected time
            if (conn == null) {
                _connectTime += ((now - _networkStamp) / 1000);
                _messagesDropped = 0;
            }

            // make damn sure we don't get any more messages from the old connection
            _conn.clearMessageHandler();
        }

        // keep a handle to the new connection
        _conn = conn;

        // if we're setting a connection rather than clearing one out...
        if (_conn != null) {
            // tell the connection to pass messages on to us
            _conn.setMessageHandler(this);

            // configure any active custom class loader
            if (_loader != null) {
                _conn.setClassLoader(_loader);
            }
        }

        // make a note that our network status changed
        _networkStamp = now;
    }
415837
private synchronized void connectionOpened(String protocol, 
                                               String extensionsHeader) {
        // ### TODO: Currently, the Gateway is not sending the negotiated
        //           protocol.
        setNegotiatedProtocol(protocol);
        
        // Parse the negotiated extensions and parameters. This can result in 
        // _exception to be setup indicating that there is something wrong
        // while parsing the negotiated extensions and parameters.
        setNegotiatedExtensions(extensionsHeader);
        
        if ((getException() == null) && (_readyState == ReadyState.CONNECTING)) {
            _readyState = ReadyState.OPEN;
        }
        else {
            // The exception can be caused either while parsing the negotiated
            // extensions and parameters or the expiry of the connection timeout.
            // The parsing of negotiated extension can cause an exception if -- 
            // 1) a negotiated extension is not an enabled extension or
            // 2) the type of a negotiated parameter is not String.
            _readyState = ReadyState.CLOSED;
            
            // Inform the Gateway to close the WebSocket.
            _handler.processClose(_channel, 0, null);
        }

        // Unblock the connect() call so that it can proceed.
        notifyAll();
    }
5226
def get_connection_state(self, connection: str) -> Dict[str, Any]:
        
        if connection not in self.connections:
            raise ConnectionNotOpen(connection)

        return self.connections[connection].state
14550
public synchronized boolean setToSuspended()
    {
        if ( state.get() != State.STARTED )
        {
            return false;
        }

        if ( (currentConnectionState == ConnectionState.LOST) || (currentConnectionState == ConnectionState.SUSPENDED) )
        {
            return false;
        }

        currentConnectionState = ConnectionState.SUSPENDED;
        postState(ConnectionState.SUSPENDED);

        return true;
    }
323085
def on_open(self, _handle):
        
        self.logger.debug('Connection opened')
        self.handle.add_on_connection_blocked_callback(self.on_blocked)
        self.handle.add_on_connection_unblocked_callback(self.on_unblocked)
        self.handle.add_on_close_callback(self.on_closed)
        self.handle.channel(self.on_channel_open)
543032
public void setConnectTimeout(int connectTimeout) {
		this.client = this.client.newBuilder()
				.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
				.build();
	}
644765
public boolean areAnyOpen() {
        //==========================================================================//
        //============== Describe Spot Instance Requests to determine =============//
        //==========================================================================//

        // Create the describeRequest with tall of the request id to monitor (e.g. that we started).
        DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpotInstanceRequestsRequest();
        describeRequest.setSpotInstanceRequestIds(spotInstanceRequestIds);

        System.out.println("Checking to determine if Spot Bids have reached the active state...");

        // Initialize variables.
        instanceIds = new ArrayList<String>();

        try
        {
            // Retrieve all of the requests we want to monitor.
            DescribeSpotInstanceRequestsResult describeResult = ec2.describeSpotInstanceRequests(describeRequest);
            List<SpotInstanceRequest> describeResponses = describeResult.getSpotInstanceRequests();

            // Look through each request and determine if they are all in the active state.
            for (SpotInstanceRequest describeResponse : describeResponses) {
                System.out.println(" " +describeResponse.getSpotInstanceRequestId() +
                                   " is in the "+describeResponse.getState() + " state.");

                // If the state is open, it hasn't changed since we attempted to request it.
                // There is the potential for it to transition almost immediately to closed or
                // cancelled so we compare against open instead of active.
                if (describeResponse.getState().equals("open")) {
                    return true;
                }

                // Add the instance id to the list we will eventually terminate.
                instanceIds.add(describeResponse.getInstanceId());
            }
        } catch (AmazonServiceException e) {
            // Print out the error.
            System.out.println("Error when calling describeSpotInstances");
            System.out.println("Caught Exception: " + e.getMessage());
            System.out.println("Reponse Status Code: " + e.getStatusCode());
            System.out.println("Error Code: " + e.getErrorCode());
            System.out.println("Request ID: " + e.getRequestId());

            // If we have an exception, ensure we don't break out of the loop.
            // This prevents the scenario where there was blip on the wire.
            return true;
        }

        return false;
    }