当前位置: 首页>>代码示例>>Java>>正文


Java Cache.createRegionFactory方法代码示例

本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.createRegionFactory方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.createRegionFactory方法的具体用法?Java Cache.createRegionFactory怎么用?Java Cache.createRegionFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.gemstone.gemfire.cache.Cache的用法示例。


在下文中一共展示了Cache.createRegionFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPartitionedRegion

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void createPartitionedRegion(String regionName) {
 
  final Cache cache = getCache();
  // Create the data region
  RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
  dataRegionFactory.setConcurrencyLevel(4);
  EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY);
  dataRegionFactory.setEvictionAttributes(ea);
  dataRegionFactory.setEnableAsyncConflation(true);
  
  FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par1", true);
  PartitionAttributes pa = new PartitionAttributesFactory()
                                  .setLocalMaxMemory(100)
                                  .setRecoveryDelay(2)
                                  .setTotalMaxMemory(200)
                                  .setRedundantCopies(1)
                                  .addFixedPartitionAttributes(fpa)
                                  .create();
  dataRegionFactory.setPartitionAttributes(pa);
  dataRegionFactory.addCacheListener(new CacheListener1());
  dataRegionFactory.addCacheListener(new CacheListener2());
  dataRegionFactory.create(regionName);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:ListAndDescribeRegionDUnitTest.java

示例2: createPartitionedRegion

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void createPartitionedRegion(String regionName) {
  final Cache cache = getCache();
  // Create the data region
  RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
  dataRegionFactory.setConcurrencyLevel(4);
  EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY);
  dataRegionFactory.setEvictionAttributes(ea);
  dataRegionFactory.setEnableAsyncConflation(true);
  
  FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par1", true);
  PartitionAttributes pa = new PartitionAttributesFactory()
                                  .setLocalMaxMemory(100)
                                  .setRecoveryDelay(2)
                                  .setTotalMaxMemory(200)
                                  .setRedundantCopies(1)
                                  .addFixedPartitionAttributes(fpa)
                                  .create();
  dataRegionFactory.setPartitionAttributes(pa);
  
  dataRegionFactory.create(regionName);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:22,代码来源:MemberCommandsDUnitTest.java

示例3: testAsyncIndexUpdaterThreadShutdownForPR

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testAsyncIndexUpdaterThreadShutdownForPR() {
  Cache cache = new CacheFactory().create();

  RegionFactory rf = cache.createRegionFactory(RegionShortcut.PARTITION);
  rf.setIndexMaintenanceSynchronous(false);
  Region localRegion = rf.create(name);
  
  assertNotNull("Region ref null", localRegion);
  
  try {
    cache.getQueryService().createIndex("idIndex", "ID", "/"+name);
  } catch (Exception e) {
    cache.close();
    e.printStackTrace();
    fail("Index creation failed");
  }
  
  for (int i=0; i<500; i++) {
    localRegion.put(i, new Portfolio(i));
  }

  GemFireCacheImpl internalCache = (GemFireCacheImpl)cache;
  // Don't disconnect distributed system yet to keep system thread groups alive.
  internalCache.close("Normal disconnect", null, false, false);

  // Get Asynchronous index updater thread group from Distributed System.
  ThreadGroup indexUpdaterThreadGroup = LogWriterImpl.getThreadGroup("QueryMonitor Thread Group");
  
  assertEquals(0, indexUpdaterThreadGroup.activeCount());

  internalCache.getSystem().disconnect();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:33,代码来源:AsyncIndexUpdaterThreadShutdownTest.java

示例4: createRegionsWithSubRegions

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void createRegionsWithSubRegions() {
  final Cache cache = getCache();
  
  RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
  dataRegionFactory.setConcurrencyLevel(3);
  Region<String, Integer> region1 = dataRegionFactory.create(REGION1);
  region1.createSubregion(SUBREGION1C, region1.getAttributes());
  Region<String, Integer> subregion2 = region1.createSubregion(SUBREGION1A, region1.getAttributes());
  
  subregion2.createSubregion(SUBREGION1B, subregion2.getAttributes());
  dataRegionFactory.create(REGION2);
  dataRegionFactory.create(REGION3);
  
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:16,代码来源:ListAndDescribeRegionDUnitTest.java

示例5: createParReg

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private Region<?,?> createParReg(String regionName, Cache cache, Class keyConstraint, Class valueConstraint ) {
  RegionFactory regionFactory = cache.createRegionFactory();
  regionFactory.setDataPolicy(DataPolicy.PARTITION);
  regionFactory.setKeyConstraint(keyConstraint);
  regionFactory.setValueConstraint(valueConstraint);
  return regionFactory.create(regionName);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:8,代码来源:IndexCommandsDUnitTest.java

示例6: 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);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:IndexCommandsDUnitTest.java

示例7: 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);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:IndexCommandsDUnitTest.java

示例8: createRegionsWithSubRegions

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void createRegionsWithSubRegions() {
  final Cache cache = getCache();
  
  RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
  dataRegionFactory.setConcurrencyLevel(3);
  Region<String, Integer> region1 = dataRegionFactory.create(REGION1);
  region1.createSubregion(SUBREGION1C, region1.getAttributes());
  Region<String, Integer> subregion2 = region1.createSubregion(SUBREGION1A, region1.getAttributes());
  
  subregion2.createSubregion(SUBREGION1B, subregion2.getAttributes());
  dataRegionFactory.create(REGION2);
  dataRegionFactory.create(REGION3);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:14,代码来源:MemberCommandsDUnitTest.java

示例9: getCreateServerCallable

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private Callable getCreateServerCallable(final String regionName, final boolean usePR) {
  return new SerializableCallable("create server and entries") {
    public Object call() {
      Cache cache = getCache();
      List<CacheServer> servers = cache.getCacheServers();
      CacheServer server;
      if (servers.size() > 0) {
        server = servers.get(0);
      } else {
        server = cache.addCacheServer();
        int port = AvailablePortHelper.getRandomAvailableTCPPort();
        server.setPort(port);
        server.setHostnameForClients("localhost");
        try {
          server.start();
        }
        catch (IOException e) {
          fail("Failed to start server ", e);
        }
      }
      if (usePR) {
        RegionFactory factory = cache.createRegionFactory(RegionShortcut.PARTITION);
        PartitionAttributesFactory pf = new PartitionAttributesFactory();
        pf.setTotalNumBuckets(2);
        factory.setPartitionAttributes(pf.create());
        factory.create(regionName);
      } else {
        cache.createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
      }
      return server.getPort();
    }
  };
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:34,代码来源:ClientServerInvalidAndDestroyedEntryDUnitTest.java

示例10: setupSystem

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void setupSystem() throws IOException {
  disconnectAllFromDS();
  final Host host = Host.getHost(0);
  final VM[] servers = { host.getVM(0), host.getVM(1) };

  final Properties propsMe = createProperties("me", "G1");
  final Properties propsServer1 = createProperties("Server1", "G1");
  final Properties propsServer2 = createProperties("Server2", "G2");
  
  
  getSystem(propsMe);
  final Cache cache = getCache();
  RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE_PROXY);
  dataRegionFactory.setConcurrencyLevel(5);
  Region<String, Integer> region1 = dataRegionFactory.create(REGION1);
  
  
  
  servers[1].invoke( new SerializableRunnable("Create cache for server1") {
    public void run() {
      getSystem(propsServer2);
      createRegionsWithSubRegions();
      createLocalRegion();
      createPartitionedRegion("ParReg1");
    }
  }) ;
  servers[0].invoke( new SerializableRunnable("Create cache for server0") {
    public void run() {
      getSystem(propsServer1);
      createRegionsWithSubRegions();
      createLocalRegion();
      
    }
    });
  
  
  
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:39,代码来源:MemberCommandsDUnitTest.java

示例11: createLocalSetUp

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void createLocalSetUp() {
  Properties localProps = new Properties();
  localProps.setProperty(DistributionConfig.NAME_NAME, "Controller");
  getSystem(localProps);
  Cache cache = getCache();
  RegionFactory<Integer, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
  Region region1 = dataRegionFactory.create("REGION1");
  Region region2 = dataRegionFactory.create("REGION2");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:10,代码来源:ShowMetricsDUnitTest.java

示例12: 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);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:DiskStoreCommandsDUnitTest.java

示例13: testAsyncIndexUpdaterThreadShutdownForRR

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testAsyncIndexUpdaterThreadShutdownForRR() {
  Cache cache = new CacheFactory().create();

  RegionFactory rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
  rf.setIndexMaintenanceSynchronous(false);
  Region localRegion = rf.create(name);
  
  assertNotNull("Region ref null", localRegion);
  
  try {
    cache.getQueryService().createIndex("idIndex", "ID", "/"+name);
  } catch (Exception e) {
    cache.close();
    e.printStackTrace();
    fail("Index creation failed");
  }
  
  for (int i=0; i<500; i++) {
    localRegion.put(i, new Portfolio(i));
  }
  
  GemFireCacheImpl internalCache = (GemFireCacheImpl)cache;
  // Don't disconnect distributed system yet to keep system thread groups alive.
  internalCache.close("Normal disconnect", null, false, false);

  // Get Asynchronous index updater thread group from Distributed System.
  ThreadGroup indexUpdaterThreadGroup = LogWriterImpl.getThreadGroup("QueryMonitor Thread Group");
  
  assertEquals(0, indexUpdaterThreadGroup.activeCount());
  
  internalCache.getSystem().disconnect();
  
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:34,代码来源:AsyncIndexUpdaterThreadShutdownTest.java

示例14: getRegionFactory

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected RegionFactory<Integer, String> getRegionFactory(Cache cache) {
  return cache.<Integer,String>createRegionFactory(RegionShortcut.PARTITION_PERSISTENT);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:4,代码来源:IncrementalBackupDUnitTest.java

示例15: createPartitionedRegion1

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void createPartitionedRegion1() {
    final Cache cache = getCache();
    // Create the data region
   RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
   dataRegionFactory.create(PR1);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:7,代码来源:ListAndDescribeRegionDUnitTest.java


注:本文中的com.gemstone.gemfire.cache.Cache.createRegionFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。