Allows the remote end of the specified connection to access objects registered in this ObjectSpace.
353280
public void addConnection (Connection connection) {
		if (connection == null) throw new IllegalArgumentException("connection cannot be null.");

		synchronized (connectionsLock) {
			Connection[] newConnections = new Connection[connections.length + 1];
			newConnections[0] = connection;
			System.arraycopy(connections, 0, newConnections, 1, connections.length);
			connections = newConnections;
		}

		connection.addListener(invokeListener);

		if (TRACE) trace("kryonet", "Added connection to ObjectSpace: " + connection);
	}
24493
public void activeClose(TransferContext context, int connections) {

        try {

            //this could be improved; for symmetry and performance,
            //make it a separate task class and pass to the taskThread
            for (int i = 0; i < connections; i++) {
                SocketBox sbox = socketPool.checkOut();
                try {
                    GridFTPDataChannel dc = new GridFTPDataChannel(gSession, sbox);
                    EBlockImageDCWriter writer = (EBlockImageDCWriter)dc.getDataChannelSink(context);
                    writer.setDataStream(sbox.getSocket().getOutputStream());
                    // close the socket
                    writer.close();
                } finally {
                    // do not reuse the socket
                    socketPool.remove(sbox);
                    sbox.setSocket(null);
                }
            }

        } catch (Exception e) {
            FTPServerFacade.exceptionToControlChannel(
                e,
                "closing of a reused connection failed",
                localControlChannel);
        }
    }
785073
def fetch(self, end=values.unset, start=values.unset):
        
        return self._proxy.fetch(end=end, start=start, )
500097
private Connection getConnection(InetSocketAddress addr,
                                   Class<?> protocol,
                                   UserGroupInformation ticket,
                                   int rpcTimeout,
                                   Call call)
                                   throws IOException {
    if (!running.get()) {
      // the client is stopped
      throw new IOException("The client is stopped");
    }
    Connection connection;
    /* we could avoid this allocation for each RPC by having a  
     * connectionsId object and with set() method. We need to manage the
     * refs for keys in HashMap properly. For now its ok.
     */
    ConnectionId remoteId = new ConnectionId(
		addr, protocol, ticket, rpcTimeout);
    do {
      synchronized (connections) {
        connection = connections.get(remoteId);
        if (connection == null) {
          connection = new Connection(remoteId);
          connections.put(remoteId, connection);
        }
      }
    } while (!connection.addCall(call));
    
    //we don't invoke the method below inside "synchronized (connections)"
    //block above. The reason for that is if the server happens to be slow,
    //it will take longer to establish a connection and that will slow the
    //entire system down.
    boolean success = false;
    try {
      connection.setupIOstreams();
      success = true;
    } finally {
      if (!success) {
        // We need to make sure connection is removed from connections object if
        // there is any unhandled exception (like OOM). In this case, unlikely
        // there is response thread started which can clear the connection
        // eventually.
        try {
          if (connection.closeException == null) {
            connection.markClosed(new IOException(
                "Unexpected error when setup IO Stream"));
          }
        } finally {
          connection.close(true);
        }
      }
    }
    return connection;
  }
331858
@Override
	public void close() throws RemoteException {
		s.close();
		if (rconn.getAutoCommit())
			rconn.commit();
		else
			rconn.endStatement();
	}
881903
function(callback) {
                connection.end();

                client.close();
                client.__sftp = null;
                client.__ssh = null;

                callback();
            }
1234067
private void closeOutgoingSockets() throws ClientException {

        SocketOperator op = new SocketOperator() {
                public void operate(SocketBox sb) throws Exception {
                    if (((ManagedSocketBox) sb).isReusable()) {
                        Socket s = sb.getSocket();
                        if (s != null) {
                            // write the closing Eblock and close the socket
                            EBlockImageDCWriter.close(
                                  new DataOutputStream(s.getOutputStream()));
                        }
                    }
                }
       };

        try {
            socketPool.applyToAll(op);
        } catch (IOException e) {
            // ignore - sometimes server might close the socket
        } catch (Exception e) {
            ClientException ce =
                new ClientException(ClientException.SOCKET_OP_FAILED);
            ce.setRootCause(e);
            throw ce;
        }
    }
321570
def _use_remote_connection(self, kwargs):
        '''
        
        '''
        kwargs['host'] = kwargs.get('host')
        kwargs['username'] = kwargs.get('username')
        kwargs['password'] = kwargs.get('password')
        if kwargs['host'] is None or \
           kwargs['username'] is None or \
           kwargs['password'] is None:
            return False
        else:
            return True
897954
def manual_close(self):
        
        if self.is_closed():
            return False

        # Obtain reference to the connection in-use by the calling thread.
        conn = self.connection()

        # A connection will only be re-added to the available list if it is
        # marked as "in use" at the time it is closed. We will explicitly
        # remove it from the "in use" list, call "close()" for the
        # side-effects, and then explicitly close the connection.
        self._in_use.pop(self.conn_key(conn), None)
        self.close()
        self._close(conn, close_conn=True)
470183
@Override
    public void closeConnection() throws JdbcServerException {
        if (!endpointConfiguration.isAutoConnect()) {
            handleMessageAndCheckResponse(JdbcMessage.closeConnection());
        }

        if (connections.decrementAndGet() < 0) {
            connections.set(0);
        }
    }
159564
def end(self):
        """"""
        if not self.args.disable_autodiscover:
            self.autodiscover_client.close()
        self.server.end()
691667
public void setReturnSessionOrObject(PrintWriter out, Object objReturn)
    {
        String strID = null;
        String strSessionClass = null;
        if (objReturn instanceof RemoteTable)
        {
            strSessionClass = REMOTE_TABLE;
            strID = this.add(new TableHolder(this, (RemoteTable)objReturn));
        }
        else if (objReturn instanceof RemoteSession)
        {
            strSessionClass = REMOTE_SESSION;
            strID = this.add(new SessionHolder(this, (RemoteSession)objReturn));
        }
        else if (objReturn instanceof RemoteBaseSession)
        {
            strSessionClass = REMOTE_BASE_SESSION;
            strID = this.add(new BaseSessionHolder(this, (RemoteBaseSession)objReturn));
        }
        if (strID != null)
            this.setReturnString(out, strSessionClass + CLASS_SEPARATOR + strID);
        else
            this.setReturnObject(out, objReturn);
    }
1081360
static public void register (EndPoint endPoint) {
		Kryo kryo = endPoint.getKryo();
		// This must be called in order to use ObjectSpaces.
		ObjectSpace.registerClasses(kryo);
		// The interfaces that will be used as remote objects must be registered.
		kryo.register(IPlayer.class);
		kryo.register(IChatFrame.class);
		// The classes of all method parameters and return values
		// for remote objects must also be registered.
		kryo.register(String[].class);
	}
587345
def get_object(conn, binding_name, object_cls):
        
        try:
            obj = conn.rootContext.resolve(binding_name)
            narrowed = obj._narrow(object_cls)
        except CORBA.TRANSIENT:
            raise IOError('Attempt to retrieve object failed')

        if narrowed is None:
            raise IOError('Attempt to retrieve object got a different class of object')

        return narrowed
1285637
private void closeOutboundInternal() {

        if ((debug != null) && Debug.isOn("ssl")) {
            System.out.println(threadName() + ", closeOutboundInternal()");
        }

        /*
         * Already closed, ignore
         */
        if (writer.isOutboundDone()) {
            return;
        }

        switch (connectionState) {

        /*
         * If we haven't even started yet, don't bother reading inbound.
         */
        case cs_START:
            writer.closeOutbound();
            inboundDone = true;
            break;

        case cs_ERROR:
        case cs_CLOSED:
            break;

        /*
         * Otherwise we indicate clean termination.
         */
        // case cs_HANDSHAKE:
        // case cs_DATA:
        // case cs_RENEGOTIATE:
        default:
            warning(Alerts.alert_close_notify);
            writer.closeOutbound();
            break;
        }

        // See comment in changeReadCiphers()
        writeCipher.dispose();

        connectionState = cs_CLOSED;
    }
794700
void connectionClosed(final SibRaConnection connection) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "connectionClosed", connection);
        }

        final ConnectionEvent event = new ConnectionEvent(this,
                ConnectionEvent.CONNECTION_CLOSED);
        event.setConnectionHandle(connection);

        for (Iterator iterator = _eventListeners.iterator(); iterator.hasNext();) {

            final ConnectionEventListener listener = (ConnectionEventListener) iterator
                    .next();
            listener.connectionClosed(event);

        }

        _connections.remove(connection);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "connectionClosed");
        }

    }
1002190
protected void internalReleaseConnection(ThriftConnectionHandle<T> connectionHandle)
			throws ThriftConnectionPoolException {
		if (connectionHandle.isExpired() || (!this.poolShuttingDown && connectionHandle.isPossiblyBroken()
				&& !isConnectionHandleAlive(connectionHandle))) {

			if (connectionHandle.isExpired()) {
				connectionHandle.internalClose();
			}

			ThriftConnectionPartition<T> connectionPartition = connectionHandle.getConnectionPartition();
			postDestroyConnection(connectionHandle);

			maybeSignalForMoreConnections(connectionPartition);
			return;
		}
		connectionHandle.setConnectionLastUsedInMs(System.currentTimeMillis());
		if (!this.poolShuttingDown) {
			putConnectionBackInPartition(connectionHandle);
		} else {
			connectionHandle.internalClose();
		}
	}