You can customize your snapshot by filtering entries during the import or export of a region or a cache.
For example, use filters to limit the export of data to a certain date range. If you set up a filter on the import or export of a cache, the filter is applied to every single region in the cache.
The following example filters snapshot data by even numbered keys.
File mySnapshot = ...
Region<Integer, MyObject> region = ...
SnapshotFilter<Integer, MyObject> even = new SnapshotFilter<Integer, MyObject>() {
@Override
public boolean accept(Entry<Integer, MyObject> entry) {
return entry.getKey() % 2 == 0;
}
};
RegionSnapshotService<Integer, MyObject> snapsrv = region.getSnapshotService();
SnapshotOptions<Integer, MyObject> options = snapsrv.createOptions().setFilter(even);
// only save cache entries with an even key
snapsrv.save(mySnapshot, SnapshotFormat.GEMFIRE, options);