com.gemstone.gemfire.internal.cache.snapshot.SnapshotOptionsImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gemfire-core Show documentation
Show all versions of gemfire-core Show documentation
SnappyData store based off Pivotal GemFireXD
The newest version!
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.internal.cache.snapshot;
import com.gemstone.gemfire.cache.snapshot.SnapshotFilter;
import com.gemstone.gemfire.cache.snapshot.SnapshotOptions;
/**
* Implements the snapshot options.
*
* @author bakera
*
* @param the key type
* @param the value type
*/
public class SnapshotOptionsImpl implements SnapshotOptions {
private static final long serialVersionUID = 1L;
/** the entry filter */
private volatile SnapshotFilter filter;
/** true if parallel mode is enabled */
private volatile boolean parallel;
/** the file mapper, or null if parallel mode is not enabled */
private volatile SnapshotFileMapper mapper;
public SnapshotOptionsImpl() {
filter = null;
}
@Override
public SnapshotOptions setFilter(SnapshotFilter filter) {
this.filter = filter;
return this;
}
@Override
public SnapshotFilter getFilter() {
return filter;
}
/**
* Enables parallel mode for snapshot operations. This will cause each member
* of a partitioned region to save its local data set (ignoring redundant
* copies) to a separate snapshot file. During a parallel import, each member
* may read from one or more snapshot files created during a parallel export.
*
* Parallelizing snapshot operations may yield significant performance
* improvements for large data sets. This is particularly true when each
* member is reading from or writing to separate physical disks.
*
* This flag is ignored for replicated regions.
*
* If the mapper is not set explicitly, a default mapping implementation is used
* that assumes each member can access a non-shared disk volume. The default
* mapper provides the following behavior:
*
* - export
* - use the supplied path
* - import
* - if the supplied path is a file, use that file
* - if the supplied path is a directory, use all files in the directory
*
* If processes are colocated on the same machine and relative pathnames are
* not used, a custom mapper must be supplied to disambiguate filenames.
* This rule applies when writing to a shared network volume as well.
*
* @param parallel true if the snapshot operations will be performed in parallel
* @return the snapshot options
*
* @see SnapshotFileMapper
*/
public SnapshotOptions setParallelMode(boolean parallel) {
this.parallel = parallel;
return this;
}
/**
* Returns true if the snapshot operation will proceed in parallel.
*
* @return true if the parallel mode has been enabled
*/
public boolean isParallelMode() {
return parallel;
}
/**
* Overrides the default file mapping for parallel import and export
* operations.
*
* @param mapper the custom mapper, or null to use the default mapping
* @return the snapshot options
* @see #setParallelMode(boolean)
*/
public SnapshotOptions setMapper(SnapshotFileMapper mapper) {
this.mapper = mapper;
return this;
}
/**
* Returns the snapshot file mapper for parallel import and export.
*
* @return the mapper
* @see #setParallelMode(boolean)
*/
public SnapshotFileMapper getMapper() {
return (mapper == null) ? RegionSnapshotServiceImpl.LOCAL_MAPPER : mapper;
}
}