Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1.  Create an ThreadLocal storage (Context) with the following properties
            a) Ignite node-independent
            b) stores arbitrary attributes and their corresponding values
            c) provides the ability to update attribute values
            d) provides the ability to automatically undo the last Context update, restoring previous attribute values, after the corresponding operation completes
            e) provides the ability to creates a snapshot of stored attributes and their values
            f) provides the ability to restores attribute values from snapshot to Context in another thread

    This will help create a unified mechanism for attaching arbitrary data to an operation for its duration, as well as the ability to move context attribute values ​​between threads.

  2. Integrate the ability to capture Context Attributes values via snapshot creation into Thread Pool and Futures classes. It will require to create a special wrappers over existing classes.
    Methods such as ExecutorSecvice#submit or IgniteFuture#listen should automatically capture and save the state of the Context along with the closure that could potentially be executed on another thread, and restore the saved Context before executing it.

    The following Ignite and Java classes should be considered:
    1. IgniteThreadPoolExecutor
    2. StripedExecutor
    3. StripedThreadPoolExecutor
    4. ForkJoinPool
    5. ScheduledThreadPoolExecuror
    6. ForkJoinPool.commonPool
    7. GridFutureAdapter
    8. CompletableFuture

  3. Add special rules for the static code analyzer to prevent the use of multithreading-related classes of  classes related to asynchronous execution that do not support automatic Context capture/restore. And support . It seems that even the creation of new Threads in Ignite internal code should be limited by default - but this is a matter for discussion..
    We should also support an ability to exclude classes and and modules from this check - e.g. the mentioned check can be skipped for thin client related code.

  4. Research and implement a mechanism for propagating context between remote Ignite nodes to cover the case where an operation continues to execute on a remote node. The question of whether the entire Сontext should be transferred or only a specific attribute remains open, as transferring the entire Сontext between nodes may result in increased network overhead.


Example of ThreadLocal storage API:

...