ehcache

net.sf.ehcache.writer.writebehind.operations
Class WriteOperation

java.lang.Object
  extended by net.sf.ehcache.writer.writebehind.operations.WriteOperation
All Implemented Interfaces:
KeyBasedOperation, SingleOperation

public class WriteOperation
extends Object
implements SingleOperation

Implements the write operation for write behind

Version:
$Id: WriteOperation.java 10029 2015-10-07 18:57:27Z cdennis $
Author:
Geert Bevin

Constructor Summary
WriteOperation(Element element)
          Create a new write operation for a particular element
WriteOperation(Element element, long creationTime)
          Create a new write operation for a particular element and creation time
 
Method Summary
 BatchOperation createBatchOperation(List<? extends SingleOperation> operations)
          Creates a batch operation that corresponds to the operation type of this single operation.
 boolean equals(Object other)
          
 long getCreationTime()
          Retrieves the moment when the operation was created.
 Element getElement()
          Retrieves the element that will be used for this operation
 Object getKey()
          Retrieves the element key for this operation.
 SingleOperationType getType()
          Returns a stable identifier for the type this operation can be classified in.
 int hashCode()
          
 void performSingleOperation(CacheWriter cacheWriter)
          Perform this operation as a single execution with the provided cache writer
 void throwAway(CacheWriter cacheWriter, RuntimeException e)
          Called when all retries have failed
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteOperation

public WriteOperation(Element element)
Create a new write operation for a particular element

Parameters:
element - the element to write

WriteOperation

public WriteOperation(Element element,
                      long creationTime)
Create a new write operation for a particular element and creation time

Parameters:
element - the element to write
creationTime - the creation time of the operation
Method Detail

performSingleOperation

public void performSingleOperation(CacheWriter cacheWriter)
Perform this operation as a single execution with the provided cache writer

Specified by:
performSingleOperation in interface SingleOperation
Parameters:
cacheWriter - the cache writer this operation should be performed upon

createBatchOperation

public BatchOperation createBatchOperation(List<? extends SingleOperation> operations)
Creates a batch operation that corresponds to the operation type of this single operation.

This batch operation will not be stored in the queue anymore and is solely used for structuring. The data from the single operation will already be processed in the final form that will be expected by the CacheWriter that will be used to execute the batch operation.

Specified by:
createBatchOperation in interface SingleOperation
Parameters:
operations - the single operations that need to be regrouped in the batch operation
Returns:
the created batch operation

getKey

public Object getKey()
Retrieves the element key for this operation.

Specified by:
getKey in interface KeyBasedOperation
Returns:
the key of the element that is concerned by the operation.

getCreationTime

public long getCreationTime()
Retrieves the moment when the operation was created.

Specified by:
getCreationTime in interface KeyBasedOperation
Returns:
the creation time in milliseconds

getElement

public Element getElement()
Retrieves the element that will be used for this operation


getType

public SingleOperationType getType()
Returns a stable identifier for the type this operation can be classified in. This is used to group and order batched operations.

Specified by:
getType in interface SingleOperation
Returns:
the identifier for this operation type

throwAway

public void throwAway(CacheWriter cacheWriter,
                      RuntimeException e)
Called when all retries have failed

Specified by:
throwAway in interface SingleOperation
Parameters:
cacheWriter - the CacheWriter to delegate to
e - the last exception encountered

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object other)

Overrides:
equals in class Object

ehcache

Copyright 2001-2017, Terracotta, Inc.