Importing Cache and Region Snapshots
To import a GemFire cache or region data snapshot that you previously exported into another distributed system or region, use the
region.getSnapshotService.load API, or the
gfsh command-line interface (
Before you import a region snapshot:
- Make sure the cache is configured correctly. Configure all registered PdxSerializers, DataSerializers, and Instantiators; create regions; and ensure the classpath contains any required classes.
- When you import a snapshot containing PDX types, you must wait until the exported type definitions are imported into the cache before inserting data that causes type conflicts. It is recommended that you wait for the import to complete before inserting data.
During an import, the
CacheListener callbacks are not invoked.
If an error occurs during import, the import is halted and the region will contain some but not all snapshot data.
The state of a cache client is indeterminate after an import. It is likely that the data in the client’s cache is inconsistent with the imported data. Take the client offline during the import and restart it after the import completes.
When you import a cache snapshot, the snapshot file is imported into the same region (match determined by name) that was used during snapshot export. When you import a cache, you import all snapshot files located within a directory into the cache. The API attempts to load all files in the specified directory.
File mySnapshotDir = ... Cache cache = ... cache.getSnapshotService().load(mySnapshotDir, SnapshotFormat.GEMFIRE);
File mySnapshot = ... Region<String, MyObject> region = ... region.getSnapshotService().load(mySnapshot, SnapshotFormat.GEMFIRE);
Open a gfsh prompt. After connecting to a GemFire distributed system, at the prompt type:
gfsh>import data --region=Region --file=filename.gfd --member=membername
where Region corresponds to the name of the region that you want to import data into; filename (must end in .gfd) corresponds to the name of the file to be imported; and membername corresponds to the member where the region to be imported is hosted. For example:
gfsh>import data --region=region1 --file=region1_2012_10_10.gfd --member=server2
The snapshot file must already reside on the specified member at the location specified in the
--file argument before import.
For more information on this command, see import data.