本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.createDiskStoreFactory方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.createDiskStoreFactory方法的具体用法?Java Cache.createDiskStoreFactory怎么用?Java Cache.createDiskStoreFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gemstone.gemfire.cache.Cache
的用法示例。
在下文中一共展示了Cache.createDiskStoreFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPersistentRegionAsync
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Creates a persistent region in async manner
*
* @param vm
* reference to VM
* @return reference to AsyncInvocation
*/
@SuppressWarnings("serial")
protected AsyncInvocation createPersistentRegionAsync(final VM vm) {
SerializableRunnable createRegion = new SerializableRunnable(
"Create persistent region") {
public void run() {
Cache cache = getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File dir = getDiskDirForVM(vm);
dir.mkdirs();
dsf.setDiskDirs(new File[] { dir });
dsf.setMaxOplogSize(1);
dsf.setAllowForceCompaction(true);
dsf.setAutoCompact(false);
DiskStore ds = dsf.create(REGION_NAME);
RegionFactory rf = cache.createRegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDiskSynchronous(true);
rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
rf.setScope(Scope.DISTRIBUTED_ACK);
rf.create(REGION_NAME);
}
};
return vm.invokeAsync(createRegion);
}
示例2: createPersistentRegionWithoutCompaction
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected SerializableRunnable createPersistentRegionWithoutCompaction(final VM vm0) {
SerializableRunnable createRegion = new SerializableRunnable("Create persistent region") {
public void run() {
Cache cache = getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File dir = getDiskDirForVM(vm0);
dir.mkdirs();
dsf.setDiskDirs(new File[] {dir});
dsf.setMaxOplogSize(1);
dsf.setAutoCompact(false);
dsf.setAllowForceCompaction(true);
dsf.setCompactionThreshold(20);
DiskStore ds = dsf.create(REGION_NAME);
RegionFactory rf = new RegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDiskSynchronous(true);
rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
rf.setScope(Scope.DISTRIBUTED_ACK);
rf.create(REGION_NAME);
}
};
vm0.invoke(createRegion);
return createRegion;
}
示例3: createPersistentRegionAsync
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected AsyncInvocation createPersistentRegionAsync(final VM vm) {
SerializableRunnable createRegion = new SerializableRunnable("Create persistent region") {
public void run() {
Cache cache = getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File dir = getDiskDirForVM(vm);
dir.mkdirs();
dsf.setDiskDirs(new File[] {dir});
dsf.setMaxOplogSize(1);
DiskStore ds = dsf.create(REGION_NAME);
RegionFactory rf = new RegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDiskSynchronous(true);
rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
rf.setScope(Scope.DISTRIBUTED_ACK);
rf.create(REGION_NAME);
}
};
return vm.invokeAsync(createRegion);
}
示例4: createPersistentRegionAsync
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected AsyncInvocation createPersistentRegionAsync(final VM vm, final boolean diskSynchronous) {
SerializableRunnable createRegion = new SerializableRunnable("Create persistent region") {
public void run() {
Cache cache = getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File dir = getDiskDirForVM(vm);
dir.mkdirs();
dsf.setDiskDirs(new File[] {dir});
dsf.setMaxOplogSize(1);
DiskStore ds = dsf.create(REGION_NAME);
RegionFactory rf = new RegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDiskSynchronous(diskSynchronous);
rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
rf.setScope(Scope.DISTRIBUTED_ACK);
rf.create(REGION_NAME);
}
};
return vm.invokeAsync(createRegion);
}
示例5: createRegion
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private LocalRegion createRegion(final VM vm0) {
Cache cache = getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File dir = getDiskDirForVM(vm0);
dir.mkdirs();
dsf.setDiskDirs(new File[] {dir});
dsf.setMaxOplogSize(1);
//Turn of automatic compaction
dsf.setAllowForceCompaction(true);
dsf.setAutoCompact(false);
//The compaction javadocs seem to be wrong. This
//is the amount of live data in the oplog
dsf.setCompactionThreshold(40);
DiskStore ds = dsf.create(REGION_NAME);
RegionFactory rf = new RegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDiskSynchronous(true);
rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
rf.setScope(Scope.DISTRIBUTED_ACK);
LocalRegion region = (LocalRegion) rf.create(REGION_NAME);
return region;
}
示例6: createAsyncRegionWithSmallQueue
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private Region createAsyncRegionWithSmallQueue(final VM vm0) {
Cache cache = getCache();
DiskStoreFactoryImpl dsf = (DiskStoreFactoryImpl) cache.createDiskStoreFactory();
File dir = getDiskDirForVM(vm0);
dir.mkdirs();
dsf.setDiskDirs(new File[] {dir});
dsf.setMaxOplogSizeInBytes(500);
dsf.setQueueSize(1000);
dsf.setTimeInterval(1000);
DiskStore ds = dsf.create(REGION_NAME);
RegionFactory rf = new RegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
rf.setScope(Scope.DISTRIBUTED_ACK);
rf.setDiskSynchronous(false);
Region region = rf.create(REGION_NAME);
return region;
}
示例7: initQueue
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private SingleWriteSingleReadRegionQueue initQueue(boolean conflate) {
Cache cache = getCache();
GatewayQueueAttributes queueAttrs = new GatewayQueueAttributes();
queueAttrs.setBatchConflation(true);
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File overflowDir = new File(getUniqueName() + InternalDistributedSystem.getAnyInstance().getId());
if (!overflowDir.exists()) {
overflowDir.mkdir();
}
assertTrue(overflowDir.isDirectory());
File[] dirs1 = new File[] {overflowDir.getAbsoluteFile()};
dsf.setDiskDirs(dirs1).create(getUniqueName());
queueAttrs.setDiskStoreName(getUniqueName());
// queueAttrs.setOverflowDirectory(getUniqueName() + InternalDistributedSystem.getAnyInstance().getId());
CacheListener listener = new CacheListenerAdapter() {
};
GatewayStats stats = new GatewayStats(cache.getDistributedSystem(), "g1", "h1", null);
SingleWriteSingleReadRegionQueue queue = new SingleWriteSingleReadRegionQueue(cache, "region", queueAttrs, listener, stats);
return queue;
}
示例8: createOverflowRegion
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected void createOverflowRegion(final VM vm) {
SerializableRunnable createRegion = new SerializableRunnable("Create persistent region") {
public void run() {
Cache cache = getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setDiskDirs(getDiskDirs(getUniqueName()));
dsf.setMaxOplogSize(1);
DiskStore ds = dsf.create(getUniqueName());
RegionFactory rf = new RegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDiskSynchronous(true);
rf.setDataPolicy(DataPolicy.REPLICATE);
rf.setEvictionAttributes(EvictionAttributes.createLIFOEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));
rf.create("region3");
}
};
vm.invoke(createRegion);
}
示例9: createForOffline
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private static DiskStoreImpl createForOffline(String dsName, File[] dsDirs,
boolean offlineCompacting, boolean offlineValidate,
boolean upgradeVersionOnly, long maxOplogSize, boolean needsOplogs)
throws Exception {
if (dsDirs == null) {
dsDirs = new File[] { new File("") };
}
// need a cache so create a loner ds
Properties props = new Properties();
props.setProperty("locators", "");
props.setProperty("mcast-port", "0");
props.setProperty("cache-xml-file", "");
if (!TRACE_RECOVERY) {
props.setProperty("log-level", "warning");
}
DistributedSystem ds = GemFireCacheImpl.getInstance().getDistributedSystem();
offlineDS = ds;
Cache c = GemFireCacheImpl.getInstance();
offlineCache = c;
com.gemstone.gemfire.cache.DiskStoreFactory dsf = c
.createDiskStoreFactory();
dsf.setDiskDirs(dsDirs);
if (offlineCompacting && maxOplogSize != -1L) {
dsf.setMaxOplogSize(maxOplogSize);
}
DiskStoreImpl dsi = new GFXDDiskStoreImpl(c, dsName,
((DiskStoreFactoryImpl) dsf).getDiskStoreAttributes(), false, null,
true, upgradeVersionOnly, offlineValidate, offlineCompacting,
needsOplogs);
((GemFireCacheImpl) c).addDiskStore(dsi);
return dsi;
}
示例10: createForOffline
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private static DiskStoreImpl createForOffline(String dsName, File[] dsDirs,
boolean offlineCompacting, boolean offlineValidate,
boolean upgradeVersionOnly, long maxOplogSize, boolean needsOplogs)
throws Exception {
if (dsDirs == null) {
dsDirs = new File[] { new File("") };
}
// need a cache so create a loner ds
Properties props = new Properties();
props.setProperty("locators", "");
props.setProperty("mcast-port", "0");
props.setProperty("cache-xml-file", "");
if (!TRACE_RECOVERY) {
props.setProperty("log-level", "warning");
}
DistributedSystem ds = DistributedSystem.connect(props);
offlineDS = ds;
Cache c = com.gemstone.gemfire.cache.CacheFactory.create(ds);
offlineCache = c;
com.gemstone.gemfire.cache.DiskStoreFactory dsf = c
.createDiskStoreFactory();
dsf.setDiskDirs(dsDirs);
if (offlineCompacting && maxOplogSize != -1L) {
dsf.setMaxOplogSize(maxOplogSize);
}
DiskStoreImpl dsi = new DiskStoreImpl(c, dsName,
((DiskStoreFactoryImpl) dsf).getDiskStoreAttributes(), false, null,
true, upgradeVersionOnly, offlineValidate, offlineCompacting,
needsOplogs);
((GemFireCacheImpl) c).addDiskStore(dsi);
return dsi;
}
示例11: createParRegWithPersistence
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private Region<?,?> createParRegWithPersistence(String regionName, String diskStoreName, String diskDirName) {
Cache cache = getCache();
File diskStoreDirFile = new File(diskDirName);
diskStoreDirFile.deleteOnExit();
if (!diskStoreDirFile.exists()) {
diskStoreDirFile.mkdirs();
}
DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile });
diskStoreFactory.setMaxOplogSize(1);
diskStoreFactory.setAllowForceCompaction(true);
diskStoreFactory.setAutoCompact(false);
diskStoreFactory.create(diskStoreName);
/****
* Eviction Attributes
*/
EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK);
RegionFactory regionFactory = cache.createRegionFactory();
regionFactory.setDiskStoreName(diskStoreName);
regionFactory.setDiskSynchronous(true);
regionFactory.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
regionFactory.setEvictionAttributes(ea);
return regionFactory.create(regionName);
}
示例12: createRepRegWithPersistence
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private Region<?,?> createRepRegWithPersistence(String regionName, String diskStoreName, String diskDirName) {
Cache cache = getCache();
File diskStoreDirFile = new File(diskDirName);
diskStoreDirFile.deleteOnExit();
if (!diskStoreDirFile.exists()) {
diskStoreDirFile.mkdirs();
}
DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile });
diskStoreFactory.setMaxOplogSize(1);
diskStoreFactory.setAllowForceCompaction(true);
diskStoreFactory.setAutoCompact(false);
diskStoreFactory.create(diskStoreName);
/****
* Eviction Attributes
*/
EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK);
RegionFactory regionFactory = cache.createRegionFactory();
regionFactory.setDiskStoreName(diskStoreName);
regionFactory.setDiskSynchronous(true);
regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
regionFactory.setEvictionAttributes(ea);
return regionFactory.create(regionName);
}
示例13: createParRegWithPersistence
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private Region<?,?> createParRegWithPersistence(String regionName, String diskStoreName, String diskDirName) {
Cache cache = getCache();
File diskStoreDirFile = new File(diskDirName);
if (!diskStoreDirFile.exists()) {
diskStoreDirFile.mkdirs();
}
DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile });
diskStoreFactory.setMaxOplogSize(1);
diskStoreFactory.setAllowForceCompaction(true);
diskStoreFactory.setAutoCompact(false);
diskStoreFactory.create(diskStoreName);
/****
* Eviction Attributes
*/
EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK);
RegionFactory regionFactory = cache.createRegionFactory();
regionFactory.setDiskStoreName(diskStoreName);
regionFactory.setDiskSynchronous(true);
regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
regionFactory.setScope(Scope.DISTRIBUTED_ACK);
regionFactory.setEvictionAttributes(ea);
return regionFactory.create(regionName);
}
示例14: createPersistentGatewayAsync
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected AsyncInvocation createPersistentGatewayAsync(final VM vm, final int destinationPort) {
SerializableRunnable createRegion = new SerializableRunnable("Create gateway region") {
public void run() {
Cache cache = getCache();
RegionFactory rf = new RegionFactory();
rf.setDataPolicy(DataPolicy.REPLICATE);
rf.setScope(Scope.DISTRIBUTED_ACK);
rf.setEnableGateway(true);
rf.create(REGION_NAME);
int port = AvailablePortHelper.getRandomAvailableTCPPort();
GatewayHub hub = cache.addGatewayHub("h1", port);
Gateway gateway = hub.addGateway("g1");
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setDiskDirs(getDiskDirs());
dsf.setMaxOplogSize(1);
DiskStore ds = dsf.create(REGION_NAME);
gateway.setQueueAttributes(new GatewayQueueAttributes(ds.getName(), 5, 1, 100, false, true, 60000));
try {
gateway.addEndpoint("end1", InetAddress.getLocalHost().getHostAddress(), destinationPort);
hub.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
return vm.invokeAsync(createRegion);
}
示例15: createPersistentRegionAsync
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected AsyncInvocation createPersistentRegionAsync(final VM vm) {
SerializableRunnable createRegion = new SerializableRunnable("Create persistent region") {
public void run() {
Cache cache = getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setDiskDirs(getDiskDirs(getUniqueName()));
dsf.setMaxOplogSize(1);
DiskStore ds = dsf.create(getUniqueName());
RegionFactory rf = new RegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDiskSynchronous(true);
rf.setDataPolicy(getDataPolicy());
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(0);
rf.setPartitionAttributes(paf.create());
rf.create("region1");
dsf = cache.createDiskStoreFactory();
dsf.setDiskDirs(getDiskDirs(getUniqueName()+2));
dsf.setMaxOplogSize(1);
ds = dsf.create(getUniqueName()+2);
rf.setDiskStoreName(getUniqueName()+2);
rf.create("region2");
}
};
return vm.invokeAsync(createRegion);
}