public interface CacheSnapshotService
// obtain a snapshot CacheSnapshotService snapshot = cache.getSnapshotService(); // export the snapshot, every region in the cache will be exported snapshot.save(new File("."), SnapshotFormat.GEMFIRE); // import the snapshot files, updates any existing entries in the cache snapshot.load(new File("."), SnapshotFormat.GEMFIRE);The default behavior is to perform all I/O operations on the node where the snapshot operations are invoked. This will involve either collecting or dispersing data over the network if the cache contains a partitioned region. The snapshot behavior can be changed using
SnapshotOptions
. For example:
CacheSnapshotService snapshot = cache.getSnapshotService(); SnapshotFilter filter = new SnapshotFilter() { public boolean accept(EntryNote that the snapshot does not provide a consistency guarantee. Updates to data during the course of import/export operations could result data inconsistencies.entry) { return true; } }; SnapshotOptions
Cache.getSnapshotService()
,
SnapshotOptions
Modifier and Type | Method and Description |
---|---|
SnapshotOptions<java.lang.Object,java.lang.Object> |
createOptions()
Creates a
SnapshotOptions object configured with default settings. |
void |
load(java.io.File[] snapshots,
SnapshotOptions.SnapshotFormat format,
SnapshotOptions<java.lang.Object,java.lang.Object> options)
Imports the specified files into the cache by applying user-configured options.
|
void |
load(java.io.File dir,
SnapshotOptions.SnapshotFormat format)
Imports all files in the specified directory into the cache.
|
void |
save(java.io.File dir,
SnapshotOptions.SnapshotFormat format)
Exports all regions in the cache to the specified directory.
|
void |
save(java.io.File dir,
SnapshotOptions.SnapshotFormat format,
SnapshotOptions<java.lang.Object,java.lang.Object> options)
Exports all regions in the cache to the specified directory by applying user-configured
options.
|
SnapshotOptions<java.lang.Object,java.lang.Object> createOptions()
SnapshotOptions
object configured with default settings. The options can
be used to configure snapshot behavior.void save(java.io.File dir, SnapshotOptions.SnapshotFormat format) throws java.io.IOException
dir
- the directory for writing the snapshots, will be created if necessaryformat
- the snapshot formatjava.io.IOException
- error writing snapshotvoid save(java.io.File dir, SnapshotOptions.SnapshotFormat format, SnapshotOptions<java.lang.Object,java.lang.Object> options) throws java.io.IOException
dir
- the directory for writing the snapshots, will be created if necessaryformat
- the snapshot formatoptions
- the snapshot optionsjava.io.IOException
- error writing snapshotvoid load(java.io.File dir, SnapshotOptions.SnapshotFormat format) throws java.io.IOException, java.lang.ClassNotFoundException
Prior to loading data, all regions should have been created and any necessary serializers
(either DataSerializer
or PdxSerializer
) and Instantiator
s should have
been registered.
dir
- the directory containing the snapshot filesformat
- the snapshot file formatjava.io.IOException
- Unable to import datajava.lang.ClassNotFoundException
- Unable to import datavoid load(java.io.File[] snapshots, SnapshotOptions.SnapshotFormat format, SnapshotOptions<java.lang.Object,java.lang.Object> options) throws java.io.IOException, java.lang.ClassNotFoundException
Prior to loading data, all regions should have been created and any necessary serializers
(either DataSerializer
or PdxSerializer
) and Instantiator
s should have
been registered.
snapshots
- the snapshot filesformat
- the snapshot file formatoptions
- the snapshot optionsjava.io.IOException
- Unable to import datajava.lang.ClassNotFoundException
- Unable to import data