com.hazelcast.spi
Class InvocationBuilder

java.lang.Object
  extended by com.hazelcast.spi.InvocationBuilder
Direct Known Subclasses:
InvocationBuilderImpl

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
protected  Callback<Object> callback
           
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  ExecutionCallback<Object> executionCallback
           
protected  NodeEngineImpl nodeEngine
           
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
InvocationBuilder(NodeEngineImpl nodeEngine, String serviceName, Operation op, int partitionId, Address target)
          Creates an InvocationBuilder
 
Method Summary
 Callback getCallback()
          Deprecated. 
 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.
 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 setCallback(Callback<Object> callback)
          Deprecated. 
 InvocationBuilder setCallTimeout(long callTimeout)
           
 InvocationBuilder setExecutionCallback(ExecutionCallback<Object> executionCallback)
          Sets the ExecutionCallback.
 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.
 
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

nodeEngine

protected final NodeEngineImpl nodeEngine

serviceName

protected final String serviceName

op

protected final Operation op

partitionId

protected final int partitionId

target

protected final Address target

callback

protected Callback<Object> callback

executionCallback

protected ExecutionCallback<Object> executionCallback

callTimeout

protected long callTimeout

replicaIndex

protected int replicaIndex

tryCount

protected int tryCount

tryPauseMillis

protected long tryPauseMillis

resultDeserialized

protected boolean resultDeserialized
Constructor Detail

InvocationBuilder

public InvocationBuilder(NodeEngineImpl nodeEngine,
                         String serviceName,
                         Operation op,
                         int partitionId,
                         Address target)
Creates an InvocationBuilder

Parameters:
nodeEngine - the nodeEngine
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

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()

getCallback

@Deprecated
public Callback getCallback()
Deprecated. 

This method is deprecated since HZ 3.5. Please use the getExecutionCallback()


setCallback

@Deprecated
public InvocationBuilder setCallback(Callback<Object> callback)
Deprecated. 

This method is deprecated since HZ 3.5. Please use the setExecutionCallback(ExecutionCallback)


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.
Throws:
IllegalStateException - if a Callback already has been set.

invoke

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


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.