IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

com.ibm.websphere.objectgrid
Class CopyMode

java.lang.Object
  extended by com.ibm.websphere.objectgrid.CopyMode

public final class CopyMode
extends Object

This class is used to define the "copy" mode when the setCopyMode method of the BackingMap interface is used. The application is expected to pass one of the final static variables that are defined in this class to the setCopyMode method.

Since:
WAS XD 6.0, XC10
See Also:
BackingMap.setCopyMode(CopyMode, Class), ObjectTransformer.copyValue(Object)

Field Summary
static CopyMode COPY_ON_READ
          The COPY_ON_READ mode improves performance over the COPY_ON_READ_AND_COMMIT mode by eliminating the copy that occurs when a transaction is committed.
static CopyMode COPY_ON_READ_AND_COMMIT
          The COPY_ON_READ_AND_COMMIT mode is the default mode.
static CopyMode COPY_ON_WRITE
          The COPY_ON_WRITE mode improves performance over the COPY_ON_READ_AND_COMMIT mode by eliminating the copy that occurs when ObjectMap.get is called for the first time by a transaction for a given key.
static CopyMode COPY_TO_BYTES
          The COPY_TO_BYTES mode is similar to the COPY_ON_READ_AND_COMMIT mode in that it ensures that an application never has a reference to the value object that is in the BackingMap.
static CopyMode COPY_TO_BYTES_RAW
          When set, all ObjectMap APIs that return a SerializedValue rather than the original Java Object, allowing access to the serialized form of the data, preventing inflation of object into Java Object form.
static CopyMode NO_COPY
          The NO_COPY mode allows an application to promise that it will never modify a value object obtained using an ObjectMap.get method in exchange for performance improvements.
 
Method Summary
 boolean isBytes()
          Is the copy mode one of the copy modes that indicate copy to bytes?
 String toString()
          Returns a string representation of the CopyMode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COPY_ON_READ_AND_COMMIT

public static final CopyMode COPY_ON_READ_AND_COMMIT
The COPY_ON_READ_AND_COMMIT mode is the default mode. This mode ensures that an application never has a reference to the value object that is in the BackingMap, and instead the application is always working with a copy of the value that is in the BackingMap. The copy ensures the application can never inadvertently corrupt the data that is cached in the BackingMap. When an application transaction calls an ObjectMap.get method for a given key, and it is the first access of the ObjectMap entry for that key, a copy of the value is returned. When the transaction is committed, any changes the application committed are copied to the BackingMap to ensure that the application does not have reference to the committed value in the BackingMap.


COPY_ON_READ

public static final CopyMode COPY_ON_READ
The COPY_ON_READ mode improves performance over the COPY_ON_READ_AND_COMMIT mode by eliminating the copy that occurs when a transaction is committed. To preserve integrity of BackingMap data, the application promises to destroy every reference it has to an entry once the transaction is committed. This mode results in a ObjectMap.get method returning a copy of the value rather than a reference to the value to ensure that changes made by the application to the value does not affect the BackingMap value until the transaction is committed. However, when the transaction does commit, a copy of changes is not made. Instead, the reference to the copy that was returned by ObjectMap.get is stored in the BackingMap. This is the reason the application must agree to destroy all map entry references once the transaction is committed. If application fails to keep its promise, the application could cause the data cached in BackingMap to become corrupted. If an application is using this mode and it is having problems, then switch to the COPY_ON_READ_AND_COMMIT mode to see if the problem still exists. If the problem goes away, then more than likely the application is failing to destroy all of its references after the transaction has committed.


COPY_ON_WRITE

public static final CopyMode COPY_ON_WRITE
The COPY_ON_WRITE mode improves performance over the COPY_ON_READ_AND_COMMIT mode by eliminating the copy that occurs when ObjectMap.get is called for the first time by a transaction for a given key. Instead, the ObjectMap.get method returns a proxy to the value rather than a direct reference to the value object itself. The proxy ensures that a copy of the value is not made unless the application calls a set method on the value interface that is passed on the BackingMap.setCopyMode(CopyMode, Class) method. Thus, the proxy provides a "copy on write" implementation. When a transaction commits, the BackingMap examines the proxy to determine if any copy was made as a result of a set method being called. If a copy was made, then the reference to that copy is stored in the BackingMap. The big advantage of this mode is a value is never copied on read or at commit when the transaction never calls a set method to mutate the value.

See Also:
BackingMap.setCopyMode(CopyMode, Class)

NO_COPY

public static final CopyMode NO_COPY
The NO_COPY mode allows an application to promise that it will never modify a value object obtained using an ObjectMap.get method in exchange for performance improvements. If this mode is used, no copy of the value is ever made. If the application breaks its promise and does modify values, then data in the BackingMap will be corrupted. This mode is primarily useful for read only maps where data is never modified by the application. If the application is using this mode and it is having problems, then switch to COPY_ON_READ_AND_COMMIT mode to see if the problem still exists. If the problem goes away, then more than likely the application is not keeping its promise and is modifying the value returned by ObjectMap.get method (either during transaction or after transaction has committed).


COPY_TO_BYTES

public static final CopyMode COPY_TO_BYTES
The COPY_TO_BYTES mode is similar to the COPY_ON_READ_AND_COMMIT mode in that it ensures that an application never has a reference to the value object that is in the BackingMap. The value that the application works with is a newly inflated version of the serialized version that is in the BackingMap. The copy ensures the application can never inadvertently corrupt the data that is cached in the BackingMap since a byte form of the value is what is stored in the BackingMap instead of the Object form.

A copy of the value is returned when an application transaction calls an ObjectMap.get method for a given key, and it is the first time that the ObjectMap entry is accessed for that key. When the transaction is committed, any changes the application committed are copied to bytes in the BackingMap to ensure that the application does not have reference to the committed value in the BackingMap.

Since:
7.0

COPY_TO_BYTES_RAW

public static final CopyMode COPY_TO_BYTES_RAW
When set, all ObjectMap APIs that return a SerializedValue rather than the original Java Object, allowing access to the serialized form of the data, preventing inflation of object into Java Object form.

Since:
7.1.1
See Also:
ValueDataSerializer
Method Detail

toString

public String toString()
Returns a string representation of the CopyMode.

Overrides:
toString in class Object
Returns:
a string representation of the CopyMode.

isBytes

public boolean isBytes()
Is the copy mode one of the copy modes that indicate copy to bytes?

Returns:
boolean indicating if copy mode is one of COPY_TO_BYTES or COPY_TO_BYTES_RAW.

IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

© Copyright International Business Machines Corp 2005,2012. All rights reserved.