Connect to client shared object.

@param name
Client shared object name
@param persistent
SO persistence flag
@return Client shared object instance
971416
@Override
    public IClientSharedObject getSharedObject(String name, boolean persistent) {
        log.debug("getSharedObject name: {} persistent {}", new Object[] { name, persistent });
        ClientSharedObject result = sharedObjects.get(name);
        if (result != null) {
            if (result.isPersistent() != persistent) {
                throw new RuntimeException("Already connected to a shared object with this name, but with different persistence.");
            }
            return result;
        }
        result = new ClientSharedObject(name, persistent);
        sharedObjects.put(name, result);
        return result;
    }
714756
public static ConnectionHolder getConnectionHolder(ConsumerBootstrap consumerBootstrap) {
        try {
            String connectionHolder = consumerBootstrap.getConsumerConfig().getConnectionHolder();
            ExtensionClass<ConnectionHolder> ext = ExtensionLoaderFactory
                .getExtensionLoader(ConnectionHolder.class).getExtensionClass(connectionHolder);
            if (ext == null) {
                throw ExceptionUtils.buildRuntime("consumer.connectionHolder", connectionHolder,
                    "Unsupported connectionHolder of client!");
            }
            return ext.getExtInstance(new Class[] { ConsumerBootstrap.class }, new Object[] { consumerBootstrap });
        } catch (SofaRpcRuntimeException e) {
            throw e;
        } catch (Throwable e) {
            throw new SofaRpcRuntimeException(e.getMessage(), e);
        }
    }
55115
public Object setConnectionProperty(String name, String value) {
        return connProperties.setProperty(name, value);
    }
485493
public void connectClient(Connection connection) {
    threadContext.checkThread();

    // Note we do not use method references here because the "state" variable changes over time.
    // We have to use lambdas to ensure the request handler points to the current state.
    connection.handler(RegisterRequest.class, (Function<RegisterRequest, CompletableFuture<RegisterResponse>>) request -> state.register(request));
    connection.handler(ConnectRequest.class, (Function<ConnectRequest, CompletableFuture<ConnectResponse>>) request -> state.connect(request, connection));
    connection.handler(KeepAliveRequest.class, (Function<KeepAliveRequest, CompletableFuture<KeepAliveResponse>>) request -> state.keepAlive(request));
    connection.handler(UnregisterRequest.class, (Function<UnregisterRequest, CompletableFuture<UnregisterResponse>>) request -> state.unregister(request));
    connection.handler(ResetRequest.class, (Consumer<ResetRequest>) request -> state.reset(request));
    connection.handler(CommandRequest.class, (Function<CommandRequest, CompletableFuture<CommandResponse>>) request -> state.command(request));
    connection.handler(QueryRequest.class, (Function<QueryRequest, CompletableFuture<QueryResponse>>) request -> state.query(request));

    connection.onClose(stateMachine.executor().context().sessions()::unregisterConnection);
  }
663974
public Optional<Client> findClient(final String name) {
        CommonHelper.assertNotBlank("name", name);
        init();
        final String lowerTrimmedName = name.toLowerCase().trim();
        final Client client = _clients.get(lowerTrimmedName);
        if (client != null) {
            return Optional.of(client);
        }
        LOGGER.debug("No client found for name: {}", name);
        return Optional.empty();
    }
1244912
public static SparkDataClient getDataClient(String clientName)
    {

        if (clientPool.get(clientName) != null)
        {
            return clientPool.get(clientName);
        }
        try
        {
            SparkDataClient dataClient = (SparkDataClient) KunderaCoreUtils.createNewInstance(Class
                    .forName(clientNameToClass.get(clientName)));
            clientPool.put(clientName, dataClient);
            return dataClient;
        }
        catch (Exception e)
        {
            logger.error(clientName
                    + " client is invalid/not supported. Please check kundera.client in persistence properties.");
            throw new KunderaException(clientName
                    + " client is invalid/not supported. Please check kundera.client in persistence properties.");
        }
    }
78304
public function db_connect($persistent = FALSE, $conn_id = NULL)
	{
		$client_flags = ($this->compress === FALSE) ? 0 : MYSQL_CLIENT_COMPRESS;

		if ($this->encrypt === TRUE)
		{
			$client_flags = $client_flags | MYSQL_CLIENT_SSL;
		}
        
		if( $conn_id && is_resource($conn_id) ){
		    $this->conn_id = $conn_id;
        }
        else {
            // Error suppression is necessary mostly due to PHP 5.5+ issuing E_DEPRECATED messages
            $this->conn_id = ($persistent === true)
                ? mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags)
                : mysql_connect($this->hostname, $this->username, $this->password, true, $client_flags);
        }

		// ----------------------------------------------------------------

		// Select the DB... assuming a database name is specified in the config file
		if ($this->database !== '' && ! $this->db_select())
		{
			return ($this->db_debug === TRUE)
				? $this->display_error('db_unable_to_select', $this->database)
				: FALSE;
		}

		if ($this->stricton && is_resource($this->conn_id))
		{
			$this->simple_query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
		}

		return $this->conn_id;
	}
266317
public static DBContext offlineInstance(String name) {
    DB db = DBMaker
        .fileDB(name)
        .fileMmapEnableIfSupported()
        .closeOnJvmShutdown()
        .cleanerHackEnable()
        .transactionEnable()
        .fileDeleteAfterClose()
        .make();

    return new MapDBContext(db);
  }
1297863
@Override
    public Session connectToServer(Object clazz, URI path) throws DeploymentException, IOException {

        if (clazz == null || path == null) {
            throw new IllegalArgumentException();
        }
        ClientConnector x = new ClientConnector();
        return x.connectAnnotatedClass(clazz, path, this);
    }
631076
public Member getMember(String name) {
        if (null == keyValStore) throw new RuntimeException("No key value store was found.  You must first call Chain.setKeyValStore");
        if (null == memberServices) throw new RuntimeException("No member services was found.  You must first call Chain.setMemberServices or Chain.setMemberServicesUrl");

        // Try to get the member state from the cache
        Member member = (Member) members.get(name);
        if (null != member) return member;

        // Create the member and try to restore it's state from the key value store (if found).
        member = new Member(name, this);
        member.restoreState();
        return member;

    }
680334
public Engine addSharedObject(String name, Object object) {
		config.addSharedObject(name, object);
		return this;
	}
796737
public SomeUnpublishedObject create(
            final String name) {
        final SomeUnpublishedObject obj = container.newTransientInstance(SomeUnpublishedObject.class);
        obj.setName(name);
        container.persistIfNotAlready(obj);
        return obj;
    }
1134775
protected function _getGuzzleClient(bool $persistent = true): Client
    {
        if (!$persistent || !self::$_guzzleClientConnection) {
            self::$_guzzleClientConnection = new Client();
        }

        return self::$_guzzleClientConnection;
    }
74020
protected function createConnection($name)
    {
        $config = $this->getConfig($name);

        $connection = new Client($config);

        $connection->connect();

        return $connection;
    }
748715
@Override
    protected Object createPoolOrConnection()
    {
        PersistenceUnitMetadata persistenceUnitMetadata = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(getPersistenceUnit());

        Properties props = persistenceUnitMetadata.getProperties();

        String host = externalProperties != null ? (String) externalProperties.get(PersistenceProperties.KUNDERA_NODES)
                : null;
        String port = externalProperties != null ? (String) externalProperties.get(PersistenceProperties.KUNDERA_PORT)
                : null;

        if (host == null)
        {
            host = props.getProperty(PersistenceProperties.KUNDERA_NODES);
        }

        if (port == null)
        {
            port = props.getProperty(PersistenceProperties.KUNDERA_PORT);
        }

        String[] hosts = getHosts(host);

        Properties properties = ((ESClientPropertyReader) propertyReader).getConnectionProperties();

        Builder builder = Settings.settingsBuilder();

        builder.put("client.transport.sniff", true);

        if (properties != null)
        {
            builder.put(properties);
        }

        Settings settings = builder.build();

        TransportClient client = TransportClient.builder().settings(settings).build();

        for (String h : hosts)
        {
            client.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress(h, new Integer(port))));
        }

        return client;
    }
411694
public static DBContext onlineInstance(String name) {
    DB db = DBMaker
        .fileDB(name)
        .fileMmapEnableIfSupported()
        .closeOnJvmShutdown()
        .transactionEnable()
        .make();

    return new MapDBContext(db);
  }
170600
public function create($name)
    {
        $config = $this->getConfiguration($name);

        if(null === $config) {
            throw new \RuntimeException(
                "Connection with name: $name not found."
            );
        }

        return new Client($config);
    }