AsyncStateMachine (Apache Tomcat 8.5.20 API Documentation)

org.apache.coyote

## Class AsyncStateMachine

- java.lang.Object
- - org.apache.coyote.AsyncStateMachine

-     public class AsyncStateMachine
      extends Object

  Manages the state transitions for async requests.

       The internal states that are used are:
       DISPATCHED       - Standard request. Not in Async mode.
       STARTING         - ServletRequest.startAsync() has been called but the
                          request in which that call was made has not finished
                          processing.
       STARTED          - ServletRequest.startAsync() has been called and the
                          request in which that call was made has finished
                          processing.
       READ_WRITE_OP    - Performing an asynchronous read or write.
       MUST_COMPLETE    - ServletRequest.startAsync() followed by complete() have
                          been called during a single Servlet.service() method. The
                          complete() will be processed as soon as the request
                          finishes.
       COMPLETE_PENDING - ServletRequest.startAsync() has been called and before the
                          request in which that call was had finished processing,
                          complete() was called for a non-container thread. The
                          complete() will be processed as soon as the request
                          finishes. This is different to MUST_COMPLETE because of
                          differences required to avoid race conditions during error
                          handling.
       COMPLETING       - The call to complete() was made once the request was in
                          the STARTED state. May or may not be triggered by a
                          container thread - depends if start(Runnable) was used.
       TIMING_OUT       - The async request has timed out and is waiting for a call
                          to complete(). If that isn't made, the error state will
                          entered.
       MUST_DISPATCH    - ServletRequest.startAsync() followed by dispatch() have
                          been called during a single Servlet.service() method. The
                          dispatch() will be processed as soon as the request
                          finishes.
       DISPATCH_PENDING - ServletRequest.startAsync() has been called and before the
                          request in which that call was had finished processing,
                          dispatch() was called for a non-container thread. The
                          dispatch() will be processed as soon as the request
                          finishes. This is different to MUST_DISPATCH because of
                          differences required to avoid race conditions during error
                          handling.
       DISPATCHING      - The dispatch is being processed.
       MUST_ERROR       - ServletRequest.startAsync() has been called followed by an
                          I/O error on a non-container thread. The main purpose of
                          this state is to prevent additional async actions
                          (complete(), dispatch() etc.) on the non-container thread.
                          The container will perform the necessary error handling,
                          including ensuring that the AsyncLister.onError() method
                          is called.
       ERROR            - Something went wrong.

                                 |-----«-------------------------------«------------------------------|
                                 |                                                                    |
                                 |      error()                                                       |
       |-----------------»---|   |  |--«--------MUST_ERROR---------------«------------------------|   |
       |                    \|/ \|/\|/                                                            |   |
       |   |----------«-----E R R O R--«-----------------------«-------------------------------|  |   |
       |   |      complete() /|\/|\\ \-«--------------------------------«-------|              |  |   |
       |   |                  |  |  \                                           |              |  |   |
       |   |    |-----»-------|  |   \-----------»----------|                   |              |  |   |
       |   |    |                |                          |dispatch()         |              |  ^   |
       |   |    |                |                         \|/                  ^              |  |   |
       |   |    |                |          |--|timeout()   |                   |              |  |   |
       |   |    |     post()     |          | \|/           |     post()        |              |  |   |
       |   |    |    |---------- | --»DISPATCHED«---------- | --------------COMPLETING«-----|  |  |   |
       |   |    |    |           |   /|\/|\ |               |                | /|\ /|\      |  |  |   |
       |   |    |    |    |---»- | ---|  |  |startAsync()   |       timeout()|--|   |       |  |  |   |
       |   |    ^    ^    |      |       |  |               |                       |       |  ^  |   |
       |   |    |    |    |   |-- \ -----|  |   complete()  |                       |post() |  |  |   |
       |   |    |    |    |   |    \        |     /--»----- | ---COMPLETE_PENDING-»-|       ^  |  |   |
       |   |    |    |    |   |     \       |    /          |                               |  |  |   |
       |   |    |    |    |   ^      \      |   /           |                    complete() |  |  |   |
       |  \|/   |    |    |   |       \    \|/ /   post()   |                     /---»-----|  |  ^   |
       | MUST_COMPLETE-«- | - | --«----STARTING--»--------- | ------------|      /             |  |   |
       |  /|\    /|\      |   |  complete()  | \            |             |     /   error()    |  |   ^
       |   |      |       |   |              |  \           |             |    //---»----------|  |   |
       |   |      |       ^   |    dispatch()|   \          |    post()   |   //                  |   |
       |   |      |       |   |              |    \         |    |-----|  |  //   nct-io-error    |   |
       |   |      |       |   |              |     \        |    |     |  | ///---»---------------|   |
       |   |      |       |   |             \|/     \       |    |    \|/\| |||                       |
       |   |      |       |   |--«--MUST_DISPATCH-----«-----|    |--«--STARTED«---------«---------|   |
       |   |      |       | dispatched() /|\   |      \               / |   |        post()       |   |
       |   |      |       |               |    |       \             /  |   |                     |   |
       |   |      |       |               |    |        \           /   |   |                     |   |
       |   |      |       |               |    |post()  |           |   |   |                     ^   |
       ^   |      ^       |               |    |       \|/          |   |   |asyncOperation()     |   |
       |   |      |       ^               |    |  DISPATCH_PENDING  |   |   |                     |   |
       |   |      |       |               |    |  |post()           |   |   |                     |   |
       |   |      |       |               |    |  |      |----------|   |   |»-READ_WRITE_OP--»---|   |
       |   |      |       |               |    |  |      |  dispatch()  |            |  |  |          |
       |   |      |       |               |    |  |      |              |            |  |  |          |
       |   |      |       |post()         |    |  |      |     timeout()|            |  |  |   error()|
       |   |      |       |dispatched()   |   \|/\|/    \|/             |  dispatch()|  |  |-»--------|
       |   |      |       |---«---------- | ---DISPATCHING«-----«------ | ------«----|  |
       |   |      |                       |     |    ^                  |               |
       |   |      |                       |     |----|                  |               |
       |   |      |                       |    timeout()                |               |
       |   |      |                       |                             |               |
       |   |      |                       |       dispatch()           \|/              |
       |   |      |                       |-----------«-----------TIMING_OUT            |
       |   |      |                                                 |   |               |
       |   |      |-------«----------------------------------«------|   |               |
       |   |                          complete()                        |               |
       |   |                                                            |               |
       |«- | ----«-------------------«-------------------------------«--|               |
           |                           error()                                          |
           |                                                  complete()                |
           |----------------------------------------------------------------------------|

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AsyncStateMachine(AbstractProcessor processor)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `asyncComplete()`
    `boolean` | `asyncDispatch()`
    `void` | `asyncDispatched()`
    `void` | `asyncError()`
    `void` | `asyncMustError()`
    `void` | `asyncOperation()`
    `AbstractEndpoint.Handler.SocketState` | `asyncPostProcess()`
    `void` | `asyncRun(Runnable runnable)`
    `void` | `asyncStart(AsyncContextCallback asyncCtxt)`
    `boolean` | `asyncTimeout()`
    `long` | `getLastAsyncStart()` Obtain the time that this connection last transitioned to async processing.
    `boolean` | `isAsync()`
    `boolean` | `isAsyncDispatching()`
    `boolean` | `isAsyncError()`
    `boolean` | `isAsyncStarted()`
    `boolean` | `isAsyncTimingOut()`
    `boolean` | `isCompleting()`
    `void` | `recycle()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AsyncStateMachine

          public AsyncStateMachine(AbstractProcessor processor)

  - ### Method Detail

    - #### isAsync

          public boolean isAsync()

    - #### isAsyncDispatching

          public boolean isAsyncDispatching()

    - #### isAsyncStarted

          public boolean isAsyncStarted()

    - #### isAsyncTimingOut

          public boolean isAsyncTimingOut()

    - #### isAsyncError

          public boolean isAsyncError()

    - #### isCompleting

          public boolean isCompleting()

    - #### getLastAsyncStart

          public long getLastAsyncStart()

      Obtain the time that this connection last transitioned to async processing.
      Returns:
        The time (as returned by `System.currentTimeMillis()`) that this connection last transitioned to async

    - #### asyncStart

          public void asyncStart(AsyncContextCallback asyncCtxt)

    - #### asyncOperation

          public void asyncOperation()

    - #### asyncPostProcess

          public AbstractEndpoint.Handler.SocketState asyncPostProcess()

    - #### asyncComplete

          public boolean asyncComplete()

    - #### asyncTimeout

          public boolean asyncTimeout()

    - #### asyncDispatch

          public boolean asyncDispatch()

    - #### asyncDispatched

          public void asyncDispatched()

    - #### asyncMustError

          public void asyncMustError()

    - #### asyncError

          public void asyncError()

    - #### asyncRun

          public void asyncRun(Runnable runnable)

    - #### recycle

          public void recycle()

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.