com.hazelcast.spi
Class InvocationBuilder

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

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
          If 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 millis.
protected  String executorName
           
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()
           
 long getCallTimeout()
           
 String getExecutorName()
          Gets the name of the Executor to use.
 Operation getOp()
           
 int getPartitionId()
           
 int getReplicaIndex()
           
 String getServiceName()
           
 Address getTarget()
           
 int getTryCount()
           
 long getTryPauseMillis()
           
abstract  InternalCompletableFuture invoke()
           
 boolean isResultDeserialized()
          Checks if the Future should automatically deserialize the result.
 InvocationBuilder setCallback(Callback<Object> callback)
           
 InvocationBuilder setCallTimeout(long callTimeout)
           
 InvocationBuilder setExecutorName(String executorName)
          Sets the executor name.
 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 millis.
 
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 millis. So 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
If 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

callTimeout

protected long callTimeout

replicaIndex

protected int replicaIndex

tryCount

protected int tryCount

tryPauseMillis

protected long tryPauseMillis

executorName

protected String executorName

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 to execute the operation on
target - the target machine. Either the partitionId or the target needs to be set.
Method Detail

getExecutorName

public String getExecutorName()
Gets the name of the Executor to use. This functionality is useful if you want to customize which executor is going to run an operation. By default you don't need to configure anything, but in some case, for example map reduce logic, where you don't want to hog the partition threads, you could offload to another executor.

Returns:
the name of the executor. Returns null if no explicit executor has been configured.

setExecutorName

public InvocationBuilder setExecutorName(String executorName)
Sets the executor name. Value can be null, meaning that no custom executor will be used.

Parameters:
executorName - the name of the executor.
Returns:
the InvocationBuilder

setReplicaIndex

public InvocationBuilder setReplicaIndex(int replicaIndex)
Sets the replicaIndex

Parameters:
replicaIndex -
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 get 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.
Returns:
the InvocationBuilder

setTryPauseMillis

public InvocationBuilder setTryPauseMillis(long tryPauseMillis)
Sets the pause time in millis.

Parameters:
tryPauseMillis - the pause time in millis.
Returns:
the InvocationBuilder

setCallTimeout

public InvocationBuilder setCallTimeout(long callTimeout)

getServiceName

public String getServiceName()

getOp

public Operation getOp()

getReplicaIndex

public int getReplicaIndex()

getTryCount

public int getTryCount()

getTryPauseMillis

public long getTryPauseMillis()

getTarget

public Address getTarget()

getPartitionId

public int getPartitionId()

getCallTimeout

public long getCallTimeout()

getCallback

public Callback getCallback()

setCallback

public InvocationBuilder setCallback(Callback<Object> callback)

invoke

public abstract InternalCompletableFuture invoke()


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