org.apache.geode.cache.snapshot

## Interface RegionSnapshotService<K,V>

- Type Parameters:
    `K` - the cache entry key type
    `V` - the cache entry value type

      public interface RegionSnapshotService<K,V>

  Allows a snapshot of region data to be imported and exported. Example usage:

       // 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(Entry entry) {
           return true;
         }
       };

       SnapshotOptions options = snapshot.createOptions();
       options.setFilter(filter);

       snapshot.save(new File("snapshot"), 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.
  Since:
    GemFire 7.0
  See Also:
    `Region.getSnapshotService()`, `SnapshotOptions`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    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.

- - ### Method Detail

    - #### createOptions

          SnapshotOptions<K,V> createOptions()

      Creates a `SnapshotOptions` object configured with default settings. The options can be used to configure snapshot behavior.
      Returns:
        the default options

    - #### save

          void save(java.io.File snapshot,
                    SnapshotOptions.SnapshotFormat format)
             throws java.io.IOException

      Exports the region data into the snapshot file.
      Parameters:
        `snapshot` - the snapshot file
        `format` - the snapshot format
      Throws:
        `java.io.IOException` - error writing snapshot

    - #### save

          void save(java.io.File snapshot,
                    SnapshotOptions.SnapshotFormat format,
                    SnapshotOptions<K,V> options)
             throws java.io.IOException

      Exports the region data into the snapshot file by applying user-configured options.
      Parameters:
        `snapshot` - the snapshot file
        `format` - the snapshot format
        `options` - the snapshot options
      Throws:
        `java.io.IOException` - error writing snapshot

    - #### load

          void load(java.io.File snapshot,
                    SnapshotOptions.SnapshotFormat format)
             throws java.io.IOException,
                    java.lang.ClassNotFoundException

      Imports the snapshot file into the specified region.

      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.

      Parameters:
        `snapshot` - the snapshot file
        `format` - the snapshot file format
      Throws:
        `java.io.IOException` - Unable to import data
        `java.lang.ClassNotFoundException` - Unable to import data

    - #### load

          void load(java.io.File snapshot,
                    SnapshotOptions.SnapshotFormat format,
                    SnapshotOptions<K,V> options)
             throws java.io.IOException,
                    java.lang.ClassNotFoundException

      Imports the snapshot file into the specified region by applying user- configured options.

      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.

      Parameters:
        `snapshot` - the snapshot file
        `format` - the snapshot file format
        `options` - the snapshot options
      Throws:
        `java.io.IOException` - Unable to import data
        `java.lang.ClassNotFoundException` - Unable to import data