com.hazelcast.spi

## Interface OperationService

-     public interface OperationService

  The OperationService is responsible for executing operations.

  A single operation can be executed locally using `run(Operation)` and `execute(Operation)`. Or it can executed remotely using one of the send methods.

  It also is possible to execute multiple operation on multiple partitions using one of the invoke methods.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `InvocationBuilder` | `createInvocationBuilder(String serviceName, Operation op, Address target)`
    `InvocationBuilder` | `createInvocationBuilder(String serviceName, Operation op, int partitionId)`
    `void` | `execute(Operation op)` Executes an operation in the operation executor pool.
    `Map<Integer,Object>` | `invokeOnAllPartitions(String serviceName, OperationFactory operationFactory)` Invokes a set of operations on each partition.
    `<T> ICompletableFuture<Map<Integer,T>>` | `invokeOnAllPartitionsAsync(String serviceName, OperationFactory operationFactory)` Invokes a set of operations on selected set of all partitions in an async way.
    `<E> InternalCompletableFuture<E>` | `invokeOnPartition(Operation op)` Executes an operation on a partition.
    `<E> InternalCompletableFuture<E>` | `invokeOnPartition(String serviceName, Operation op, int partitionId)`
    `<T> Map<Integer,T>` | `invokeOnPartitions(String serviceName, OperationFactory operationFactory, Collection<Integer> partitions)` Invokes a set of operations on selected set of partitions.
    `Map<Integer,Object>` | `invokeOnPartitions(String serviceName, OperationFactory operationFactory, int[] partitions)` Invokes a set of operations on selected set of partitions.
    `<T> ICompletableFuture<Map<Integer,T>>` | `invokeOnPartitionsAsync(String serviceName, OperationFactory operationFactory, Collection<Integer> partitions)` Invokes a set of operations on selected set of partitions in an async way.
    `<E> InternalCompletableFuture<E>` | `invokeOnTarget(String serviceName, Operation op, Address target)`
    `void` | `run(Operation op)` Runs an operation in the calling thread.
    `boolean` | `send(Operation op, Address target)` Executes an operation remotely.

- - ### Method Detail

    - #### run

          void run(Operation op)

      Runs an operation in the calling thread.
      Parameters:
        `op` - the operation to execute in the calling thread

    - #### execute

          void execute(Operation op)

      Executes an operation in the operation executor pool.
      Parameters:
        `op` - the operation to execute in the operation executor pool.

    - #### invokeOnPartition

          <E> InternalCompletableFuture<E> invokeOnPartition(String serviceName,
                                                             Operation op,
                                                             int partitionId)

    - #### invokeOnPartition

          <E> InternalCompletableFuture<E> invokeOnPartition(Operation op)

      Executes an operation on a partition.
      Type Parameters:
        `E` - the return type of the operation response
      Parameters:
        `op` - the operation
      Returns:
        the future.

    - #### invokeOnTarget

          <E> InternalCompletableFuture<E> invokeOnTarget(String serviceName,
                                                          Operation op,
                                                          Address target)

    - #### createInvocationBuilder

          InvocationBuilder createInvocationBuilder(String serviceName,
                                                    Operation op,
                                                    int partitionId)

    - #### createInvocationBuilder

          InvocationBuilder createInvocationBuilder(String serviceName,
                                                    Operation op,
                                                    Address target)

    - #### invokeOnAllPartitions

          Map<Integer,Object> invokeOnAllPartitions(String serviceName,
                                                    OperationFactory operationFactory)
                                             throws Exception

      Invokes a set of operations on each partition.

      This method blocks until the operations complete.

      If the operations have sync backups, this method will not wait for their completion. Instead, it will return once the operations are completed on primary replicas of the given `partitions`.

      Parameters:
        `serviceName` - the name of the service.
        `operationFactory` - the factory responsible for creating operations
      Returns:
        a Map with partitionId as a key and the outcome of the operation as a value.
      Throws:
        `Exception`

    - #### invokeOnAllPartitionsAsync

          <T> ICompletableFuture<Map<Integer,T>> invokeOnAllPartitionsAsync(String serviceName,
                                                                            OperationFactory operationFactory)

      Invokes a set of operations on selected set of all partitions in an async way.

      If the operations have sync backups, the returned `ICompletableFuture` does not wait for their completion. Instead, the `ICompletableFuture` is completed once the operations are completed on primary replicas of the given `partitions`.

      Type Parameters:
        `T` - type of result of operations returned by `operationFactory`
      Parameters:
        `serviceName` - the name of the service
        `operationFactory` - the factory responsible for creating operations
      Returns:
        a future returning a Map with partitionId as a key and the outcome of the operation as a value.

    - #### invokeOnPartitions

          <T> Map<Integer,T> invokeOnPartitions(String serviceName,
                                                OperationFactory operationFactory,
                                                Collection<Integer> partitions)
                                         throws Exception

      Invokes a set of operations on selected set of partitions.

      This method blocks until all operations complete.

      If the operations have sync backups, this method will not wait for their completion. Instead, it will return once the operations are completed on primary replicas of the given `partitions`.

      Type Parameters:
        `T` - type of result of operations returned by `operationFactory`
      Parameters:
        `serviceName` - the name of the service
        `operationFactory` - the factory responsible for creating operations
        `partitions` - the partitions the operation should be executed on.
      Returns:
        a Map with partitionId as a key and the outcome of the operation as a value.
      Throws:
        `Exception` - if there was an exception while waiting for the results of the partition invocations

    - #### invokeOnPartitionsAsync

          <T> ICompletableFuture<Map<Integer,T>> invokeOnPartitionsAsync(String serviceName,
                                                                         OperationFactory operationFactory,
                                                                         Collection<Integer> partitions)

      Invokes a set of operations on selected set of partitions in an async way.

      If the operations have sync backups, the returned `ICompletableFuture` does not wait for their completion. Instead, the `ICompletableFuture` is completed once the operations are completed on primary replicas of the given `partitions`.

      Type Parameters:
        `T` - type of result of operations returned by `operationFactory`
      Parameters:
        `serviceName` - the name of the service
        `operationFactory` - the factory responsible for creating operations
        `partitions` - the partitions the operation should be executed on.
      Returns:
        a future returning a Map with partitionId as a key and the outcome of the operation as a value.

    - #### invokeOnPartitions

          Map<Integer,Object> invokeOnPartitions(String serviceName,
                                                 OperationFactory operationFactory,
                                                 int[] partitions)
                                          throws Exception

      Invokes a set of operations on selected set of partitions.

      This method blocks until all operations complete.

      If the operations have sync backups, this method will not wait for their completion. Instead, it will return once the operations are completed on primary replicas of the given `partitions`.

      Parameters:
        `serviceName` - the name of the service
        `operationFactory` - the factory responsible for creating operations
        `partitions` - the partitions the operation should be executed on.
      Returns:
        a Map with partitionId as a key and the outcome of the operation as a value.
      Throws:
        `Exception`

    - #### send

          boolean send(Operation op,
                       Address target)

      Executes an operation remotely.

      It isn't allowed
      Parameters:
        `op` - the operation to send and execute.
        `target` - the address of that target member.
      Returns:
        true if send is successful, false otherwise.

Copyright © 2019. All rights reserved.