Handles any/all steps required in the transtion
 between states.

 @param state [Symbol] Can be 1 of 2 possible states:
   `:announced`, `:unannounced`
505186
def transition_to(state)
      ::Instana.logger.debug("Transitioning to #{state}")
      case state
      when :announced
        # announce successful; set state
        @state = :announced

        # Reset the entity timer
        @entity_last_seen = Time.now

      when :unannounced
        @state = :unannounced
        # Reset our HTTP client
        @httpclient = nil

      else
        ::Instana.logger.debug "Uknown agent state: #{state}"
      end
      ::Instana.collector.reset_timer!
      true
    end
653539
private void handleInConfirmedState(final SipPacket msg) throws SipPacketParseException {
        if (msg.isRequest()) {
            if (msg.isBye()) {
                if (this.byeRequest == null) {
                    this.byeRequest = msg.toRequest();
                }
                transition(CallState.COMPLETED, msg);
            } else if (msg.isAck()) {
                this.handshakeIsComplete = true;
                transition(CallState.IN_CALL, msg);
            }
        } else {
            final SipResponsePacket response = (SipResponsePacket) msg;
            if (response.isSuccess()) {
                // probably re-transmits.
                // need to check it better
                this.reTransmisionsDetected = true;
            } else if (response.isBye()) {
                // already in completed (or should be)
            }
        }
    }
405800
private void setState(State state) {
    if (this.state != state) {
      this.state = state;
      LOGGER.debug("State changed: {}", state);
      changeListeners.forEach(l -> l.accept(state));
    }
  }
305244
def change_state(self, state):
        """"""
        if state is not self.state:
            if self.debug:
                self.print_debug(b'state => ' + STATE_NAMES[state].encode())
            if self.state is STATE_NOT_STARTED:
                self.read_in_state_not_started = b''
            self.state = state
1117464
private void handleInCompletedState(final SipPacket msg) throws SipPacketParseException {
        if (msg.isRequest()) {
            // TODO:
        } else {
            if (msg.isBye()) {
                transition(CallState.COMPLETED, msg);
            }
        }
    }
990552
public void updateState() {
        if (Thread.currentThread() == this.homeThread) {
            IState state = null;
            // Check the state queue to see if we need to carry out a transition:
            synchronized (this.stateQueue) {
                if (this.stateQueue.size() > 0) {
                    state = this.stateQueue.remove(0);
                }
            }
            if (state != null) {
                setState(state);   // Transition to the next state.
            }
        }
    }
216156
def match_transition(name, from_state)
      find(name).find { |trans| trans.matches?(from_state) }
    end
453685
function handleAuthorizedState() {
        PermTransitionEvents.broadcastPermissionAcceptedEvent();

        // Overwrite notify option to broadcast it later
        var transitionOptions = angular.extend({}, PermTransitionProperties.options, {
          notify: false,
          location: true
        });

        $state
          .go(PermTransitionProperties.toState.name, PermTransitionProperties.toParams, transitionOptions)
          .then(function () {
            PermTransitionEvents.broadcastStateChangeSuccessEvent();
          });
      }
987603
def transition(name, states = self::STATES, transitions = self::TRANSITIONS)
      self.state_machines ||= {}
      self.state_machines[name] = { states: states.values, transitions: transitions }
      self.state_machines[name][:states].each do |this_state|
        method_name = "#{this_state}?".to_sym
        raise 'Method already defined' if self.instance_methods(false).include?(method_name)
        define_method method_name do
          current_state_based_on(this_state) == this_state
        end
      end
    end
84328
def notify_state(node, state, latency = nil)
      @lock.synchronize do
        if running?
          update_current_state(node, state, latency)
        end
      end
    rescue => ex
      logger.error("Error handling state report #{[node, state].inspect}: #{ex.inspect}")
      logger.error(ex.backtrace.join("\n"))
    end
803658
public synchronized void setState(DebugState newState)
	{
		if (!states.contains(newState))
		{
			switch (newState)
			{
				case Disconnected:
					Assert.isLegal(canChange(DebugState.Disconnected), "Cannot disconnect a terminated state");
				case Terminated:
					Assert.isLegal(canChange(DebugState.Terminated), "Cannot terminate a terminated state");
					states.clear();
					states.add(newState);
					break;
				case Suspended:
					Assert.isLegal(canChange(DebugState.Suspended), "Can only suspend if resumed");
					states.remove(DebugState.Resumed);
					states.add(newState);
					break;
				case IsStepping:
					Assert.isLegal(canChange(DebugState.IsStepping), "Cannot step if not suspended");
					states.add(newState);
					break;
				case Resumed:
					Assert.isLegal(canChange(DebugState.Resumed), "Cannot resume in a terminated state");
					if (states.contains(DebugState.IsStepping))
					{
						states.clear();
						states.add(DebugState.IsStepping);
					} else
					{
						states.clear();
					}
					states.add(newState);
					break;
				case Deadlocked:
					states.add(newState);
					break;
			}
		}
	}
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;
        }
    }
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");
  }
557258
function(options) {
        this._transitions = {}
        this._states = {}
        options = options || {}
        this._bindStates()
        this._bindTransitions()
        if (options.debugStateMachine === true)
          StateMachine.DebugView.register(this)
        this.bind('all', this._onMachineEvent, this)
        this.currentState = INIT_STATE
        this.startStateMachine = function() {
          throw new Error('startStateMachine has been called twice!')
        }
      }
512351
protected void setState(int newState) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setState", newState);

        synchronized (stateLock) {
            if ((newState == JmsInternalConstants.CLOSED)
                || (newState == JmsInternalConstants.STOPPED)
                || (newState == JmsInternalConstants.STARTED)) {
                state = newState;
                stateLock.notifyAll();
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setState");
    }
890258
protected void ensureTransitionAllowed(CmmnActivityExecution execution, CaseExecutionState expected, CaseExecutionState target, String transition) {
    String id = execution.getId();

    CaseExecutionState currentState = execution.getCurrentState();

    // the state "suspending" or "terminating" will set immediately
    // inside the corresponding AtomicOperation, that's why the
    // previous state will be used to ensure that the transition
    // is allowed.
    if (execution.isTerminating() || execution.isSuspending()) {
      currentState = execution.getPreviousState();
    }

    // is the case execution already in the target state
    if (target.equals(currentState)) {
      throw LOG.isAlreadyInStateException(transition, id, target);

    } else
    // is the case execution in the expected state
    if (!expected.equals(currentState)) {
      throw LOG.unexpectedStateException(transition, id, expected, currentState);
    }
  }
1128915
public void transition(CopycatServer.State state) {
    checkThread();

    if (this.state != null && state == this.state.type()) {
      return;
    }

    LOGGER.info("{} - Transitioning to {}", cluster.member().address(), state);

    // Close the old state.
    try {
      this.state.close().get();
    } catch (InterruptedException | ExecutionException e) {
      throw new IllegalStateException("failed to close Raft state", e);
    }

    // Force state transitions to occur synchronously in order to prevent race conditions.
    try {
      this.state = createState(state);
      this.state.open().get();
    } catch (InterruptedException | ExecutionException e) {
      throw new IllegalStateException("failed to initialize Raft state", e);
    }

    stateChangeListeners.forEach(l -> l.accept(this.state.type()));
  }