K
- the cache entry key typeV
- the cache entry value typepublic interface RegionSnapshotService<K,V>
// obtain a snapshot RegionSnapshot snapshot = region.getSnapshotService(); // export the snapshot, every region in the cache will be exported snapshot.save(new File("snapshot.gfd"), SnapshotOptions.GEMFIRE); // import the snapshot file, updates any existing entries in the region snapshot.load(new File("snapshot.gfd"), SnapshotOptions.GEMFIRE);When parallel export is used, the file name will be modified to include a unique identifier for the member that created the file, so providing a file location of "snapshot.gfd" would result in creation of multiple files with the format "snapshot-unique_id.gfd". When loading files from a parallel export, a directory can be given instead of a single file and all snapshot files in that directory will be loaded.
// import directory of snapshot files snapshot.load(new File("snapshotDir"), SnapshotOptions.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 region is a partitioned region. The snapshot behavior can be changed using
SnapshotOptions
. For example:
RegionSnapshotService snapshot = region.getSnapshotService(); SnapshotFilter filter = new SnapshotFilter() { public boolean accept(Entry$lt;K, V$gt; entry) { return true; } }; SnapshotOptions$lt;Object, Object$gt; options = snapshot.createOptions(); options.setFilter(filter); snapshot.save(new File("snapshot.gfd"), SnapshotFormat.GEMFIRE, options);Note that the snapshot does not provide a consistency guarantee. Updates to data during the course of import/export operations could result data inconsistencies.
Region.getSnapshotService()
,
SnapshotOptions
Modifier and Type | Field and Description |
---|---|
static String |
SNAPSHOT_FILE_EXTENSION
File extension for snapshot files
|
Modifier and Type | Method and Description |
---|---|
SnapshotOptions<K,V> |
createOptions()
Creates a
SnapshotOptions object configured with default settings. |
void |
load(File snapshot,
SnapshotOptions.SnapshotFormat format)
Imports the snapshot file into the specified region.
|
void |
load(File snapshot,
SnapshotOptions.SnapshotFormat format,
SnapshotOptions<K,V> options)
Imports the snapshot file into the specified region by applying user-configured options.
|
void |
save(File snapshot,
SnapshotOptions.SnapshotFormat format)
Exports the region data into the snapshot file.
|
void |
save(File snapshot,
SnapshotOptions.SnapshotFormat format,
SnapshotOptions<K,V> options)
Exports the region data into the snapshot file by applying user-configured options.
|
static final String SNAPSHOT_FILE_EXTENSION
SnapshotOptions<K,V> createOptions()
SnapshotOptions
object configured with default settings. The options can
be used to configure snapshot behavior.void save(File snapshot, SnapshotOptions.SnapshotFormat format) throws IOException
snapshot
- the snapshot file (must end in .gfd)format
- the snapshot formatIOException
- error writing snapshotvoid save(File snapshot, SnapshotOptions.SnapshotFormat format, SnapshotOptions<K,V> options) throws IOException
snapshot
- the snapshot file (must end in .gfd)format
- the snapshot formatoptions
- the snapshot optionsIOException
- error writing snapshotvoid load(File snapshot, SnapshotOptions.SnapshotFormat format) throws IOException, ClassNotFoundException
Prior to loading data, the region should have been created and any necessary serializers
(either DataSerializer
or PdxSerializer
) and Instantiator
s should have
been registered.
snapshot
- the snapshot file (ending in .gfd) or a directory of .gfd snapshot filesformat
- the snapshot file formatIOException
- Unable to import dataClassNotFoundException
- Unable to import datavoid load(File snapshot, SnapshotOptions.SnapshotFormat format, SnapshotOptions<K,V> options) throws IOException, ClassNotFoundException
Prior to loading data, the region should have been created and any necessary serializers
(either DataSerializer
or PdxSerializer
) and Instantiator
s should have
been registered.
snapshot
- the snapshot file (ending in .gfd) or a directory of .gfd snapshot filesformat
- the snapshot file formatoptions
- the snapshot optionsIOException
- Unable to import dataClassNotFoundException
- Unable to import data