com.hazelcast.cache.impl.operation
Class CachePutIfAbsentOperation

java.lang.Object
  extended by com.hazelcast.spi.Operation
      extended by com.hazelcast.spi.AbstractOperation
          extended by com.hazelcast.spi.impl.AbstractNamedOperation
              extended by com.hazelcast.cache.impl.operation.AbstractMutatingCacheOperation
                  extended by com.hazelcast.cache.impl.operation.CachePutIfAbsentOperation
All Implemented Interfaces:
MutableOperation, DataSerializable, IdentifiedDataSerializable, BackupAwareOperation, RemotePropagatable<Operation>, PartitionAwareOperation

public class CachePutIfAbsentOperation
extends AbstractMutatingCacheOperation

Operation implementation for calling ICacheRecordStore.putIfAbsent(Data, Object, ExpiryPolicy, String, int).

See Also:
ICacheRecordStore.putIfAbsent(Data, Object, ExpiryPolicy, String, int)

Field Summary
protected  CacheRecord backupRecord
           
protected  ICacheRecordStore cache
           
protected  Data key
           
protected  Object response
           
 
Fields inherited from class com.hazelcast.cache.impl.operation.AbstractMutatingCacheOperation
completionId
 
Fields inherited from class com.hazelcast.spi.impl.AbstractNamedOperation
name
 
Fields inherited from interface com.hazelcast.cache.impl.operation.MutableOperation
IGNORE_COMPLETION
 
Constructor Summary
CachePutIfAbsentOperation()
           
CachePutIfAbsentOperation(String name, Data key, Data value, javax.cache.expiry.ExpiryPolicy expiryPolicy, int completionId)
           
 
Method Summary
 void beforeRun()
           
 int getAsyncBackupCount()
           
 Operation getBackupOperation()
          Creates the BackupOperation responsible for making the backup.
 int getFactoryId()
          Returns DataSerializableFactory factory id for this class.
 int getId()
          Returns type identifier for this class.
 Object getResponse()
           
 int getSyncBackupCount()
           
 ExceptionAction onException(Throwable throwable)
           
protected  void readInternal(ObjectDataInput in)
           
 boolean returnsResponse()
           
 void run()
           
 boolean shouldBackup()
          Checks if a backup needs to be made.
protected  void writeInternal(ObjectDataOutput out)
           
 
Methods inherited from class com.hazelcast.cache.impl.operation.AbstractMutatingCacheOperation
getCompletionId, setCompletionId
 
Methods inherited from class com.hazelcast.spi.impl.AbstractNamedOperation
getName
 
Methods inherited from class com.hazelcast.spi.AbstractOperation
afterRun
 
Methods inherited from class com.hazelcast.spi.Operation
getCallerAddress, getCallerUuid, getCallId, getCallTimeout, getConnection, getExecutorName, getInvocationTime, getLogger, getNodeEngine, getPartitionId, getReplicaIndex, getResponseHandler, getService, getServiceName, getWaitTimeout, isUrgent, logError, readData, setCallerUuid, setExecutorName, setNodeEngine, setPartitionId, setReplicaIndex, setResponseHandler, setService, setServiceName, setValidateTarget, setWaitTimeout, toString, validatesTarget, writeData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hazelcast.spi.BackupAwareOperation
getAsyncBackupCount, getSyncBackupCount
 
Methods inherited from interface com.hazelcast.spi.PartitionAwareOperation
getPartitionId
 
Methods inherited from interface com.hazelcast.nio.serialization.DataSerializable
readData, writeData
 

Field Detail

key

protected Data key

response

protected Object response

cache

protected transient ICacheRecordStore cache

backupRecord

protected transient CacheRecord backupRecord
Constructor Detail

CachePutIfAbsentOperation

public CachePutIfAbsentOperation()

CachePutIfAbsentOperation

public CachePutIfAbsentOperation(String name,
                                 Data key,
                                 Data value,
                                 javax.cache.expiry.ExpiryPolicy expiryPolicy,
                                 int completionId)
Method Detail

run

public void run()
         throws Exception
Specified by:
run in class Operation
Throws:
Exception

shouldBackup

public boolean shouldBackup()
Description copied from interface: BackupAwareOperation
Checks if a backup needs to be made.

If a call has not made any change, e.g. an AtomicLong increment with 0, no backup needs to be made.

Returns:
true if a backup needs to be made, false otherwise.

getBackupOperation

public Operation getBackupOperation()
Description copied from interface: BackupAwareOperation
Creates the BackupOperation responsible for making the backup.

Returns:
the created BackupOperation.

writeInternal

protected void writeInternal(ObjectDataOutput out)
                      throws IOException
Overrides:
writeInternal in class AbstractMutatingCacheOperation
Throws:
IOException

readInternal

protected void readInternal(ObjectDataInput in)
                     throws IOException
Overrides:
readInternal in class AbstractMutatingCacheOperation
Throws:
IOException

getId

public int getId()
Description copied from interface: IdentifiedDataSerializable
Returns type identifier for this class. Id should be unique per DataSerializableFactory.

Returns:
type id

beforeRun

public final void beforeRun()
                     throws Exception
Overrides:
beforeRun in class AbstractOperation
Throws:
Exception

returnsResponse

public boolean returnsResponse()
Specified by:
returnsResponse in interface RemotePropagatable<Operation>
Overrides:
returnsResponse in class AbstractOperation

getResponse

public final Object getResponse()
Overrides:
getResponse in class AbstractOperation

onException

public ExceptionAction onException(Throwable throwable)
Overrides:
onException in class Operation

getFactoryId

public int getFactoryId()
Description copied from interface: IdentifiedDataSerializable
Returns DataSerializableFactory factory id for this class.

Specified by:
getFactoryId in interface IdentifiedDataSerializable
Returns:
factory id

getSyncBackupCount

public final int getSyncBackupCount()

getAsyncBackupCount

public final int getAsyncBackupCount()


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