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"), SnapshotOptions.GEMFIRE); // import the snapshot file, updates any existing entries in the region snapshot.load(new File("snapshot"), 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(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
Region.getSnapshotService()
,
SnapshotOptions
Modifier and Type | Method and Description |
---|---|
SnapshotOptions<K,V> |
createOptions()
Creates a
SnapshotOptions object configured with default settings. |
void |
load(java.io.File snapshot,
SnapshotOptions.SnapshotFormat format)
Imports the snapshot file into the specified region.
|
void |
load(java.io.File snapshot,
SnapshotOptions.SnapshotFormat format,
SnapshotOptions<K,V> options)
Imports the snapshot file into the specified region by applying user- configured options.
|
void |
save(java.io.File snapshot,
SnapshotOptions.SnapshotFormat format)
Exports the region data into the snapshot file.
|
void |
save(java.io.File snapshot,
SnapshotOptions.SnapshotFormat format,
SnapshotOptions<K,V> options)
Exports the region data into the snapshot file by applying user-configured options.
|
SnapshotOptions<K,V> createOptions()
SnapshotOptions
object configured with default settings. The options can
be used to configure snapshot behavior.void save(java.io.File snapshot, SnapshotOptions.SnapshotFormat format) throws java.io.IOException
snapshot
- the snapshot fileformat
- the snapshot formatjava.io.IOException
- error writing snapshotvoid save(java.io.File snapshot, SnapshotOptions.SnapshotFormat format, SnapshotOptions<K,V> options) throws java.io.IOException
snapshot
- the snapshot fileformat
- the snapshot formatoptions
- the snapshot optionsjava.io.IOException
- error writing snapshotvoid load(java.io.File snapshot, SnapshotOptions.SnapshotFormat format) throws java.io.IOException, java.lang.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 fileformat
- the snapshot file formatjava.io.IOException
- Unable to import datajava.lang.ClassNotFoundException
- Unable to import datavoid load(java.io.File snapshot, SnapshotOptions.SnapshotFormat format, SnapshotOptions<K,V> options) throws java.io.IOException, java.lang.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 fileformat
- the snapshot file formatoptions
- the snapshot optionsjava.io.IOException
- Unable to import datajava.lang.ClassNotFoundException
- Unable to import data