Class CachePersistenceHelper
java.lang.Object
com.tangosol.persistence.CachePersistenceHelper
Static helper methods used in the persistence of a partitioned cache.
- Author:
- rhl 2012.08.15
- API Note:
- this helper is intended for internal use only
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe Visitor interface allows the "iteration" of the persisted contents (and metadata) of a cache service in the style of the Visitor Pattern. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault active directory name.static final StringDefault backup directory name.static final StringDefault base persistence directory name.static final StringDefault persistence directory system property.static final StringDefault events directory name.static final StringDefault lock directory name.static final StringDefault snapshot directory name.static final StringDefault trash directory name.static final ReadBufferA constant that suggests to a PersistentStore implementation to load the last entry.static final Converter<Long, ReadBuffer> A converter that converts from a Long to a ReadBuffer.static final Converter<ReadBuffer, Long> A converter that converts from a ReadBuffer to a Long.static final longThe extent-id used to store cache metadata.static final StringPersistence metadata filename.static final StringPersistence metadata property: implementation version.static final StringPersistence metadata property: partition count.static final StringPersistence metadata property: service version.static final StringPersistence metadata property: sparse snapshot marker.static final StringPersistence metadata property: storage format.static final StringPersistence metadata property: storage version.static final intPersistence protocol version.static final intReserve a certain number of extents identifiers for holding metadata. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyMetadata(File fileDirFrom, File fileDirTo) Copy the metadata file from one directory to another.protected static ReadBuffercreateContinuousAggregationRegistrationKey(long lCacheId, int nFormat, Binary binDefinition) Create a continuous aggregation definition registration key.protected static ReadBuffercreateContinuousAggregationStateKey(long lCacheId, int nFormat, int nPartition, long lOwnershipVersion, long lDataVersion, Binary binDefinition) Create a continuous aggregation partition-state checkpoint key.protected static ReadBuffercreateIndexRegistrationKey(long lCacheId, Binary binExtractor) Create a key representing an index registration.protected static ReadBuffercreateListenerRegistrationKey(long lMemberId, long lCacheId, Binary binKey) Create a key representing a cache listener registration.protected static ReadBuffercreateLockRegistrationKey(long lHolderId, long lHolderThreadId, long lCacheId, Binary binKey) Create a key representing a cache entry lock.protected static ReadBuffercreateTriggerRegistrationKey(long lCacheId, Binary binTrigger) Create a key representing an trigger registration.static voiddeleteContinuousAggregationStates(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Delete every continuous aggregation state checkpoint for the specified cache from a mutable persistent store.static voiddeleteExtents(com.oracle.coherence.persistence.PersistentStore store, long lExtentId) Delete the provided extent from the specifiedstoreand all associated extents (meta extents).static com.oracle.coherence.persistence.PersistenceExceptionensurePersistenceException(Throwable eCause) Return a PersistenceException with the given cause.static com.oracle.coherence.persistence.PersistenceExceptionensurePersistenceException(Throwable eCause, String sMessage) Return a PersistenceException with the given cause and detail message.static com.oracle.coherence.persistence.PersistenceToolsgetArchiverPersistenceTools(ExtensibleConfigurableCacheFactory eccf, String sSnapshotName, String sServiceName) Return an implementation specific instance of PersistenceTools for the given archived snapshot.getCacheNamesForActiveRecovery(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Return the cache names in active recovery context.getCacheNamesForSnapshotRecovery(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, boolean fSparseSnapshot) Return the cache names in sparse snapshot recovery context.protected static StringReturn the cluster name without starting the cluster service.protected static longgetContinuousAggregationExtentId(long lCacheId) Return the extent identifier containing continuous aggregation definitions for the specified cache.protected static longgetContinuousAggregationStateExtentId(long lCacheId) Return the extent identifier containing continuous aggregation partition-state checkpoints for the specified cache.static PersistenceEnvironmentInfogetEnvironmentInfo(ExtensibleConfigurableCacheFactory eccf, String sServiceName) Return thePersistenceEnvironmentInfofor a given cluster and service name using the currentConfigurableCacheFactorywithout starting the services.static String[]getFailedSnapshots(com.oracle.coherence.persistence.PersistenceEnvironment env) static PartitionSetgetGlobalPartitions(PartitionedService service) Return a PartitionSet that contains partitions to be used to persist (meta-)data that is logically "global".protected static longgetIndexExtentId(long lCacheId) Return the extent identifier that contains index registration information for the cache with the given identifier.protected static longgetListenerExtentId(long lCacheId) Return the extent identifier that contains listener registration information for the cache with the given identifier.protected static longgetLockExtentId(long lCacheId) Return the extent identifier that contains lock registration information for the cache with the given identifier.static StringgetMBeanName(String sService) Obtain the PersistenceManagerMBean name for a given service.static intgetPartitionCount(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Return the partition count that has been stored in the specified store.static intgetPersistenceVersion(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Return the persistence version the provided store was written with.static StringgetServiceVersion(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Deprecated.static com.oracle.coherence.persistence.PersistenceToolsgetSnapshotPersistenceTools(File dirSnapshot) Return an implementation specific instance ofPersistenceToolsfor the given local snapshot directory.static com.oracle.coherence.persistence.PersistenceToolsgetSnapshotPersistenceTools(File dirSnapshot, boolean validation) Return an implementation specific instance ofPersistenceToolsfor the given local snapshot directory.static StringgetSnapshotRecoveryStatus(com.oracle.coherence.persistence.PersistenceEnvironment env, String sName) Return recovery status for the given snapshot.static StringgetSnapshotStatus(com.oracle.coherence.persistence.PersistenceEnvironment env, String sName) Return snapshot status.protected static longgetTriggerExtentId(long lCacheId) Return the extent identifier that contains trigger registration information for the cache with the given identifier.static com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> instantiateEventsVisitor(long lExtentId, Filter filter, long lVersion, Map<Long, MapEvent> mapEvents, Converter<Long, ReadBuffer> convKeyDown, Converter<ReadBuffer, Long> convKeyUp, Converter<Object, ReadBuffer> convDown, Converter<ReadBuffer, Object> convUp) Create aPersistentStore.Visitorthat can read a PersistentStore and populate the providedmapEventswith events that are larger than the provided version (inclusive) and match the givenFilter.static com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> instantiateEventsVisitor(long lExtentId, Set setKeys, long lVersion, Map<Long, MapEvent> mapEvents, Converter<Long, ReadBuffer> convKeyDown, Converter<ReadBuffer, Long> convKeyUp, Converter<Object, ReadBuffer> convDown, Converter<ReadBuffer, Object> convUp) Create aPersistentStore.Visitorthat can read a PersistentStore and populate the providedmapEventswith events that are larger than the provided version (inclusive) and within the given set of keys.static com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> instantiatePersistenceVisitor(CachePersistenceHelper.Visitor visitorCache) Instantiate avisitorfor the PersistentStore backed by thestatic booleanisGlobalPartitioningSchemePID(int nPartition) Return true iff the specified partition-id is to be used to persist (meta-)data that is logically "global".static booleanisLocalSnapshotSparse(com.oracle.coherence.persistence.PersistenceEnvironment env, String sSnapshot) Returntrueif the specified local snapshot is marked as sparse.static booleanisMetadataCompatible(Properties prop, int nImplVersion, String sStorageFormat, int nStorageVersion) Determine if the given metadata in thePropertiesis compatible with the metadata supplied.static booleanisMetadataComplete(Properties prop) Determine if the given metadata in thePropertiesis complete.static booleanisSealed(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Return true if the specified store has been sealed.static booleanisSnapshotSparse(Properties prop) Returntrueif the provided metadata marks the snapshot as sparse.static voidmoveExtents(com.oracle.coherence.persistence.PersistentStore store, long lOldExtentId, long lNewExtentId) Move the old extent to the new extent in the specifiedstoreincluding all associated extents (meta extents).static PropertiesreadMetadata(File fileDir) Read persistence metadata from the specified directory.static PropertiesreadMetadataIfPresent(File fileDir) Read persistence metadata from the specified directory if present.static com.tangosol.net.internal.QuorumInforeadQuorum(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Read the membership information from the "META" extent.static com.tangosol.net.internal.QuorumInforeadQuorum(Binary binMembers) Read the membership information from its encoded form.static BinaryreadQuorumRaw(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Read the membership information in Binary format from the "META" extent.static voidrecordRecoveryStatus(com.oracle.coherence.persistence.PersistenceEnvironment env, String sSnapshot, boolean bRecoverySuccess, String sReason) static voidregisterContinuousAggregation(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, int nFormat, Binary binDefinition, Object oToken) Store a continuous aggregation definition registration.static voidregisterContinuousAggregationState(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, int nFormat, int nPartition, long lOwnershipVersion, long lDataVersion, Binary binDefinition, Binary binState, Object oToken) Store an exact continuous aggregation partition-state checkpoint.static voidregisterIndex(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binExtractor, Binary binComparator, Object oToken) Store the index registration in the specified persistent store.static voidregisterListener(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lListenerId, boolean fLite, Object oToken) Store the listener registration in the specified persistent store.static voidregisterLock(com.oracle.coherence.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 voidregisterTrigger(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binTrigger, Object oToken) Store the trigger registration in the specified persistent store.static voidresumeService(Cluster cluster, String sServiceName) Resume a service on a separate thread and wait for the resume to complete.static voidseal(com.oracle.coherence.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 voidstoreCacheNames(com.oracle.coherence.persistence.PersistentStore store, LongArray laCaches) Persist the specified cache names in the persistent store.static voidunregisterContinuousAggregation(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, int nFormat, Binary binDefinition, Object oToken) Remove a continuous aggregation definition registration.static voidunregisterIndex(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binExtractor, Object oToken) Clear the index registration from the specified persistent store.static voidunregisterIndices(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Clear all index registrations for the specified cache from the specified persistent store.static voidunregisterListener(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lListenerId, Object oToken) Clear the listener registration from the specified persistent store.static voidunregisterListeners(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Clear all listener registrations for the specified cache from the specified persistent store.static voidunregisterLock(com.oracle.coherence.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 voidunregisterLocks(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Clear all cache entry locks for the specified cache from the specified persistent store.static voidunregisterTrigger(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binTrigger, Object oToken) Clear the trigger registration from the specified persistent store.static voidunregisterTriggers(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Clear all trigger registrations for the specified cache from the specified persistent store.static voidunsealForActiveRecovery(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Remove a seal from a PersistentStore in active recovery context.static voidunsealForSnapshotRecovery(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, boolean fSparseSnapshot) Remove a seal from a PersistentStore in sparse snapshot recovery context.static voidvalidateForActiveRecovery(com.oracle.coherence.persistence.PersistentStore store, PartitionedService service) Validate the specified store in active recovery context.static voidvalidateForSnapshotRecovery(com.oracle.coherence.persistence.PersistentStore store, PartitionedService service, boolean fSparseSnapshot) Validate the specified store in sparse snapshot recovery context.static StringvalidateSnapshotName(String sSnapshot) Validate that the supplied snapshot name is already a safe file name.static voidwriteMetadata(File fileDir, Properties prop) Write persistence metadata to the specified directory.static BinarywriteQuorum(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, PartitionedService service) Write the current membership information to the "META" extent.static voidwriteQuorumRaw(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, Binary binInfo) Write the current membership information in raw format to the "META" extent.
-
Field Details
-
LONG_CONVERTER_DOWN
A converter that converts from a Long to a ReadBuffer. Note: this intentionally uses BDB's serialized form of a long and *not* Coherence's form of a long. -
LONG_CONVERTER_UP
A converter that converts from a ReadBuffer to a Long. Note: this intentionally converts from a BDBs serialized form of a long and *not* Coherence's serialized form of a long. -
LAST_ENTRY
A constant that suggests to a PersistentStore implementation to load the last entry. This is expected to be used as a return fromPersistentStore.Visitor.visitFromKey(). -
DEFAULT_BASE_DIR_PROPERTY
Default persistence directory system property.- See Also:
-
META_FILENAME
-
META_IMPL_VERSION
Persistence metadata property: implementation version.- See Also:
-
META_STORAGE_FORMAT
Persistence metadata property: storage format.- See Also:
-
META_STORAGE_VERSION
Persistence metadata property: storage version.- See Also:
-
META_PARTITION_COUNT
Persistence metadata property: partition count.- See Also:
-
META_SERVICE_VERSION
Persistence metadata property: service version.- See Also:
-
META_SPARSE_SNAPSHOT
Persistence metadata property: sparse snapshot marker.- See Also:
-
PERSISTENCE_VERSION
public static final int PERSISTENCE_VERSIONPersistence protocol version.- See Also:
-
DEFAULT_BASE_DIR
-
DEFAULT_ACTIVE_DIR
-
DEFAULT_BACKUP_DIR
-
DEFAULT_EVENTS_DIR
-
DEFAULT_SNAPSHOT_DIR
-
DEFAULT_TRASH_DIR
-
DEFAULT_LOCK_DIR
-
META_EXTENT
public static final long META_EXTENTThe extent-id used to store cache metadata.- See Also:
-
RESERVED_META_EXTENTS
public static final int RESERVED_META_EXTENTSReserve a certain number of extents identifiers for holding metadata.- See Also:
-
-
Constructor Details
-
CachePersistenceHelper
public CachePersistenceHelper()
-
-
Method Details
-
ensurePersistenceException
public static com.oracle.coherence.persistence.PersistenceException ensurePersistenceException(Throwable eCause) Return a PersistenceException with the given cause. If the specified cause is an instance of PersistenceException, the given throwable will be returned as is; otherwise, a new PersistenceException will be allocated and returned.- Parameters:
eCause- an optional cause- Returns:
- a PersistenceException with the given cause
-
ensurePersistenceException
public static com.oracle.coherence.persistence.PersistenceException ensurePersistenceException(Throwable eCause, String sMessage) Return a PersistenceException with the given cause and detail message. If the specified cause is an instance of PersistenceException and the detail message is null, the given throwable will be returned as is; otherwise, a new PersistenceException will be allocated and returned.- Parameters:
eCause- an optional causesMessage- an optional detail message- Returns:
- a PersistenceException with the given cause and detail message
-
seal
public static void seal(com.oracle.coherence.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.- Parameters:
store- the persistent store to sealservice- the partitioned serviceoToken- batch token to use for the seal operation, or null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unsealForActiveRecovery
public static void unsealForActiveRecovery(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Remove a seal from a PersistentStore in active recovery context.- Parameters:
store- thestorethe seal should be removed from
-
unsealForSnapshotRecovery
public static void unsealForSnapshotRecovery(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, boolean fSparseSnapshot) Remove a seal from a PersistentStore in sparse snapshot recovery context. Empty stores are accepted only when the caller has already established sparse snapshot context from the snapshot root.- Parameters:
store- thestorethe seal should be removed fromfSparseSnapshot- true iff the snapshot root has been identified as sparse
-
isSealed
Return true if the specified store has been sealed.- Parameters:
store- the persistent store to check- Returns:
- true if the specified store has been sealed
-
writeQuorumRaw
public static void writeQuorumRaw(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, Binary binInfo) Write the current membership information in raw format to the "META" extent.- Parameters:
store- the store to write intobinInfo- the Binary object to write to the "META" extent
-
writeQuorum
public static Binary writeQuorum(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, PartitionedService service) Write the current membership information to the "META" extent. Note: this method alsosealsthe store.- Parameters:
store- the store to write intoservice- the service for which the information is stored- Returns:
- the Binary object that was written to the "META" extent
-
readQuorumRaw
public static Binary readQuorumRaw(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Read the membership information in Binary format from the "META" extent.- Parameters:
store- the store to read from- Returns:
- the membership information in a Binary format
-
readQuorum
public static com.tangosol.net.internal.QuorumInfo readQuorum(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Read the membership information from the "META" extent.- Parameters:
store- the store to read from- Returns:
- the membership information
-
readQuorum
Read the membership information from its encoded form.- Parameters:
binMembers- the encoded membership information- Returns:
- the membership information
-
validateForActiveRecovery
public static void validateForActiveRecovery(com.oracle.coherence.persistence.PersistentStore store, PartitionedService service) Validate the specified store in active recovery context.- Parameters:
store- the persistent store to validateservice- the partitioned service- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
validateForSnapshotRecovery
public static void validateForSnapshotRecovery(com.oracle.coherence.persistence.PersistentStore store, PartitionedService service, boolean fSparseSnapshot) Validate the specified store in sparse snapshot recovery context. Empty stores are accepted only when the caller has already established sparse snapshot context from the snapshot root.- Parameters:
store- the persistent store to validateservice- the partitioned servicefSparseSnapshot- true iff the snapshot root has been identified as sparse- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
storeCacheNames
public static void storeCacheNames(com.oracle.coherence.persistence.PersistentStore store, LongArray laCaches) Persist the specified cache names in the persistent store.- Parameters:
store- the persistent store to store the cache names tolaCaches- the LongArray of cache names, indexed by cache-id- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
getCacheNamesForActiveRecovery
public static LongArray<String> getCacheNamesForActiveRecovery(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Return the cache names in active recovery context.- Parameters:
store- the persistent store to load the cache names from- Returns:
- a LongArray of cache names, indexed by the cache-id
- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
getCacheNamesForSnapshotRecovery
public static LongArray<String> getCacheNamesForSnapshotRecovery(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, boolean fSparseSnapshot) Return the cache names in sparse snapshot recovery context. Empty stores are accepted only when the caller has already established sparse snapshot context from the snapshot root.- Parameters:
store- the persistent store to load the cache names fromfSparseSnapshot- true iff the snapshot root has been identified as sparse- Returns:
- a LongArray of cache names, indexed by the cache-id
- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
getPartitionCount
public static int getPartitionCount(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Return the partition count that has been stored in the specified store.- Parameters:
store- the persistent store to load the partition count from- Returns:
- the partition count or -1 if the specified store does not contain a partition count
-
getServiceVersion
@Deprecated public static String getServiceVersion(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Deprecated.usegetPersistenceVersion(PersistentStore)insteadReturn the service version that has been stored in the specified store.- Parameters:
store- the persistent store to load the service version from- Returns:
- the service version or "<none> if the specified store does not contain a service version
-
getPersistenceVersion
public static int getPersistenceVersion(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store) Return the persistence version the provided store was written with.- Parameters:
store- the persistent store to load the persistence version from- Returns:
- the persistence version or
0if the specified store does not contain a persistence version
-
isGlobalPartitioningSchemePID
public static boolean isGlobalPartitioningSchemePID(int nPartition) Return true iff the specified partition-id is to be used to persist (meta-)data that is logically "global".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.
- Parameters:
nPartition- the partition-id- Returns:
- true iff the specified partition is to be used to persist global meta-data
-
getGlobalPartitions
Return a PartitionSet that contains partitions to be used to persist (meta-)data that is logically "global".- Parameters:
service- the service for which the global partitions are requested- Returns:
- the PartitionSet containing
global partition ids
-
deleteExtents
public static void deleteExtents(com.oracle.coherence.persistence.PersistentStore store, long lExtentId) Delete the provided extent from the specifiedstoreand all associated extents (meta extents).- Parameters:
store- the PersistenceStorelExtentId- the extent id
-
moveExtents
public static void moveExtents(com.oracle.coherence.persistence.PersistentStore store, long lOldExtentId, long lNewExtentId) Move the old extent to the new extent in the specifiedstoreincluding all associated extents (meta extents).- Parameters:
store- the PersistenceStorelOldExtentId- the old extent idlNewExtentId- the new extent id
-
readMetadata
Read persistence metadata from the specified directory.- Parameters:
fileDir- the directory to read metadata from- Returns:
- the metadata
- Throws:
IOException- on error reading the metadata file
-
writeMetadata
Write persistence metadata to the specified directory.- Parameters:
fileDir- the directory to write metadata toprop- the metadata to write- Throws:
IOException- on error writing the metadata file
-
readMetadataIfPresent
Read persistence metadata from the specified directory if present.- Parameters:
fileDir- the directory to read metadata from- Returns:
- the metadata, or
nullif no metadata file exists - Throws:
IOException- on error reading the metadata file
-
isSnapshotSparse
Returntrueif the provided metadata marks the snapshot as sparse.- Parameters:
prop- the metadata to inspect- Returns:
trueif the snapshot is sparse
-
isLocalSnapshotSparse
public static boolean isLocalSnapshotSparse(com.oracle.coherence.persistence.PersistenceEnvironment env, String sSnapshot) Returntrueif the specified local snapshot is marked as sparse.- Parameters:
env- the persistence environmentsSnapshot- the snapshot name- Returns:
trueif the specified local snapshot is sparse
-
copyMetadata
Copy the metadata file from one directory to another.- Parameters:
fileDirFrom- the directory to copy fromfileDirTo- the directory to copy to- Throws:
IOException- on copying the metadata
-
isMetadataComplete
Determine if the given metadata in thePropertiesis complete.- Parameters:
prop- the metadata to analyze- Returns:
- true if the given metadata is complete; false otherwise
-
isMetadataCompatible
public static boolean isMetadataCompatible(Properties prop, int nImplVersion, String sStorageFormat, int nStorageVersion) Determine if the given metadata in thePropertiesis compatible with the metadata supplied.- Parameters:
prop- the metadata to analyzenImplVersion- the impl version to comparesStorageFormat- the storage format to comparenStorageVersion- the storage version to compare- Returns:
- true if the given metadata is compatible; false otherwise
-
getListenerExtentId
protected static long getListenerExtentId(long lCacheId) Return the extent identifier that contains listener registration information for the cache with the given identifier.- Parameters:
lCacheId- the cacheId- Returns:
- the listener extent identifier
-
createListenerRegistrationKey
protected static ReadBuffer createListenerRegistrationKey(long lMemberId, long lCacheId, Binary binKey) Create a key representing a cache listener registration.- Parameters:
lMemberId- the unique service-identifier of the listening memberlCacheId- the cache-idbinKey- the key to listen to- Returns:
- a ReadBuffer representing the listener registration
-
registerListener
public static void registerListener(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lListenerId, boolean fLite, Object oToken) Store the listener registration in the specified persistent store.- Parameters:
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 null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unregisterListener
public static void unregisterListener(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lListenerId, Object oToken) Clear the listener registration from the specified persistent store.- Parameters:
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 null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unregisterListeners
public static void unregisterListeners(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Clear all listener registrations for the specified cache from the specified persistent store.- Parameters:
store- the persistent storelCacheId- the cache-id- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
getLockExtentId
protected static long getLockExtentId(long lCacheId) Return the extent identifier that contains lock registration information for the cache with the given identifier.- Parameters:
lCacheId- the cacheId- Returns:
- the lock extent identifier
-
createLockRegistrationKey
protected static ReadBuffer createLockRegistrationKey(long lHolderId, long lHolderThreadId, long lCacheId, Binary binKey) Create a key representing a cache entry lock.- Parameters:
lHolderId- the unique service-identifier of the listening memberlHolderThreadId- the thread-id of the lock holderlCacheId- the cache-idbinKey- the locked key- Returns:
- a ReadBuffer representing the cache entry lock
-
registerLock
public static void registerLock(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lHolderId, long lHolderThreadId, Object oToken) Store the cache entry lock in the specified persistent store.- Parameters:
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 null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unregisterLock
public static void unregisterLock(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binKey, long lHolderId, long lHolderThreadId, Object oToken) Clear the cache entry lock from the specified persistent store.- Parameters:
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 null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unregisterLocks
public static void unregisterLocks(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Clear all cache entry locks for the specified cache from the specified persistent store.- Parameters:
store- the persistent storelCacheId- the cache-id- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
getIndexExtentId
protected static long getIndexExtentId(long lCacheId) Return the extent identifier that contains index registration information for the cache with the given identifier.- Parameters:
lCacheId- the cacheId- Returns:
- the index extent identifier
-
createIndexRegistrationKey
Create a key representing an index registration.- Parameters:
lCacheId- the cache-idbinExtractor- the index extractor- Returns:
- a ReadBuffer representing the index registration
-
registerIndex
public static void registerIndex(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binExtractor, Binary binComparator, Object oToken) Store the index registration in the specified persistent store.- Parameters:
store- the persistent storelCacheId- the cache idbinExtractor- the index extractorbinComparator- the index comparatoroToken- batch token to use for the store operation, or null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unregisterIndex
public static void unregisterIndex(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binExtractor, Object oToken) Clear the index registration from the specified persistent store.- Parameters:
store- the persistent storelCacheId- the cache idbinExtractor- the index extractoroToken- batch token to use for the store operation, or null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unregisterIndices
public static void unregisterIndices(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Clear all index registrations for the specified cache from the specified persistent store.- Parameters:
store- the persistent storelCacheId- the cache-id- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
getTriggerExtentId
protected static long getTriggerExtentId(long lCacheId) Return the extent identifier that contains trigger registration information for the cache with the given identifier.- Parameters:
lCacheId- the cacheId- Returns:
- the trigger extent identifier
-
createTriggerRegistrationKey
Create a key representing an trigger registration.- Parameters:
lCacheId- the cache-idbinTrigger- the trigger- Returns:
- a ReadBuffer representing the trigger registration
-
registerTrigger
public static void registerTrigger(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binTrigger, Object oToken) Store the trigger registration in the specified persistent store.- Parameters:
store- the persistent storelCacheId- the cache idbinTrigger- the triggeroToken- batch token to use for the store operation, or null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unregisterTrigger
public static void unregisterTrigger(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, Binary binTrigger, Object oToken) Clear the trigger registration from the specified persistent store.- Parameters:
store- the persistent storelCacheId- the cache idbinTrigger- the triggeroToken- batch token to use for the store operation, or null- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
unregisterTriggers
public static void unregisterTriggers(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Clear all trigger registrations for the specified cache from the specified persistent store.- Parameters:
store- the persistent storelCacheId- the cache-id- Throws:
com.oracle.coherence.persistence.PersistenceException- if the persistent store operations fail
-
getContinuousAggregationExtentId
protected static long getContinuousAggregationExtentId(long lCacheId) Return the extent identifier containing continuous aggregation definitions for the specified cache.- Parameters:
lCacheId- the cache identifier- Returns:
- the definition extent identifier
-
getContinuousAggregationStateExtentId
protected static long getContinuousAggregationStateExtentId(long lCacheId) Return the extent identifier containing continuous aggregation partition-state checkpoints for the specified cache.- Parameters:
lCacheId- the cache identifier- Returns:
- the state extent identifier
-
createContinuousAggregationRegistrationKey
protected static ReadBuffer createContinuousAggregationRegistrationKey(long lCacheId, int nFormat, Binary binDefinition) Create a continuous aggregation definition registration key. -
registerContinuousAggregation
public static void registerContinuousAggregation(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, int nFormat, Binary binDefinition, Object oToken) Store a continuous aggregation definition registration.- Parameters:
store- the persistent storelCacheId- the cache identifiernFormat- the definition format versionbinDefinition- the serialized definitionoToken- the batch token, ornull
-
unregisterContinuousAggregation
public static void unregisterContinuousAggregation(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, int nFormat, Binary binDefinition, Object oToken) Remove a continuous aggregation definition registration.- Parameters:
store- the persistent storelCacheId- the cache identifiernFormat- the definition format versionbinDefinition- the serialized definitionoToken- the batch token, ornull
-
createContinuousAggregationStateKey
protected static ReadBuffer createContinuousAggregationStateKey(long lCacheId, int nFormat, int nPartition, long lOwnershipVersion, long lDataVersion, Binary binDefinition) Create a continuous aggregation partition-state checkpoint key. -
registerContinuousAggregationState
public static void registerContinuousAggregationState(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId, int nFormat, int nPartition, long lOwnershipVersion, long lDataVersion, Binary binDefinition, Binary binState, Object oToken) Store an exact continuous aggregation partition-state checkpoint.- Parameters:
store- the persistent storelCacheId- the cache identifiernFormat- the state format versionnPartition- the partition identifierlOwnershipVersion- the ownership versionlDataVersion- the logical data versionbinDefinition- the serialized definition fingerprintbinState- the serialized state envelopeoToken- the batch token, ornull
-
deleteContinuousAggregationStates
public static void deleteContinuousAggregationStates(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> store, long lCacheId) Delete every continuous aggregation state checkpoint for the specified cache from a mutable persistent store.Checkpoints recovered from an immutable partition snapshot are consumed once and then removed from the active store. Otherwise later data-only persistence writes could leave an old derived-state checkpoint beside newer cache data.
- Parameters:
store- the persistent storelCacheId- the cache identifier
-
resumeService
-
getSnapshotPersistenceTools
public static com.oracle.coherence.persistence.PersistenceTools getSnapshotPersistenceTools(File dirSnapshot) Return an implementation specific instance ofPersistenceToolsfor the given local snapshot directory.- Parameters:
dirSnapshot- the snapshot directory to get tools for- Returns:
- an implementation specific instance of PersistenceTools
- Throws:
com.oracle.coherence.persistence.PersistenceException- if any errors
-
getSnapshotPersistenceTools
public static com.oracle.coherence.persistence.PersistenceTools getSnapshotPersistenceTools(File dirSnapshot, boolean validation) Return an implementation specific instance ofPersistenceToolsfor the given local snapshot directory.- Parameters:
dirSnapshot- the snapshot directory to get tools forvalidation- whether to enable snapshot validation- Returns:
- an implementation specific instance of PersistenceTools
- Throws:
com.oracle.coherence.persistence.PersistenceException- if any errors
-
getArchiverPersistenceTools
public static com.oracle.coherence.persistence.PersistenceTools getArchiverPersistenceTools(ExtensibleConfigurableCacheFactory eccf, String sSnapshotName, String sServiceName) Return an implementation specific instance of PersistenceTools for the given archived snapshot.- Parameters:
eccf- ExtensibleConfigurableCacheFactory to usesSnapshotName- the snapshot to get toolssServiceName- the service name to get tools- Returns:
- an implementation specific instance of PersistenceTools
- Throws:
com.oracle.coherence.persistence.PersistenceException- if any errors
-
getEnvironmentInfo
public static PersistenceEnvironmentInfo getEnvironmentInfo(ExtensibleConfigurableCacheFactory eccf, String sServiceName) Return thePersistenceEnvironmentInfofor a given cluster and service name using the currentConfigurableCacheFactorywithout starting the services.- Parameters:
eccf- ExtensibleConfigurableCacheFactory to usesServiceName- the service name to use- Returns:
- the PersistenceEnvironmentInfo for the given service and cluster
-
getClusterName
Return the cluster name without starting the cluster service.- Returns:
- the name of the cluster
-
validateSnapshotName
-
instantiatePersistenceVisitor
public static com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> instantiatePersistenceVisitor(CachePersistenceHelper.Visitor visitorCache) Instantiate avisitorfor the PersistentStore backed by the- Parameters:
visitorCache- the cache visitor to delegate to- Returns:
- a visitor for the PersistentStore
-
getMBeanName
-
instantiateEventsVisitor
public static com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> instantiateEventsVisitor(long lExtentId, Set setKeys, long lVersion, Map<Long, MapEvent> mapEvents, Converter<Long, ReadBuffer> convKeyDown, Converter<ReadBuffer, Long> convKeyUp, Converter<Object, ReadBuffer> convDown, Converter<ReadBuffer, Object> convUp) Create aPersistentStore.Visitorthat can read a PersistentStore and populate the providedmapEventswith events that are larger than the provided version (inclusive) and within the given set of keys.- Parameters:
lExtentId- the extent id to interrogatesetKeys- a set of keys the MapEvent should be raised withinlVersion- the version that all events should be larger than (inclusive)mapEvents- a Map to store the MapEventsconvKeyDown- a converter that can convert a version to a binaryconvKeyUp- a converter that can convert a binary to a versionconvDown- a converter that can convert an MapEvent to a binaryconvUp- a converter that can convert an MapEvent to a binary- Returns:
- a Visitor that can read a PersistentStore and populate the provided map of events
-
instantiateEventsVisitor
public static com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> instantiateEventsVisitor(long lExtentId, Filter filter, long lVersion, Map<Long, MapEvent> mapEvents, Converter<Long, ReadBuffer> convKeyDown, Converter<ReadBuffer, Long> convKeyUp, Converter<Object, ReadBuffer> convDown, Converter<ReadBuffer, Object> convUp) Create aPersistentStore.Visitorthat can read a PersistentStore and populate the providedmapEventswith events that are larger than the provided version (inclusive) and match the givenFilter.- Parameters:
lExtentId- the extent id to interrogatefilter- a Filter to test the MapEvents againstlVersion- the version that all events should be larger than (inclusive)mapEvents- a Map to store the MapEventsconvKeyDown- a converter that can convert a version to a binaryconvKeyUp- a converter that can convert a binary to a versionconvDown- a converter that can convert an MapEvent to a binaryconvUp- a converter that can convert an MapEvent to a binary- Returns:
- a Visitor that can read a PersistentStore and populate the provided map of events
-
recordRecoveryStatus
-
getSnapshotStatus
-
getSnapshotRecoveryStatus
public static String getSnapshotRecoveryStatus(com.oracle.coherence.persistence.PersistenceEnvironment env, String sName) Return recovery status for the given snapshot.- Parameters:
env- thePersistenceEnvironmentto querysName- the snapshot name- Returns:
- the snapshot recovery status, or null if it is not possible to obtain the status.
-
getFailedSnapshots
public static String[] getFailedSnapshots(com.oracle.coherence.persistence.PersistenceEnvironment env)
-
getPersistenceVersion(PersistentStore)instead