com.hazelcast.spi

## Class InvocationBuilder

- java.lang.Object
- - com.hazelcast.spi.InvocationBuilder

-     public abstract class InvocationBuilder
      extends Object

  The InvocationBuilder is responsible for building an invocation of an operation and invoking it.

  The original design exposed the actual Invocation class, but this will limit flexibility since the whole invocation can't be changed or fully removed easily.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `callTimeout`
    `static long` | `DEFAULT_CALL_TIMEOUT` Default call timeout.
    `static boolean` | `DEFAULT_DESERIALIZE_RESULT` True that the result of an operation automatically should be deserialized to an object.
    `static int` | `DEFAULT_REPLICA_INDEX` Default replica index.
    `static int` | `DEFAULT_TRY_COUNT` Default try count.
    `static long` | `DEFAULT_TRY_PAUSE_MILLIS` Default try pause in milliseconds.
    `protected Runnable` | `doneCallback`
    `protected ExecutionCallback<Object>` | `executionCallback`
    `protected boolean` | `failOnIndeterminateOperationState`
    `protected Operation` | `op`
    `protected int` | `partitionId`
    `protected int` | `replicaIndex`
    `protected boolean` | `resultDeserialized`
    `protected String` | `serviceName`
    `protected Address` | `target`
    `protected int` | `tryCount`
    `protected long` | `tryPauseMillis`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `InvocationBuilder(String serviceName, Operation op, int partitionId, Address target)` Creates an InvocationBuilder

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getCallTimeout()`
    `ExecutionCallback<Object>` | `getExecutionCallback()` Gets the ExecutionCallback.
    `Operation` | `getOp()` Gets the operation to execute.
    `int` | `getPartitionId()` Returns the partition ID.
    `int` | `getReplicaIndex()` Gets the replicaIndex.
    `String` | `getServiceName()` Gets the name of the service.
    `Address` | `getTarget()` Returns the target machine.
    `protected ExecutionCallback` | `getTargetExecutionCallback()`
    `int` | `getTryCount()` Gets the try count; the number of times this operation can be retried.
    `long` | `getTryPauseMillis()` Gets the pause time in milliseconds.
    `abstract <E> InternalCompletableFuture<E>` | `invoke()`
    `boolean` | `isResultDeserialized()` Checks if the Future should automatically deserialize the result.
    `InvocationBuilder` | `setCallTimeout(long callTimeout)`
    `InvocationBuilder` | `setDoneCallback(Runnable doneCallback)` Sets a callback that will respond to the "task done" event for the invocation this builder is about to create.
    `InvocationBuilder` | `setExecutionCallback(ExecutionCallback<Object> executionCallback)` Sets the ExecutionCallback.
    `InvocationBuilder` | `setFailOnIndeterminateOperationState(boolean failOnIndeterminateOperationState)` Enables / disables throwing `IndeterminateOperationStateException` for this invocation.
    `InvocationBuilder` | `setReplicaIndex(int replicaIndex)` Sets the replicaIndex.
    `InvocationBuilder` | `setResultDeserialized(boolean resultDeserialized)` Sets the automatic deserialized option for the result.
    `InvocationBuilder` | `setTryCount(int tryCount)` Sets the try count; the number of times this operation can be retried.
    `InvocationBuilder` | `setTryPauseMillis(long tryPauseMillis)` Sets the pause time in milliseconds.
    `boolean` | `shouldFailOnIndeterminateOperationState()` Returns true if `IndeterminateOperationStateException` is enabled for this invocation

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

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

- - ### Field Detail

    - #### DEFAULT_CALL_TIMEOUT

          public static final long DEFAULT_CALL_TIMEOUT

      Default call timeout.
      See Also:
        Constant Field Values

    - #### DEFAULT_REPLICA_INDEX

          public static final int DEFAULT_REPLICA_INDEX

      Default replica index.
      See Also:
        Constant Field Values

    - #### DEFAULT_TRY_COUNT

          public static final int DEFAULT_TRY_COUNT

      Default try count.
      See Also:
        Constant Field Values

    - #### DEFAULT_TRY_PAUSE_MILLIS

          public static final long DEFAULT_TRY_PAUSE_MILLIS

      Default try pause in milliseconds. If a call is retried, then perhaps a delay is needed.
      See Also:
        Constant Field Values

    - #### DEFAULT_DESERIALIZE_RESULT

          public static final boolean DEFAULT_DESERIALIZE_RESULT

      True that the result of an operation automatically should be deserialized to an object.
      See Also:
        Constant Field Values

    - #### serviceName

          protected final String serviceName

    - #### op

          protected final Operation op

    - #### partitionId

          protected final int partitionId

    - #### target

          protected final Address target

    - #### executionCallback

          protected ExecutionCallback<Object> executionCallback

    - #### doneCallback

          protected Runnable doneCallback

    - #### callTimeout

          protected long callTimeout

    - #### replicaIndex

          protected int replicaIndex

    - #### tryCount

          protected int tryCount

    - #### tryPauseMillis

          protected long tryPauseMillis

    - #### resultDeserialized

          protected boolean resultDeserialized

    - #### failOnIndeterminateOperationState

          protected boolean failOnIndeterminateOperationState

  - ### Constructor Detail

    - #### InvocationBuilder

          protected InvocationBuilder(String serviceName,
                                      Operation op,
                                      int partitionId,
                                      Address target)

      Creates an InvocationBuilder
      Parameters:
        `serviceName` - the name of the service
        `op` - the operation to execute
        `partitionId` - the ID of the partition upon which to execute the operation
        `target` - the target machine. Either the partitionId or the target needs to be set.

  - ### Method Detail

    - #### setReplicaIndex

          public InvocationBuilder setReplicaIndex(int replicaIndex)

      Sets the replicaIndex.
      Parameters:
        `replicaIndex` - the replica index
      Returns:
        the InvocationBuilder
      Throws:
        `IllegalArgumentException` - if replicaIndex smaller than 0 or larger than the max replica count.

    - #### isResultDeserialized

          public boolean isResultDeserialized()

      Checks if the Future should automatically deserialize the result. In most cases, you don't want `Data` to be returned, but the deserialized object. But in some cases, you want to get the raw Data object.

      Defaults to true.
      Returns:
        true if the the result is automatically deserialized, false otherwise.

    - #### setResultDeserialized

          public InvocationBuilder setResultDeserialized(boolean resultDeserialized)

      Sets the automatic deserialized option for the result.
      Parameters:
        `resultDeserialized` - true if data
      Returns:
        the updated InvocationBuilder.
      See Also:
        `isResultDeserialized()`

    - #### setTryCount

          public InvocationBuilder setTryCount(int tryCount)

      Sets the try count; the number of times this operation can be retried.
      Parameters:
        `tryCount` - the try count; the number of times this operation can be retried
      Returns:
        the InvocationBuilder

    - #### shouldFailOnIndeterminateOperationState

          public boolean shouldFailOnIndeterminateOperationState()

      Returns true if `IndeterminateOperationStateException` is enabled for this invocation
      Returns:
        true if `IndeterminateOperationStateException` is enabled for this invocation

    - #### setFailOnIndeterminateOperationState

          public InvocationBuilder setFailOnIndeterminateOperationState(boolean failOnIndeterminateOperationState)

      Enables / disables throwing `IndeterminateOperationStateException` for this invocation. Can be used only for partition invocations
      Returns:
        the InvocationBuilder
      See Also:
        `IndeterminateOperationStateException`

    - #### setTryPauseMillis

          public InvocationBuilder setTryPauseMillis(long tryPauseMillis)

      Sets the pause time in milliseconds.
      Parameters:
        `tryPauseMillis` - the pause time in milliseconds.
      Returns:
        the InvocationBuilder

    - #### setCallTimeout

          public InvocationBuilder setCallTimeout(long callTimeout)

    - #### getServiceName

          public String getServiceName()

      Gets the name of the service.
      Returns:
        the name of the service

    - #### getOp

          public Operation getOp()

      Gets the operation to execute.
      Returns:
        the operation to execute

    - #### getReplicaIndex

          public int getReplicaIndex()

      Gets the replicaIndex.
      Returns:
        the replicaIndex

    - #### getTryCount

          public int getTryCount()

      Gets the try count; the number of times this operation can be retried.
      Returns:
        the try count; the number of times this operation can be retried

    - #### getTryPauseMillis

          public long getTryPauseMillis()

      Gets the pause time in milliseconds.
      Returns:
        the pause time in milliseconds

    - #### getTarget

          public Address getTarget()

      Returns the target machine.
      Returns:
        the target machine.

    - #### getPartitionId

          public int getPartitionId()

      Returns the partition ID.
      Returns:
        the partition ID.

    - #### getCallTimeout

          public long getCallTimeout()

    - #### getExecutionCallback

          public ExecutionCallback<Object> getExecutionCallback()

      Gets the ExecutionCallback. If none is set, null is returned.
      Returns:
        gets the ExecutionCallback.

    - #### setExecutionCallback

          public InvocationBuilder setExecutionCallback(ExecutionCallback<Object> executionCallback)

      Sets the ExecutionCallback.
      Parameters:
        `executionCallback` - the new ExecutionCallback. If null is passed, the ExecutionCallback is unset.
      Returns:
        the updated InvocationBuilder.

    - #### getTargetExecutionCallback

          protected ExecutionCallback getTargetExecutionCallback()

    - #### setDoneCallback

          public InvocationBuilder setDoneCallback(Runnable doneCallback)

      Sets a callback that will respond to the "task done" event for the invocation this builder is about to create. It occurs upon the release of computational and other resources used by the task underlying the invocation. The user loses interest in the computation as soon as the invocation's future is canceled, but our internal concern is keeping track of resource usage. Therefore we need a lifecycle event independent of the regular future completion/cancellation.

    - #### invoke

          public abstract <E> InternalCompletableFuture<E> invoke()

Copyright © 2018. All rights reserved.