Request to set this connection into a new connection state.

@param newState new state to set
325021
protected final void setState(final int newState)
	{
		if (closing < 2) {
			//  detect and ignore order of arrival inversion for tunneling.ack/cEMI.con
			if (internalState == OK && newState == ClientConnection.CEMI_CON_PENDING)
				return;
			internalState = newState;
			if (updateState)
				state = newState;
		}
		else
			state = internalState = CLOSED;
	}
512209
public T set(T newState)
    {
        checkState(!Thread.holdsLock(lock), "Can not set state while holding the lock");
        requireNonNull(newState, "newState is null");

        T oldState;
        FutureStateChange<T> futureStateChange;
        ImmutableList<StateChangeListener<T>> stateChangeListeners;
        synchronized (lock) {
            if (state.equals(newState)) {
                return state;
            }

            checkState(!isTerminalState(state), "%s can not transition from %s to %s", name, state, newState);

            oldState = state;
            state = newState;

            futureStateChange = this.futureStateChange.getAndSet(new FutureStateChange<>());
            stateChangeListeners = ImmutableList.copyOf(this.stateChangeListeners);

            // if we are now in a terminal state, free the listeners since this will be the last notification
            if (isTerminalState(state)) {
                this.stateChangeListeners.clear();
            }
        }

        fireStateChanged(newState, futureStateChange, stateChangeListeners);
        return oldState;
    }
574274
protected void setSICoreConnection(SICoreConnection connection)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "setSICoreConnection", connection);

      //Retrieve Client Conversation State if necessary
      validateConversationState();
      cConState.setSICoreConnection(connection);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "setSICoreConnection");
   }
864993
public void setState(String state)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "setState", state);

    this.state = state;

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "setState");
  }
179009
public synchronized boolean addStateChange(ConnectionState newConnectionState)
    {
        if ( state.get() != State.STARTED )
        {
            return false;
        }

        ConnectionState previousState = currentConnectionState;
        if ( previousState == newConnectionState )
        {
            return false;
        }
        currentConnectionState = newConnectionState;

        ConnectionState localState = newConnectionState;
        boolean isNegativeMessage = ((newConnectionState == ConnectionState.LOST) || (newConnectionState == ConnectionState.SUSPENDED) || (newConnectionState == ConnectionState.READ_ONLY));
        if ( !isNegativeMessage && initialConnectMessageSent.compareAndSet(false, true) )
        {
            localState = ConnectionState.CONNECTED;
        }

        postState(localState);

        return true;
    }
354435
private synchronized void setService( final T newService )
    {
        if( m_service != newService )
        {
            LOG.debug( "Service changed [" + m_service + "]  -> [" + newService + "]" );
            final T oldService = m_service;
            m_service = newService;
            if( m_serviceListener != null )
            {
                m_serviceListener.serviceChanged( oldService, m_service );
            }
        }
    }
1056516
private void changeStateTo(int newState) {
    int oldState = this.status.getRunState();
    if (oldState == newState) {
      return; //old and new states are same
    }
    this.status.setRunState(newState);

    //update the metrics
    if (oldState == JobStatus.PREP) {
      this.jobtracker.getInstrumentation().decPrepJob(conf, jobId);
    } else if (oldState == JobStatus.RUNNING) {
      this.jobtracker.getInstrumentation().decRunningJob(conf, jobId);
    }

    if (newState == JobStatus.PREP) {
      this.jobtracker.getInstrumentation().addPrepJob(conf, jobId);
    } else if (newState == JobStatus.RUNNING) {
      this.jobtracker.getInstrumentation().addRunningJob(conf, jobId);
    }

  }
1166691
def set_connection_state():
    """"""
    message = create(protobuf.ProtocolMessage.SET_CONNECTION_STATE_MESSAGE)
    message.inner().state = protobuf.SetConnectionStateMessage.Connected
    return message
1236802
public void setSession(Session newSession) {
        if (newSession == null) {
            if (session != null) {
                // We're current tracking a Session. Remove the callback
                // and start tracking the active Session.
                session.removeCallback(callback);
                session = null;
                addBroadcastReceiver();
                if (getSession() != null) {
                    getSession().addCallback(callback);
                }
            }
        } else {
            if (session == null) {
                // We're currently tracking the active Session, but will be
                // switching to tracking a different Session object.
                Session activeSession = Session.getActiveSession();
                if (activeSession != null) {
                    activeSession.removeCallback(callback);
                }
                broadcastManager.unregisterReceiver(receiver);
            } else {
                // We're currently tracking a Session, but are now switching 
                // to a new Session, so we remove the callback from the old 
                // Session, and add it to the new one.
                session.removeCallback(callback);
            }
            session = newSession;
            session.addCallback(callback);
        }
    }
281051
@Override
    public AuthenticationRequest setConnection(String connection) {
        if (!hasLegacyPath()) {
            Log.w(TAG, "Not setting the 'connection' parameter as the request is using a OAuth 2.0 API Authorization endpoint that doesn't support it.");
            return this;
        }
        addParameter(CONNECTION_KEY, connection);
        return this;
    }
996782
public void setPortStates(java.util.Collection<InstancePortState> portStates) {
        if (portStates == null) {
            this.portStates = null;
            return;
        }

        this.portStates = new java.util.ArrayList<InstancePortState>(portStates);
    }
1128474
void gotoState(@Nonnull ConnectivityState newState) {
    checkNotNull(newState, "newState");
    if (state != newState && state != ConnectivityState.SHUTDOWN) {
      state = newState;
      if (listeners.isEmpty()) {
        return;
      }
      // Swap out callback list before calling them, because a callback may register new callbacks,
      // if run in direct executor, can cause ConcurrentModificationException.
      ArrayList<Listener> savedListeners = listeners;
      listeners = new ArrayList<>();
      for (Listener listener : savedListeners) {
        listener.runInExecutor();
      }
    }
  }
226425
@Override
  public Connection<T> newConnection(final Identifier destId) {
    final Connection<T> connection = connectionMap.get(destId);

    if (connection == null) {
      final Connection<T> newConnection = new NetworkConnection<>(this, destId);
      connectionMap.putIfAbsent(destId, newConnection);
      return connectionMap.get(destId);
    }
    return connection;
  }
50302
@Override
    public void setState(TransferState state) {
        super.setState(state);

        switch (state) {
        case Waiting:
            fireProgressEvent(ProgressEventType.TRANSFER_PREPARING_EVENT);
            break;
        case InProgress:
            if ( subTransferStarted.compareAndSet(false, true) ) {
                /* The first InProgress signal */
                fireProgressEvent(ProgressEventType.TRANSFER_STARTED_EVENT);
            }
            /* Don't need any event code update for subsequent InProgress signals */
            break;
        case Completed:
            fireProgressEvent(ProgressEventType.TRANSFER_COMPLETED_EVENT);
            break;
        case Canceled:
            fireProgressEvent(ProgressEventType.TRANSFER_CANCELED_EVENT);
            break;
        case Failed:
            fireProgressEvent(ProgressEventType.TRANSFER_FAILED_EVENT);
            break;
        default:
            break;
        }
    }
988688
protected final synchronized void setState(int newState)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && // d527372
            TEBeanLifeCycleInfo.isTraceEnabled())
            TEBeanLifeCycleInfo.traceBeanState(state, getStateName(state), newState,
                                               getStateName(newState)); // d167264

        state = newState;
    }
1349516
@SuppressWarnings("unchecked")
  private void setupConnection(Address address, Connection connection, CompletableFuture<Connection> future) {
    LOGGER.debug("{} - Setting up connection to {}", id, address);

    this.connection = connection;

    connection.onClose(c -> {
      if (c.equals(this.connection)) {
        LOGGER.debug("{} - Connection closed", id);
        this.connection = null;
      }
    });
    connection.onException(c -> {
      if (c.equals(this.connection)) {
        LOGGER.debug("{} - Connection lost", id);
        this.connection = null;
      }
    });

    for (Map.Entry<Class<?>, Function> entry : handlers.entrySet()) {
      connection.handler(entry.getKey(), entry.getValue());
    }

    // When we first connect to a new server, first send a ConnectRequest to the server to establish
    // the connection with the server-side state machine.
    ConnectRequest request = ConnectRequest.builder()
      .withClientId(id)
      .build();

    LOGGER.trace("{} - Sending {}", id, request);
    connection.<ConnectRequest, ConnectResponse>sendAndReceive(request).whenComplete((r, e) -> handleConnectResponse(r, e, future));
  }
337151
def set_state(self, newState, timer=0):
        """"""
        if _debug: ServerSSM._debug("set_state %r (%s) timer=%r", newState, SSM.transactionLabels[newState], timer)

        # do the regular state change
        SSM.set_state(self, newState, timer)

        # when completed or aborted, remove tracking
        if (newState == COMPLETED) or (newState == ABORTED):
            if _debug: ServerSSM._debug("    - remove from active transactions")
            self.ssmSAP.serverTransactions.remove(self)

            # release the device info
            if self.device_info:
                if _debug: ClientSSM._debug("    - release device information")
                self.ssmSAP.deviceInfoCache.release(self.device_info)