Create a Cassandra-Thrift connection, but do not attempt to
set a keyspace on the connection.

@return A CTConnection ready to talk to a Cassandra cluster
@throws TTransportException on any Thrift transport failure
774330
public CTConnection makeRawConnection() throws TTransportException {
        final Config cfg = cfgRef.get();

        String hostname = cfg.getRandomHost();

        log.debug("Creating TSocket({}, {}, {}, {}, {})", hostname, cfg.port, cfg.username, cfg.password, cfg.timeoutMS);

        TSocket socket;
        if (null != cfg.sslTruststoreLocation && !cfg.sslTruststoreLocation.isEmpty()) {
            TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters() {{
               setTrustStore(cfg.sslTruststoreLocation, cfg.sslTruststorePassword);
            }};
            socket = TSSLTransportFactory.getClientSocket(hostname, cfg.port, cfg.timeoutMS, params);
        } else {
            socket = new TSocket(hostname, cfg.port, cfg.timeoutMS);
        }

        TTransport transport = new TFramedTransport(socket, cfg.frameSize);
        log.trace("Created transport {}", transport);
        TBinaryProtocol protocol = new TBinaryProtocol(transport);
        Cassandra.Client client = new Cassandra.Client(protocol);
        if (!transport.isOpen()) {
            transport.open();
        }

        if (cfg.username != null) {
            Map<String, String> credentials = new HashMap<String, String>() {{
                put(IAuthenticator.USERNAME_KEY, cfg.username);
                put(IAuthenticator.PASSWORD_KEY, cfg.password);
            }};

            try {
                client.login(new AuthenticationRequest(credentials));
            } catch (Exception e) { // TTransportException will propagate authentication/authorization failure
                throw new TTransportException(e);
            }
        }
        return new CTConnection(transport, client, cfg);
    }
867478
private ClientImpl createClientAndConnect() throws UnknownHostException, IOException
    {
        // Make client connections.
        ClientImpl clientTmp = (ClientImpl) ClientFactory.createClient(this.config);
        // ENG-6231: Only fail if we can't connect to any of the provided servers.
        boolean connectedAnything = false;
        for (String server : this.servers) {
            try {
                clientTmp.createConnection(server);
                connectedAnything = true;
            }
            catch (UnknownHostException e) {
            }
            catch (IOException e) {
            }
        }

        if (!connectedAnything) {
            try {
                clientTmp.close();
            } catch (InterruptedException ie) {}
            throw new IOException("Unable to connect to VoltDB cluster with servers: " + this.servers);
        }

        this.client.set(clientTmp);
        this.users++;
        return clientTmp;
    }
125316
public RTMPConnection createConnectionInstance(Class<?> cls) throws Exception {
        RTMPConnection conn = null;
        if (cls == RTMPMinaConnection.class) {
            conn = (RTMPMinaConnection) cls.newInstance();
        } else if (cls == RTMPTClientConnection.class) {
            conn = (RTMPTClientConnection) cls.newInstance();
        } else {
            conn = (RTMPConnection) cls.newInstance();
        }
        conn.setMaxHandshakeTimeout(maxHandshakeTimeout);
        conn.setMaxInactivity(maxInactivity);
        conn.setPingInterval(pingInterval);
        if (enableTaskExecutor) {
            // setup executor
            ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
            executor.setCorePoolSize(1);
            executor.setDaemon(true);
            executor.setMaxPoolSize(1);
            executor.setQueueCapacity(executorQueueCapacity);
            executor.initialize();
            conn.setExecutor(executor);
        }
        return conn;
    }
862949
private ThriftConnectionPartition<T> createThriftConnectionPartition(ThriftServerInfo thriftServerInfo)
			throws ThriftConnectionPoolException {
		// 队列模式
		ServiceOrder serviceOrder = this.config.getServiceOrder();

		ThriftConnectionPartition<T> thriftConnectionPartition = new ThriftConnectionPartition<>(this,
				thriftServerInfo);
		// 添加空闲连接队列
		BlockingQueue<ThriftConnectionHandle<T>> connectionHandles = new LinkedBlockingQueue<>(
				this.config.getMaxConnectionPerServer());
		thriftConnectionPartition.setFreeConnections(connectionHandles);

		if (!this.config.isLazyInit()) {
			for (int i = 0; i < this.config.getMinConnectionPerServer(); i++) {
				// 初始化连接代理对象
				thriftConnectionPartition
						.addFreeConnection(new ThriftConnectionHandle<T>(null, thriftConnectionPartition, this, false));
			}

		}

		// 连接过期时间监控
		if (this.config.getIdleConnectionTestPeriod(TimeUnit.SECONDS) > 0
				|| this.config.getIdleMaxAge(TimeUnit.SECONDS) > 0) {

			final TimerTask connectionTester = new ThriftConnectionTesterThread<T>(thriftConnectionPartition, this,
					this.config.getIdleMaxAge(TimeUnit.MILLISECONDS),
					this.config.getIdleConnectionTestPeriod(TimeUnit.MILLISECONDS), serviceOrder);
			long delayInSeconds = this.config.getIdleConnectionTestPeriod(TimeUnit.SECONDS);
			if (delayInSeconds == 0L) {
				delayInSeconds = this.config.getIdleMaxAge(TimeUnit.SECONDS);
			}
			if (this.config.getIdleMaxAge(TimeUnit.SECONDS) < delayInSeconds
					&& this.config.getIdleConnectionTestPeriod(TimeUnit.SECONDS) != 0
					&& this.config.getIdleMaxAge(TimeUnit.SECONDS) != 0) {
				delayInSeconds = this.config.getIdleMaxAge(TimeUnit.SECONDS);
			}
			TaskEngine.getInstance().scheduleAtFixedRate(connectionTester, delayInSeconds, delayInSeconds);
		}

		// 连接最长存活时间监控
		if (this.config.getMaxConnectionAgeInSeconds() > 0) {
			final TimerTask connectionMaxAgeTester = new ThriftConnectionMaxAgeThread<T>(thriftConnectionPartition,
					this, this.config.getMaxConnectionAge(TimeUnit.MILLISECONDS), serviceOrder);
			TaskEngine.getInstance().scheduleAtFixedRate(connectionMaxAgeTester,
					this.config.getMaxConnectionAgeInSeconds(), this.config.getMaxConnectionAgeInSeconds());
		}
		// 连接数量监控
		TaskEngine.getInstance().submit(new PoolWatchThread<T>(thriftConnectionPartition, this));

		return thriftConnectionPartition;

	}
435683
public synchronized boolean connect ( long timeout ) throws TransportException {
        int st = this.state;
        try {
            switch ( st ) {
            case 0:
                break;
            case 1:
                // already connecting
                this.thread.wait(timeout); /* wait for doConnect */
                st = this.state;
                switch ( st ) {
                case 1: /* doConnect never returned */
                    this.state = 6;
                    cleanupThread(timeout);
                    throw new ConnectionTimeoutException("Connection timeout");
                case 2:
                    if ( this.te != null ) { /* doConnect throw Exception */
                        this.state = 4; /* error */
                        cleanupThread(timeout);
                        throw this.te;
                    }
                    this.state = 3; /* Success! */
                    return true;
                }
                break;
            case 3:
                return true; // already connected
            case 4:
                this.state = 6;
                throw new TransportException("Connection in error", this.te);
            case 5:
            case 6:
                log.debug("Trying to connect a disconnected transport");
                return false;
            default:
                TransportException tex = new TransportException("Invalid state: " + st);
                throw tex;
            }

            if ( log.isDebugEnabled() ) {
                log.debug("Connecting " + this.name);
            }

            this.state = 1;
            this.te = null;

            Thread t = new Thread(this, this.name);
            t.setDaemon(true);
            this.thread = t;

            synchronized ( this.thread ) {
                t.start();
                t.wait(timeout); /* wait for doConnect */

                st = this.state;
                switch ( st ) {
                case 1: /* doConnect never returned */
                    this.state = 6;
                    throw new ConnectionTimeoutException("Connection timeout");
                case 2:
                    if ( this.te != null ) { /* doConnect throw Exception */
                        this.state = 4; /* error */
                        throw this.te;
                    }
                    this.state = 3; /* Success! */
                    return true;
                case 3:
                    return true;
                default:
                    return false;
                }
            }
        }
        catch ( ConnectionTimeoutException e ) {
            cleanupThread(timeout);
            // allow to retry the connection
            this.state = 0;
            throw e;
        }
        catch ( InterruptedException ie ) {
            this.state = 6;
            cleanupThread(timeout);
            throw new TransportException(ie);
        }
        catch ( TransportException e ) {
            cleanupThread(timeout);
            throw e;
        }
        finally {
            /*
             * This guarantees that we leave in a valid state
             */
            st = this.state;
            if ( st != 0 && st != 3 && st != 4 && st != 5 && st != 6 ) {
                log.error("Invalid state: " + st);
                this.state = 6;
                cleanupThread(timeout);
            }
        }
    }
571906
private ClusterManagerService.Client getCMSClient()
    throws TTransportException {
    // Get the current configuration
    CoronaConf conf = new CoronaConf(getConf());
    return getCMSClient(conf);
  }
1216881
private Connection createConnection() {

    if (mConnInfo != null) {
      DBConnCreator dbConnCreator = new DBConnCreator(mConnInfo);
      Connection conn = dbConnCreator.createDBConnection();
      return conn;
    } else if (mDbcpPropertyFile != null) {
      Properties properties = new Properties();
      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(mDbcpPropertyFile);
      try {
        properties.load(is);
        DataSource ds;
        ds = BasicDataSourceFactory.createDataSource(properties);
        Connection conn = ds.getConnection();
        return conn;
      } catch (IOException e) {
        e.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      }

    }
    return null;

  }
878691
SICoreConnection createConnection()
            throws ResourceAdapterInternalException, ResourceException {

        if (TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "createConnection");
        }

        final SICoreConnection connection;
        final SICoreConnectionFactory connectionFactory = _managedConnectionFactory
                .getCoreFactory();

        try {

            if (_subject == null) {

                connection = connectionFactory.createConnection(_userName,
                        _password, _properties);

            } else {

                connection = connectionFactory.createConnection(_subject,
                        _properties);

            }

        } catch (SIException exception) {

            FFDCFilter
                    .processException(
                            exception,
                            "com.ibm.ws.sib.ra.impl.SibRaConnectionInfo.createConnection",
                            FFDC_PROBE_1, this);
            if (TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

            throw new ResourceException(NLS.getFormattedMessage(
                    "CONNECTION_CREATION_CWSIV0300",
                    new Object[] { exception }, null), exception);

        } catch (SIErrorException exception) {

            FFDCFilter
                    .processException(
                            exception,
                            "com.ibm.ws.sib.ra.impl.SibRaConnectionInfo.createConnection",
                            FFDC_PROBE_2, this);
            if (TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

            throw new ResourceException(NLS.getFormattedMessage(
                    "CONNECTION_CREATION_CWSIV0300",
                    new Object[] { exception }, null), exception);

        }

        if (TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "createConnection", connection);
        }
        return connection;

    }
135545
@Override
    protected Client instantiateClient(String persistenceUnit)
    {
        ConnectionPool pool = getPoolUsingPolicy();
        return new ThriftClient(this, indexManager, reader, persistenceUnit, pool, externalProperties, kunderaMetadata, timestampGenerator);
    }
569437
public ThriftConnectionHandle<T> recreateConnectionHandle() throws ThriftConnectionPoolException {
		ThriftConnectionHandle<T> handle = new ThriftConnectionHandle<>(this.thriftConnection,
				this.thriftConnectionPartition, this.thriftConnectionPool, true);
		handle.thriftConnectionPartition = this.thriftConnectionPartition;
		handle.connectionCreationTimeInMs = this.connectionCreationTimeInMs;
		handle.connectionLastResetInMs = this.connectionLastResetInMs;
		handle.connectionLastUsedInMs = this.connectionLastUsedInMs;
		handle.possiblyBroken = this.possiblyBroken;
		this.thriftConnection = null;

		return handle;
	}
643644
protected final Connection<T> createConnectionForResource(T resource)
    {
        if(resource==null)
        {
            throw new FaxException("Connection resource not provided.");
        }

        //create new connection
        Connection<T> connection=new ConnectionImpl<T>(resource,this);
        
        return connection;
    }
395155
public static TcpClientTransport create(int port) {
    TcpClient tcpClient = TcpClient.create().port(port);
    return create(tcpClient);
  }
34054
public TrmRouteData createTrmRouteData() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createTrmRouteData");
    TrmRouteData msg = null;
    try {
      msg = new TrmRouteDataImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createTrmRouteData");
    return msg;
  }
1366711
public Object doGetTransaction() throws TransactionException {
		CompensatingTransactionHolderSupport holder = (CompensatingTransactionHolderSupport) TransactionSynchronizationManager
				.getResource(getTransactionSynchronizationKey());
        return new CompensatingTransactionObject(holder);
	}
176785
function getSmtpTransporter() {
  return nodemailer.createTransport(
    smtpTransport({
      // service: 'tia',
      host: gT.suiteConfig.mailSmtpHost,
      secure: true,

      // secure : false,
      // port: 25,
      auth: {
        user: gT.suiteConfig.mailUser,
        pass: gT.suiteConfig.mailPassword,
      },

      // , tls: {
      //  rejectUnauthorized: false
      // }
    })
  );
}
191964
public TrmClientAttachRequest createNewTrmClientAttachRequest() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewTrmClientAttachRequest");
    TrmClientAttachRequest msg = null;
    try {
      msg = new TrmClientAttachRequestImpl();
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewTrmClientAttachRequest");
    return msg;
  }
378762
@SuppressWarnings("unchecked")
    public CassandraJavaPairRDD<K, V> withConnector(CassandraConnector connector) {
        CassandraRDD<Tuple2<K, V>> newRDD = rdd().withConnector(connector);
        return wrap(newRDD);
    }