public class CachePersistenceHelper extends Object
| Modifier and Type | Class and Description | 
|---|---|
static interface  | 
CachePersistenceHelper.Visitor
The Visitor interface allows the "iteration" of the persisted contents (and metadata) of a cache service in the style of the Visitor Pattern. 
 | 
| Modifier and Type | Field and Description | 
|---|---|
static String | 
DEFAULT_ACTIVE_DIR
Default active directory name. 
 | 
static String | 
DEFAULT_BASE_DIR
Default base persistence directory name. 
 | 
static String | 
DEFAULT_BASE_DIR_PROPERTY
Default persistence directory system property. 
 | 
static String | 
DEFAULT_LOCK_DIR
Default lock directory name. 
 | 
static String | 
DEFAULT_SNAPSHOT_DIR
Default snapshot directory name. 
 | 
static String | 
DEFAULT_TRASH_DIR
Default trash directory name. 
 | 
static long | 
META_EXTENT
The extent-id used to store cache metadata. 
 | 
static String | 
META_FILENAME
Persistence metadata filename. 
 | 
static String | 
META_IMPL_VERSION
Persistence metadata property: implementation version. 
 | 
static String | 
META_PARTITION_COUNT
Persistence metadata property: partition count. 
 | 
static String | 
META_SERVICE_VERSION
Persistence metadata property: service version. 
 | 
static String | 
META_STORAGE_FORMAT
Persistence metadata property: storage format. 
 | 
static String | 
META_STORAGE_VERSION
Persistence metadata property: storage version. 
 | 
static int | 
PERSISTENCE_VERSION
Persistence protocol version. 
 | 
static int | 
RESERVED_META_EXTENTS
Reserve a certain number of extents identifiers for holding metadata. 
 | 
| Constructor and Description | 
|---|
CachePersistenceHelper()  | 
| Modifier and Type | Method and Description | 
|---|---|
static void | 
copyMetadata(File fileDirFrom, File fileDirTo)
Copy the metadata file from one directory to another. 
 | 
protected static ReadBuffer | 
createIndexRegistrationKey(long lCacheId, Binary binExtractor)
Create a key representing an index registration. 
 | 
protected static ReadBuffer | 
createListenerRegistrationKey(long lMemberId, long lCacheId, Binary binKey)
Create a key representing a cache listener registration. 
 | 
protected static ReadBuffer | 
createLockRegistrationKey(long lHolderId, long lHolderThreadId, long lCacheId, Binary binKey)
Create a key representing a cache entry lock. 
 | 
protected static ReadBuffer | 
createTriggerRegistrationKey(long lCacheId, Binary binTrigger)
Create a key representing an trigger registration. 
 | 
static void | 
deleteExtents(com.oracle.datagrid.persistence.PersistentStore store, long lExtentId)
Delete the provided extent from the specified  
store and all associated extents (meta extents). | 
static com.oracle.datagrid.persistence.PersistenceException | 
ensurePersistenceException(Throwable eCause)
Return a PersistenceException with the given cause. 
 | 
static com.oracle.datagrid.persistence.PersistenceException | 
ensurePersistenceException(Throwable eCause, String sMessage)
Return a PersistenceException with the given cause and detail message. 
 | 
static com.oracle.datagrid.persistence.PersistenceTools | 
getArchiverPersistenceTools(ExtensibleConfigurableCacheFactory eccf, String sSnapshotName, String sServiceName)
Return an implementation specific instance of PersistenceTools for the given archived snapshot. 
 | 
static LongArray<String> | 
getCacheNames(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
Return the cache names that have been  
stored in the specified store. | 
protected static String | 
getClusterName()
Return the cluster name without starting the cluster service. 
 | 
static PersistenceEnvironmentInfo | 
getEnvironmentInfo(ExtensibleConfigurableCacheFactory eccf, String sServiceName)
Return the  
PersistenceEnvironmentInfo for a given cluster and service name using the current ConfigurableCacheFactory without starting the services. | 
static PartitionSet | 
getGlobalPartitions(PartitionedService service)
Return a PartitionSet that contains partitions to be used to persist (meta-)data that is logically "global". 
 | 
protected static long | 
getIndexExtentId(long lCacheId)
Return the extent identifier that contains index registration information for the cache with the given identifier. 
 | 
protected static long | 
getListenerExtentId(long lCacheId)
Return the extent identifier that contains listener registration information for the cache with the given identifier. 
 | 
protected static long | 
getLockExtentId(long lCacheId)
Return the extent identifier that contains lock registration information for the cache with the given identifier. 
 | 
static String | 
getMBeanName(String sService)
Obtain the PersistenceManagerMBean name for a given service. 
 | 
static int | 
getPartitionCount(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
Return the partition count that has been stored in the specified store. 
 | 
static int | 
getPersistenceVersion(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
Return the persistence version the provided store was written with. 
 | 
static String | 
getServiceVersion(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
Deprecated. 
 
use  
getPersistenceVersion(PersistentStore) instead | 
static com.oracle.datagrid.persistence.PersistenceTools | 
getSnapshotPersistenceTools(File dirSnapshot)
Return an implementation specific instance of  
PersistenceTools for the given local snapshot directory. | 
protected static long | 
getTriggerExtentId(long lCacheId)
Return the extent identifier that contains trigger registration information for the cache with the given identifier. 
 | 
static com.oracle.datagrid.persistence.PersistentStore.Visitor<ReadBuffer> | 
instantiatePersistenceVisitor(CachePersistenceHelper.Visitor visitorCache)
Instantiate a  
visitor for the PersistentStore backed by the | 
static boolean | 
isGlobalPartitioningSchemePID(int nPartition)
Return true iff the specified partition-id is to be used to persist (meta-)data that is logically "global". 
 | 
static boolean | 
isMetadataCompatible(Properties prop, int nImplVersion, String sStorageFormat, int nStorageVersion)
Determine if the given metadata in the  
Properties is compatible with the metadata supplied. | 
static boolean | 
isMetadataComplete(Properties prop)
Determine if the given metadata in the  
Properties is complete. | 
static boolean | 
isSealed(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
Return true if the specified store has been sealed. 
 | 
static void | 
moveExtents(com.oracle.datagrid.persistence.PersistentStore store, long lOldExtentId, long lNewExtentId)
Move the old extent to the new extent in the specified  
store including all associated extents (meta extents). | 
static Properties | 
readMetadata(File fileDir)
Read persistence metadata from the specified directory. 
 | 
static com.tangosol.net.internal.QuorumInfo | 
readQuorum(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
Read the membership information from the "META" extent. 
 | 
static Binary | 
readQuorumRaw(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
Read the membership information in Binary format from the "META" extent. 
 | 
static void | 
registerIndex(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binExtractor, Binary binComparator, Object oToken)
Store the index registration in the specified persistent store. 
 | 
static void | 
registerListener(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lListenerId, boolean fLite, Object oToken)
Store the listener registration in the specified persistent store. 
 | 
static void | 
registerLock(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lHolderId, long lHolderThreadId, Object oToken)
Store the cache entry lock in the specified persistent store. 
 | 
static void | 
registerTrigger(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binTrigger, Object oToken)
Store the trigger registration in the specified persistent store. 
 | 
static void | 
resumeService(Cluster cluster, String sServiceName)
Resume a service on a separate thread and wait for the resume to complete. 
 | 
static void | 
seal(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, PartitionedService service, Object oToken)
Seal the specified PersistentStore on behalf of the specified service, indicating that it is fully initialized and eligible to be recovered from this point forward. 
 | 
static void | 
storeCacheNames(com.oracle.datagrid.persistence.PersistentStore store, LongArray laCaches, Object oToken)
Persist the specified cache names in the persistent store. 
 | 
static void | 
unregisterIndex(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binExtractor, Object oToken)
Clear the index registration from the specified persistent store. 
 | 
static void | 
unregisterIndices(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId)
Clear all index registrations for the specified cache from the specified persistent store. 
 | 
static void | 
unregisterListener(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lListenerId, Object oToken)
Clear the listener registration from the specified persistent store. 
 | 
static void | 
unregisterListeners(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId)
Clear all listener registrations for the specified cache from the specified persistent store. 
 | 
static void | 
unregisterLock(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lHolderId, long lHolderThreadId, Object oToken)
Clear the cache entry lock from the specified persistent store. 
 | 
static void | 
unregisterLocks(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId)
Clear all cache entry locks for the specified cache from the specified persistent store. 
 | 
static void | 
unregisterTrigger(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binTrigger, Object oToken)
Clear the trigger registration from the specified persistent store. 
 | 
static void | 
unregisterTriggers(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId)
Clear all trigger registrations for the specified cache from the specified persistent store. 
 | 
static void | 
unseal(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
Remove a seal from a PersistentStore. 
 | 
static void | 
validate(com.oracle.datagrid.persistence.PersistentStore store, PartitionedService service)
Validate the specified store to check that it has been sealed, indicating that it is eligible to be recovered by the specified service. 
 | 
static void | 
writeMetadata(File fileDir, Properties prop)
Write persistence metadata to the specified directory. 
 | 
static Binary | 
writeQuorum(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, PartitionedService service)
Write the current membership information to the "META" extent. 
 | 
static void | 
writeQuorumRaw(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, Binary binInfo)
Write the current membership information in raw format to the "META" extent. 
 | 
public static final String DEFAULT_BASE_DIR_PROPERTY
public static final String META_FILENAME
public static final String META_IMPL_VERSION
public static final String META_STORAGE_FORMAT
public static final String META_STORAGE_VERSION
public static final String META_PARTITION_COUNT
public static final String META_SERVICE_VERSION
public static final int PERSISTENCE_VERSION
public static final String DEFAULT_BASE_DIR
public static final String DEFAULT_ACTIVE_DIR
public static final String DEFAULT_SNAPSHOT_DIR
public static final String DEFAULT_TRASH_DIR
public static final String DEFAULT_LOCK_DIR
public static final long META_EXTENT
public static final int RESERVED_META_EXTENTS
public static com.oracle.datagrid.persistence.PersistenceException ensurePersistenceException(Throwable eCause)
eCause - an optional causepublic static com.oracle.datagrid.persistence.PersistenceException ensurePersistenceException(Throwable eCause, String sMessage)
eCause - an optional causesMessage - an optional detail messagepublic static void seal(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, PartitionedService service, Object oToken)
store - the persistent store to sealservice - the partitioned serviceoToken - batch token to use for the seal operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unseal(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
store - the {@link PersistentStore store) the seal should be removed frompublic static boolean isSealed(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
store - the persistent store to checkpublic static void writeQuorumRaw(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, Binary binInfo)
store - the store to write intobinInfo - the Binary object to write to the "META" extentpublic static Binary writeQuorum(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, PartitionedService service)
seals the store.store - the store to write intoservice - the service for which the information is storedpublic static Binary readQuorumRaw(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
store - the store to read frompublic static com.tangosol.net.internal.QuorumInfo readQuorum(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
store - the store to read from
public static void validate(com.oracle.datagrid.persistence.PersistentStore store,
                            PartitionedService service)
Successful validation is determined by this method not appending to the provided StringBuilder. Failure to validate the store results in a description of the validation being appended to the provided StringBuilder.
store - the persistent store to validateservice - the partitioned servicecom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations fail
public static void storeCacheNames(com.oracle.datagrid.persistence.PersistentStore store,
                                   LongArray laCaches,
                                   Object oToken)
store - the persistent store to store the cache names tolaCaches - the LongArray of cache names, indexed by cache-idoToken - batch token to use for the seal operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static LongArray<String> getCacheNames(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
stored in the specified store.store - the persistent store to load the cache names fromcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static int getPartitionCount(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
store - the persistent store to load the partition count from@Deprecated public static String getServiceVersion(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
getPersistenceVersion(PersistentStore) insteadstore - the persistent store to load the service version frompublic static int getPersistenceVersion(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store)
store - the persistent store to load the persistence version from0 if the specified store does not contain a persistence versionpublic static boolean isGlobalPartitioningSchemePID(int nPartition)
In an ideal implementation, these (meta)-data would belong to a separate partitioning-scheme of a single partition (and many replicas), however today we "fake it" by artificially assigning them to a single well-known partition.
nPartition - the partition-idpublic static PartitionSet getGlobalPartitions(PartitionedService service)
service - the service for which the global partitions are requestedglobal partition ids
public static void deleteExtents(com.oracle.datagrid.persistence.PersistentStore store,
                                 long lExtentId)
store and all associated extents (meta extents).
public static void moveExtents(com.oracle.datagrid.persistence.PersistentStore store,
                               long lOldExtentId,
                               long lNewExtentId)
store including all associated extents (meta extents).public static Properties readMetadata(File fileDir) throws IOException
fileDir - the directory to read metadata fromIOException - on error reading the metadata filepublic static void writeMetadata(File fileDir, Properties prop) throws IOException
fileDir - the directory to write metadata toprop - the metadata to writeIOException - on error writing the metadata filepublic static void copyMetadata(File fileDirFrom, File fileDirTo) throws IOException
fileDirFrom - the directory to copy fromfileDirTo - the directory to copy toIOException - on copying the metadatapublic static boolean isMetadataComplete(Properties prop)
Properties is complete.prop - the metadata to analyzepublic static boolean isMetadataCompatible(Properties prop, int nImplVersion, String sStorageFormat, int nStorageVersion)
Properties is compatible with the metadata supplied.prop - the metadata to analyzenImplVersion - the impl version to comparesStorageFormat - the storage format to comparenStorageVersion - the storage version to compareprotected static long getListenerExtentId(long lCacheId)
lCacheId - the cacheIdprotected static ReadBuffer createListenerRegistrationKey(long lMemberId, long lCacheId, Binary binKey)
lMemberId - the unique service-identifier of the listening memberlCacheId - the cache-idbinKey - the key to listen topublic static void registerListener(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lListenerId, boolean fLite, Object oToken)
store - the PersistentStore to store the listener registrationlCacheId - the cache-idbinKey - the key to listen onlListenerId - the unique service-identifier of the listening memberfLite - true iff the listener expects "lite" eventsoToken - batch token to use for the store operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unregisterListener(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lListenerId, Object oToken)
store - the persistent storelCacheId - the cache-idbinKey - the keylListenerId - the unique service-identifier of the listening memberoToken - batch token to use for the store operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unregisterListeners(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId)
store - the persistent storelCacheId - the cache-idcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failprotected static long getLockExtentId(long lCacheId)
lCacheId - the cacheIdprotected static ReadBuffer createLockRegistrationKey(long lHolderId, long lHolderThreadId, long lCacheId, Binary binKey)
lHolderId - the unique service-identifier of the listening memberlHolderThreadId - the thread-id of the lock holderlCacheId - the cache-idbinKey - the locked keypublic static void registerLock(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lHolderId, long lHolderThreadId, Object oToken)
store - the PersistentStore to store the locklCacheId - the cache-idbinKey - the locked keylHolderId - the unique service-identifier of the lock holderlHolderThreadId - the thread-id of the lock holderoToken - batch token to use for the store operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unregisterLock(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lHolderId, long lHolderThreadId, Object oToken)
store - the persistent storelCacheId - the cache-idbinKey - the keylHolderId - the unique service-identifier of the lock holderlHolderThreadId - the thread-id of the lock holderoToken - batch token to use for the store operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unregisterLocks(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId)
store - the persistent storelCacheId - the cache-idcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failprotected static long getIndexExtentId(long lCacheId)
lCacheId - the cacheIdprotected static ReadBuffer createIndexRegistrationKey(long lCacheId, Binary binExtractor)
lCacheId - the cache-idbinExtractor - the index extractorpublic static void registerIndex(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binExtractor, Binary binComparator, Object oToken)
store - the persistent storelCacheId - the cache idbinExtractor - the index extractorbinComparator - the index comparatoroToken - batch token to use for the store operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unregisterIndex(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binExtractor, Object oToken)
store - the persistent storelCacheId - the cache idbinExtractor - the index extractoroToken - batch token to use for the store operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unregisterIndices(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId)
store - the persistent storelCacheId - the cache-idcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failprotected static long getTriggerExtentId(long lCacheId)
lCacheId - the cacheIdprotected static ReadBuffer createTriggerRegistrationKey(long lCacheId, Binary binTrigger)
lCacheId - the cache-idbinTrigger - the triggerpublic static void registerTrigger(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binTrigger, Object oToken)
store - the persistent storelCacheId - the cache idbinTrigger - the triggeroToken - batch token to use for the store operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unregisterTrigger(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binTrigger, Object oToken)
store - the persistent storelCacheId - the cache idbinTrigger - the triggeroToken - batch token to use for the store operation, or nullcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void unregisterTriggers(com.oracle.datagrid.persistence.PersistentStore<ReadBuffer> store, long lCacheId)
store - the persistent storelCacheId - the cache-idcom.oracle.datagrid.persistence.PersistenceException - if the persistent store operations failpublic static void resumeService(Cluster cluster, String sServiceName)
cluster - the cluster to resume service forsServiceName - the service to resumepublic static com.oracle.datagrid.persistence.PersistenceTools getSnapshotPersistenceTools(File dirSnapshot)
PersistenceTools for the given local snapshot directory.dirSnapshot - the snapshot directory to get tools forcom.oracle.datagrid.persistence.PersistenceException - if any errorspublic static com.oracle.datagrid.persistence.PersistenceTools getArchiverPersistenceTools(ExtensibleConfigurableCacheFactory eccf, String sSnapshotName, String sServiceName)
eccf - ExtensibleConfigurableCacheFactory to usesSnapshotName - the snapshot to get toolssServiceName - the service name to get toolscom.oracle.datagrid.persistence.PersistenceException - if any errorspublic static PersistenceEnvironmentInfo getEnvironmentInfo(ExtensibleConfigurableCacheFactory eccf, String sServiceName)
PersistenceEnvironmentInfo for a given cluster and service name using the current ConfigurableCacheFactory without starting the services.eccf - ExtensibleConfigurableCacheFactory to usesServiceName - the service name to useprotected static String getClusterName()
public static com.oracle.datagrid.persistence.PersistentStore.Visitor<ReadBuffer> instantiatePersistenceVisitor(CachePersistenceHelper.Visitor visitorCache)
visitor for the PersistentStore backed by thevisitorCache - the cache visitor to delegate to