• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DataPolicy类的典型用法和代码示例

java 2次浏览

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

DataPolicy类属于com.gemstone.gemfire.cache包,在下文中一共展示了DataPolicy类的39个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doCompactionStep

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/** For those regions that are persistent, force compaction.
 * 
 */
private synchronized void doCompactionStep() {
  int coord = compactionCoordinator.incrementAndGet();
  if (coord == 1) { // this is the one thread in this vm to do compaction
    for (Region aRegion: allRegions) {
      DataPolicy dataPolicy = aRegion.getAttributes().getDataPolicy();
      if (dataPolicy.withPersistence() && dataPolicy.withReplication()) {
        Log.getLogWriter().info("Causing compaction of disk files for region " + aRegion.getFullPath());
        long startTime = System.currentTimeMillis();
        boolean compactionResult = ((LocalRegion)aRegion).getDiskStore().forceCompaction();
        long duration = System.currentTimeMillis() - startTime;
        Log.getLogWriter().info("Done with compaction of disk files for region " + aRegion.getFullPath() +", compaction took " +
            duration + " ms");
        if (!compactionResult) {
          throw new TestException("forceCompaction returned " + compactionResult + " for " + aRegion.getFullPath());
        }
      }
    }
    RecoveryBB.getBB().getSharedCounters().increment(RecoveryBB.doneCompactingCounter);
  } else {
    TestHelper.waitForCounter(RecoveryBB.getBB(), 
        "RecoverBB.doneCompactingCounter", RecoveryBB.doneCompactingCounter, 
        TestHelper.getNumVMs() - 1, true, -1, 10000);
  }
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:28,
代码来源:RecoveryTest.java

示例2: createOverflowRegion

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的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);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:21,
代码来源:BackupDUnitTest.java

示例3: testIsRegionPersistentWhenDataPolicyIsPersistentPartition

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
@Test
public void testIsRegionPersistentWhenDataPolicyIsPersistentPartition() {
  final Region mockRegion = mockContext.mock(Region.class, "Region");
  final RegionAttributes mockRegionAttributes = mockContext.mock(RegionAttributes.class, "RegionAttributes");

  mockContext.checking(new Expectations() {{
    oneOf(mockRegion).getAttributes();
    will(returnValue(mockRegionAttributes));
    oneOf(mockRegionAttributes).getDataPolicy();
    will(returnValue(DataPolicy.PERSISTENT_PARTITION));
  }});

  final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);

  assertTrue(function.isPersistent(mockRegion));
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:17,
代码来源:DescribeDiskStoreFunctionJUnitTest.java

示例4: initRegion

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/** Initialize a region with the desired attributes. Initialize instance
 *  fields for this instance. 
 */
protected void initRegion(DataPolicy dataPolicy) {
   CacheLoader loader = getCacheLoader();
   RegionDefinition regDef = RegionDefinition.createRegionDefinition();

   regDef.setDataPolicy(dataPolicy);

   Log.getLogWriter().info("Using RegionDefinition " + regDef + " to create region");


   aRegion = regDef.createRootRegion(CacheUtil.createCache(), REGION_NAME, 
                                     null, loader, null);
   if ((dataPolicy.equals(DataPolicy.NORMAL)) || 
       (dataPolicy.equals(DataPolicy.EMPTY))) {
      supportsConcurrentMap = false;
   } 
   sleepMSAfterOps = 30000;
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:21,
代码来源:InitImageTest.java

示例5: createCacheServerWithDR

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public static Integer createCacheServerWithDR() {
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.DISTRIBUTED_ACK);
  factory.setDataPolicy(DataPolicy.REPLICATE);
  assertNotNull(cache);
  Region region = cache.createRegion(regionName, factory.create());
  assertNotNull(region);
  
  CacheServer server1 = cache.addCacheServer();
  assertNotNull(server1);
  int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
  server1.setPort(port);
  try {
    server1.start();
  }       
  catch (IOException e) {
    fail("Failed to start the Server", e);
  }
  assertTrue(server1.isRunning());

  return new Integer(server1.getPort());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:23,
代码来源:PRClientServerTestBase.java

示例6: test46976

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public void test46976() throws Exception {
  getConnection(new Properties());
  Cache cache = Misc.getGemFireCache();
  AttributesFactory fact = new AttributesFactory();
  fact.setDataPolicy(DataPolicy.PARTITION);
  PartitionedRegion pr = (PartitionedRegion)cache.createRegion("myPR",
                          fact.create());
  //PartitionedRegion pr = (PartitionedRegion)cache.createRegionFactory(
  //                    RegionShortcut.PARTITION).create("myPR");
  pr.put(1, "one");
  pr.invalidate(1);
  Set<Integer> buckets = new HashSet<Integer>();
  buckets.add(1);
  LocalDataSet lds = new LocalDataSet(pr, buckets, null/*txState*/);
  assertTrue(lds.get(1)==null);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:17,
代码来源:BugsTest.java

示例7: createRegionsOnVm1

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void createRegionsOnVm1() {
  new MultiRegionFunctionExecutionDUnitTest("temp").createCache();   
      
  PartitionAttributesFactory pf = new PartitionAttributesFactory();
  pf.setTotalNumBuckets(12);
  pf.setRedundantCopies(1);
  AttributesFactory factory = new AttributesFactory();
  factory.setPartitionAttributes(pf.create());
  cache.createRegion("PR1", factory.create());   
  
  factory = new AttributesFactory();
  factory.setDataPolicy(DataPolicy.NORMAL);
  cache.createRegion("RR1", factory.create());
  
  factory = new AttributesFactory();
  factory.setDataPolicy(DataPolicy.REPLICATE);
  cache.createRegion("RR2", factory.create());    
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:20,
代码来源:MultiRegionFunctionExecutionDUnitTest.java

示例8: createPersistentRegionAsync

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的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);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:32,
代码来源:DiskManagementDUnitTest.java

示例9: testDistributedRegionFunctionExecutionOnDataPolicyReplicate_SendException

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public void testDistributedRegionFunctionExecutionOnDataPolicyReplicate_SendException() {
  createCacheInVm(); // Empty
  normal.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createCacheInVm");
  replicate1.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createCacheInVm");
  replicate2.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createCacheInVm");
  replicate3.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createCacheInVm");

  createPeer(DataPolicy.EMPTY);
  populateRegion();
  normal.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createPeer", new Object[] { DataPolicy.NORMAL });
  replicate1.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createPeer", new Object[] { DataPolicy.REPLICATE });
  replicate2.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createPeer", new Object[] { DataPolicy.REPLICATE });
  replicate3.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createPeer", new Object[] { DataPolicy.REPLICATE });
  replicate1.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "executeFunction_SendException");
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:25,
代码来源:DistributedRegionFunctionExecutionDUnitTest.java

示例10: createServerCache

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public static Integer createServerCache() throws Exception
{
  new HABugInPutDUnitTest("temp").createCache(new Properties());
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.DISTRIBUTED_ACK);
  factory.setDataPolicy(DataPolicy.REPLICATE);
  RegionAttributes attrs = factory.create();
  cache.createRegion(REGION_NAME, attrs);
  BridgeServerImpl server = (BridgeServerImpl)cache.addBridgeServer();
  assertNotNull(server);
  int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
  server.setPort(port);
  server.setNotifyBySubscription(false);
  server.start();
  return new Integer(server.getPort());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:17,
代码来源:HABugInPutDUnitTest.java

示例11: createLonerServerRegion

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
private int createLonerServerRegion(VM vm, final String regionName, final String dsId) {
  SerializableCallable createRegion = new SerializableCallable() {
    public Object call() throws Exception {
      Properties props = new Properties();
      props.setProperty("locators", "");
      props.setProperty(DistributionConfig.DISTRIBUTED_SYSTEM_ID_NAME, dsId);
      getSystem(props);
      AttributesFactory af = new AttributesFactory();
      af.setScope(Scope.DISTRIBUTED_ACK);
      af.setDataPolicy(DataPolicy.REPLICATE);
      createRootRegion(regionName, af.create());

      CacheServer server = getCache().addCacheServer();
      int port = AvailablePortHelper.getRandomAvailableTCPPort();
      server.setPort(port);
      server.start();
      return port;
    }
  };

  return (Integer) vm.invoke(createRegion);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:23,
代码来源:PdxClientServerDUnitTest.java

示例12: createClient_41367

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public static void createClient_41367(Integer port1) {
  CacheServerTestUtil.disableShufflingOfEndpoints();
  Pool p;
  try {
    p = PoolManager.createFactory().addServer("localhost", port1.intValue())
        .setPingInterval(3000).setSubscriptionEnabled(false)
        .setSubscriptionRedundancy(-1).setReadTimeout(2000)
        .setSocketBufferSize(1000).setMinConnections(1).setMaxConnections(1)
        .setRetryAttempts(2).create(
            "DistributedRegionFunctionExecutionDUnitTest_pool");
  }
  finally {
    CacheServerTestUtil.enableShufflingOfEndpoints();
  }
  AttributesFactory factory = new AttributesFactory();
  factory.setDataPolicy(DataPolicy.EMPTY);
  factory.setPoolName(p.getName());
  assertNotNull(cache);
  region = cache.createRegion(REGION_NAME, factory.create());
  getLogWriter().info("Client Region Created :" + region);
  assertNotNull(region);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:23,
代码来源:DistributedRegionFunctionExecutionDUnitTest.java

示例13: createSelfRolePlayingVm

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/**
 * Create a cache which playes the role of "rolePlayerA" which is required
 * by the region created in this cache.
 * 
 * @throws Exception
 * */
public static void createSelfRolePlayingVm()throws Exception{
	Cache cache = CacheUtil.createCache();
	String requiredRoles[] = new String[] {"rolePlayerA"};
	MembershipAttributes  ra = new MembershipAttributes (requiredRoles,
            LossAction.RECONNECT, ResumptionAction.NONE);
	AttributesFactory fac = new AttributesFactory();
	fac.setMembershipAttributes(ra);
	fac.setScope(Scope.DISTRIBUTED_ACK);
       fac.setDataPolicy(DataPolicy.REPLICATE);

       RegionAttributes attr = fac.createRegionAttributes();
       Region region = CacheUtil.createRegion(regionNameA, attr);
       generateXml(cache);
       
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:22,
代码来源:SustainabilityTest.java

示例14: createRegionsOnVm0

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void createRegionsOnVm0() {
  new MultiRegionFunctionExecutionDUnitTest("temp").createCache();  

  PartitionAttributesFactory pf = new PartitionAttributesFactory();
  pf.setTotalNumBuckets(12);
  pf.setRedundantCopies(1);
  AttributesFactory factory = new AttributesFactory();
  factory.setPartitionAttributes(pf.create());
  cache.createRegion("PR1", factory.create());   
  
  factory = new AttributesFactory();
  factory.setDataPolicy(DataPolicy.REPLICATE);
  cache.createRegion("RR1", factory.create());
  
  factory = new AttributesFactory();
  factory.setDataPolicy(DataPolicy.EMPTY);
  cache.createRegion("RR2", factory.create());    
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:20,
代码来源:MultiRegionFunctionExecutionDUnitTest.java

示例15: createCacheClient

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/**
 * create client cache
 *
 * @param port1
 * @param port2 - end points ports
 */
public static void createCacheClient(Integer port1, String host)
    throws Exception {
  Properties props = new Properties();
  props.setProperty("mcast-port", "0");
  props.setProperty("locators", "");
  new HAOverflowMemObjectSizerDUnitTest("temp").createCache(props);
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.DISTRIBUTED_ACK);
  factory.setDataPolicy(DataPolicy.NORMAL);
  BridgeTestCase.configureConnectionPool(factory, host, port1.intValue(), -1, true, -1, 2, null, -1, -1, false);
  RegionAttributes attrs = factory.create();
  Region region = cache.createRegion(regionName, attrs);
  assertNotNull(region);
  region.registerInterest("ALL_KEYS");
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:22,
代码来源:HAOverflowMemObjectSizerDUnitTest.java

示例16: testIndexOnCommitForPut

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/**
 * verify that queries on indexes work with transaction
 * @see bug#40842
 * @throws Exception
 */
public void testIndexOnCommitForPut() throws Exception {
  AttributesFactory af = new AttributesFactory();
  af.setDataPolicy(DataPolicy.REPLICATE);
  Region region = cache.createRegion("sample", af.create());
  qs.createIndex("foo", IndexType.FUNCTIONAL, "age", "/sample");
  Context ctx = cache.getJNDIContext();
  UserTransaction utx = (UserTransaction)ctx.lookup("java:/UserTransaction");
  Integer x = new Integer(0);
  utx.begin();
  region.create(x, new Person("xyz", 45));
  utx.commit();
  Query q = qs.newQuery("select * from /sample where age < 50");
  assertEquals(1, ((SelectResults)q.execute()).size());
  Person dsample = (Person)CopyHelper.copy(region.get(x));
  dsample.setAge(55);
  utx.begin();
  region.put(x, dsample);
  utx.commit();
  System.out.println((region.get(x)));
  assertEquals(0, ((SelectResults) q.execute()).size());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:27,
代码来源:QueryAndJtaTest.java

示例17: testPARTITION_REDUNDANT_HEAP_LRU

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public void testPARTITION_REDUNDANT_HEAP_LRU() throws CacheException {
  CacheCreation cache = new CacheCreation();
  RegionCreation root = (RegionCreation)
    cache.createRegion("rpartitionlru", "PARTITION_REDUNDANT_HEAP_LRU");
  testXml(cache);
  GemFireCacheImpl c = (GemFireCacheImpl) getCache();
  Region r = c.getRegion("rpartitionlru");
  assertNotNull(r);
  RegionAttributes ra = r.getAttributes();
  assertEquals(DataPolicy.PARTITION, ra.getDataPolicy());
  assertNotNull(ra.getPartitionAttributes());
  assertEquals(1, ra.getPartitionAttributes().getRedundantCopies());
  assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes());
  assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE,
               c.getResourceManager().getEvictionHeapPercentage());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:17,
代码来源:CacheXml65Test.java

示例18: createExporter

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
static <K, V> Exporter<K, V> createExporter(Region<?, ?> region, SnapshotOptions<K, V> options) {
  String pool = region.getAttributes().getPoolName();
  if (pool != null) {
    return new ClientExporter<K, V>(PoolManager.find(pool));
    
  } else if (InternalDistributedSystem.getAnyInstance().isLoner()
      || region.getAttributes().getDataPolicy().equals(DataPolicy.NORMAL)
      || region.getAttributes().getDataPolicy().equals(DataPolicy.PRELOADED)
      || region instanceof LocalDataSet
      || (((SnapshotOptionsImpl<K, V>) options).isParallelMode() 
          && region.getAttributes().getDataPolicy().withPartitioning())) {
    
    // Avoid function execution:
    //    for loner systems to avoid inlining fn execution
    //    for NORMAL/PRELOAD since they don't support fn execution
    //    for LocalDataSet since we're already running a fn
    //    for parallel ops since we're already running a fn
    return new LocalExporter<K, V>();
  }
  
  return new WindowedExporter<K, V>();
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:23,
代码来源:RegionSnapshotServiceImpl.java

示例19: testReplicateRegion

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/**
 * Sanity check using two peers sharing a replicated region.
 * @throws Exception
 */
public void testReplicateRegion() throws Exception {
  Compressor compressor = null;
  try {
    compressor = SnappyCompressor.getDefaultInstance();
  } catch (Throwable t) {
    // Not a supported OS
    return;
  }
  assertTrue(createCompressedRegionOnVm(getVM(0), REGION_NAME, DataPolicy.REPLICATE, compressor));
  assertTrue(createCompressedRegionOnVm(getVM(1), REGION_NAME, DataPolicy.REPLICATE, compressor));
  assertNull(putUsingVM(getVM(0),KEY_1,VALUE_1));
  waitOnPut(getVM(1),KEY_1);
  assertEquals(VALUE_1,getUsingVM(getVM(1), KEY_1));
  cleanup(getVM(0));          
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:20,
代码来源:CompressionRegionConfigDUnitTest.java

示例20: createServerCache

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public static Integer createServerCache(Boolean isListenerPresent)
    throws Exception
{
  new HAConflationDUnitTest("temp").createCache(new Properties());
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.DISTRIBUTED_ACK);
  factory.setEnableConflation(true);
  factory.setDataPolicy(DataPolicy.REPLICATE);
  if (isListenerPresent.booleanValue() == true) {
    CacheListener serverListener = new HAClientCountEventListener();
    factory.setCacheListener(serverListener);
  }
  RegionAttributes attrs = factory.create();
  cache.createRegion(regionName, attrs);
  BridgeServerImpl server = (BridgeServerImpl)cache.addBridgeServer();
  assertNotNull(server);
  int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
  server.setPort(port);
  server.setNotifyBySubscription(true);
  server.start();
  return new Integer(server.getPort());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:23,
代码来源:HAConflationDUnitTest.java

示例21: testReplicatePersistentRegion

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/**
 * Sanity check for two peers sharing a persisted replicated region.
 * @throws Exception
 */
public void testReplicatePersistentRegion() throws Exception {
  Compressor compressor = null;
  try {
    compressor = SnappyCompressor.getDefaultInstance();
  } catch (Throwable t) {
    // Not a supported OS
    return;
  }
  assertTrue(createCompressedRegionOnVm(getVM(0), REGION_NAME, DataPolicy.PERSISTENT_REPLICATE, compressor, DISK_STORE));
  assertTrue(createCompressedRegionOnVm(getVM(1), REGION_NAME, DataPolicy.PERSISTENT_REPLICATE, compressor));
  assertNull(putUsingVM(getVM(0),KEY_1,VALUE_1));
  waitOnPut(getVM(1),KEY_1);  
  flushDiskStoreOnVM(getVM(0), DISK_STORE);     
  closeRegionOnVM(getVM(1), REGION_NAME);
  assertTrue(createCompressedRegionOnVm(getVM(1), REGION_NAME, DataPolicy.PERSISTENT_REPLICATE, compressor));
  assertEquals(VALUE_1,getUsingVM(getVM(1), KEY_1));
  cleanup(getVM(0));
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:23,
代码来源:CompressionRegionConfigDUnitTest.java

示例22: createRegion

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public static void createRegion(CacheLoader cacheLoader, CacheWriter cacheWriter, Integer localMaxMemory) {
  try {
    new PartitionedRegionLoaderWriterDUnitTest("DUnitTests")
        .createCache(new Properties());
    AttributesFactory factory = new AttributesFactory();
    factory.setCacheLoader(cacheLoader);
    factory.setCacheWriter(cacheWriter);
    PartitionAttributesFactory paf = new PartitionAttributesFactory();
    paf.setLocalMaxMemory(localMaxMemory.intValue());
    factory.setDataPolicy(DataPolicy.PARTITION);
    factory.setPartitionAttributes(paf.create());
    RegionAttributes attrs = factory.create();
    cache.createRegion(PartitionedRegionName, attrs);
  }
  catch (Exception e) {
    fail("Not Expected : " , e);
  }
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:19,
代码来源:PartitionedRegionLoaderWriterDUnitTest.java

示例23: testIsRegionUsingDiskStoreWhenDiskStoresMismatch

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
@Test
public void testIsRegionUsingDiskStoreWhenDiskStoresMismatch() {
  final Region mockRegion = mockContext.mock(Region.class, "Region");
  final RegionAttributes mockRegionAttributes = mockContext.mock(RegionAttributes.class, "RegionAttributes");
  final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");

  mockContext.checking(new Expectations() {{
    atLeast(1).of(mockRegion).getAttributes();
    will(returnValue(mockRegionAttributes));
    oneOf(mockRegionAttributes).getDataPolicy();
    will(returnValue(DataPolicy.PERSISTENT_PARTITION));
    oneOf(mockRegionAttributes).getDiskStoreName();
    will(returnValue("mockDiskStore"));
    oneOf(mockDiskStore).getName();
    will(returnValue("testDiskStore"));
  }});

  final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);

  assertFalse(function.isUsingDiskStore(mockRegion, mockDiskStore));
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:22,
代码来源:DescribeDiskStoreFunctionJUnitTest.java

示例24: createPersistentRegionAsync

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的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);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:21,
代码来源:PersistentReplicatedTestBase.java

示例25: createCacheAndPopulateRegion1

点赞 3

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public static void createCacheAndPopulateRegion1() {
  try {
    ds = (new Bug33726DUnitTest("temp")).getSystem(new Properties());
    cache = CacheFactory.create(ds);
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.GLOBAL);
    factory.setDataPolicy(DataPolicy.REPLICATE);
    RegionAttributes attr = factory.create();
    Region region = cache.createRegion("testRegion", attr);
    Region subRegion = region.createSubregion("testSubRegion",attr);
    for(int i=1; i < 100; i++){
      region.put(new Integer(i), new Integer(i));      
      subRegion.put(new Integer(i), new Integer(i));
    }
   }
  catch (Exception ex) {
    fail("Creation of cache failed due to "+ex);
    ex.printStackTrace();
  }
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:21,
代码来源:Bug33726DUnitTest.java

示例26: putKeysValuesRegionF

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/**
 * Puts multiple keys value pair in RegionF.
 * */
public static void putKeysValuesRegionF() throws Exception{
	Cache cache = CacheUtil.createCache();
	AttributesFactory fac = new AttributesFactory();
       fac.setScope(Scope.DISTRIBUTED_ACK);
       fac.setDataPolicy(DataPolicy.REPLICATE);

       RegionAttributes attr = fac.createRegionAttributes();
       Region region = CacheUtil.createRegion(regionNameF, attr);
       putKeysValues(region);
       
   }
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:15,
代码来源:SustainabilityTest.java

示例27: createRR

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
private void createRR(VM vm) {
  vm.invoke(new SerializableRunnable("Create rr") {
    public void run() {
      Cache cache = getCache();
      AttributesFactory<Integer, TestDelta> attr = new AttributesFactory<Integer, TestDelta>();
      attr.setDiskSynchronous(true);
      attr.setDataPolicy(DataPolicy.REPLICATE);
      attr.setScope(Scope.DISTRIBUTED_ACK);
      attr.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(1, new TestObjectSizer(), EvictionAction.OVERFLOW_TO_DISK));
      attr.setDiskDirs(getMyDiskDirs());
      Region region = cache.createRegion("region", attr.create());
    }
  });
  
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:16,
代码来源:SizingFlagDUnitTest.java

示例28: testSYSSCHEMAS

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public void testSYSSCHEMAS() throws Exception {
  setupConnection();
  sqlExecute("CREATE SCHEMA EMP DEFAULT SERVER GROUPS (SG1)",
      Boolean.TRUE /* use prep statement */);

  RegionAttributesCreation expectedAttrs = new RegionAttributesCreation();
  expectedAttrs.setScope(Scope.DISTRIBUTED_NO_ACK);
  expectedAttrs.setDataPolicy(DataPolicy.EMPTY);
  expectedAttrs.setConcurrencyChecksEnabled(false);
  expectedAttrs.setAllHasFields(true);
  expectedAttrs.setHasDiskDirs(false);
  expectedAttrs.setHasDiskWriteAttributes(false);
  // Test the schema region attributes on client
  verifyRegionProperties("EMP", null, TestUtil
      .regionAttributesToXML(expectedAttrs));

  // Check for both index and non-index lookup in SYSSCHEMAS

  // Test the fields from SYSSCHEMAS on client with index lookup
  sqlExecuteVerifyText("SELECT SCHEMANAME,"
      + " DEFAULTSERVERGROUPS FROM SYS.SYSSCHEMAS WHERE SCHEMANAME='EMP'",
      TestUtil.getResourcesDir() + "/lib/checkSchema.xml",
      "emp_sg", Boolean.TRUE /* use prep statement */,
      Boolean.FALSE /* do not check for type info */);

  // Test the fields from SYSSCHEMAS on client with non-index table scan
  sqlExecuteVerifyText(
      "SELECT SCHEMANAME, DEFAULTSERVERGROUPS FROM SYS.SYSSCHEMAS "
          + "WHERE DEFAULTSERVERGROUPS='SG1'", getResourcesDir()
          + "/lib/checkSchema.xml", "emp_sg",
      Boolean.TRUE /* use prep statement */,
      Boolean.FALSE /* do not check for type info */);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:34,
代码来源:CreateSchemaTest.java

示例29: testPARTITION_REDUNDANT_PERSISTENT

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public void testPARTITION_REDUNDANT_PERSISTENT() throws CacheException {
  CacheCreation cache = new CacheCreation();
  RegionCreation root = (RegionCreation)
    cache.createRegion("prpartition", "PARTITION_REDUNDANT_PERSISTENT");
  testXml(cache);
  GemFireCacheImpl c = (GemFireCacheImpl) getCache();
  Region r = c.getRegion("prpartition");
  assertNotNull(r);
  RegionAttributes ra = r.getAttributes();
  assertEquals(DataPolicy.PERSISTENT_PARTITION, ra.getDataPolicy());
  assertNotNull(ra.getPartitionAttributes());
  assertEquals(1, ra.getPartitionAttributes().getRedundantCopies());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:14,
代码来源:CacheXml65Test.java

示例30: testREPLICATE_PROXY

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public void testREPLICATE_PROXY() throws CacheException {
  CacheCreation cache = new CacheCreation();
  RegionCreation root = (RegionCreation)
    cache.createRegion("replicateProxy", "REPLICATE_PROXY");
  testXml(cache);
  GemFireCacheImpl c = (GemFireCacheImpl) getCache();
  Region r = c.getRegion("replicateProxy");
  assertNotNull(r);
  RegionAttributes ra = r.getAttributes();
  assertEquals(DataPolicy.EMPTY, ra.getDataPolicy());
  assertEquals(Scope.DISTRIBUTED_ACK, ra.getScope());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:13,
代码来源:CacheXml65Test.java

示例31: mkdir_s

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
private void mkdir_s(String command) throws Exception
{
	LinkedList list = new LinkedList();
	gfsh.parseCommand(command, list);
	String regionPath = "";
	String attributes;
	RegionAttributeInfo attributeInfo = null;
	if (list.size() == 2) {
		regionPath = gfsh.getCurrentPath();
	} else {
     if (!"/".equals(gfsh.getCurrentPath())) {
       regionPath = gfsh.getCurrentPath();
     }
		regionPath = regionPath + "/" + (String) list.get(2);
		attributes = "";
		for (int i = 3; i < list.size(); i++) {
			attributes += list.get(i) + " ";
		}
		attributeInfo = parseAttributes(attributes);
	}
	
	if (regionPath.equals(gfsh.getCurrentPath())) {
		gfsh.println("Error: must define region path: mkdir [-s] <regionPath>");
	} else {
		// create for the server only
		CommandResults commandResults = gfsh.getCommandClient().execute(new RegionCreateTask(regionPath, attributeInfo));
		MemberInfo memberInfo = (MemberInfo)commandResults.getDataObject();
		gfsh.print(memberInfo.getMemberName() + "(" + memberInfo.getMemberId() + ")" + ": ");
		if (commandResults.getCode() == RegionCreateTask.SUCCESS_CREATED) {
			Region region = RegionUtil.getRegion(regionPath, Scope.LOCAL, DataPolicy.NORMAL, null);
			gfsh.println("region created: " + region.getFullPath());
		} else {
			gfsh.println("error - " + commandResults.getCodeMessage());
		}
	}
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:37,
代码来源:mkdir.java

示例32: createServerCache

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public static Integer createServerCache() throws Exception
{
  new Bug36457DUnitTest("temp").createCache(new Properties());
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.DISTRIBUTED_ACK);
  factory.setDataPolicy(DataPolicy.REPLICATE);
  RegionAttributes attrs = factory.create();
  cache.createRegion(regionName, attrs);
  int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
  BridgeServer server1 = cache.addBridgeServer();
  server1.setPort(port);
  server1.setNotifyBySubscription(true);
  server1.start();
  return new Integer(server1.getPort());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:16,
代码来源:Bug36457DUnitTest.java

示例33: initMessagePart

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
@Override
protected void initMessagePart() {
  int size = map.size();
  int flags = 0;
  if (region.getDataPolicy() == DataPolicy.EMPTY) {
    flags |= FLAG_EMPTY;
  }
  if (region.getConcurrencyChecksEnabled()) {
    flags |= FLAG_CONCURRENCY_CHECKS;
  }
  getMessage().addIntPart(flags);
  getMessage().addIntPart(size);
  this.keys = new ArrayList(size);
  Iterator iterator = map.entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry mapEntry = (Map.Entry)iterator.next();
    Object key = mapEntry.getKey();
    this.keys.add(key);
    getMessage().addStringOrObjPart(key);
    Object value = mapEntry.getValue();
    if (value instanceof CachedDeserializable) {
      if (value instanceof StoredObject && !((StoredObject) value).isSerialized()) {
        // it is a byte[]
        getMessage().addObjPart(((StoredObject) value).getDeserializedForReading());
      } else {
        Object cdValue = ((CachedDeserializable)value).getValue();
        if (cdValue instanceof byte[]) {
          getMessage().addRawPart((byte[])cdValue, true);
        } else {
          getMessage().addObjPart(cdValue);
        }
      }
    } else {
      getMessage().addObjPart(value);
    }
  }      
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:38,
代码来源:PutAllOp.java

示例34: testCacheServerEnableTcpNoDelay

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public void testCacheServerEnableTcpNoDelay()
    throws CacheException
{
  CacheCreation cache = new CacheCreation();

  CacheServer cs = cache.addCacheServer();
  cs.setTcpNoDelay(true);
  RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
  attrs.setDataPolicy(DataPolicy.NORMAL);
  cache.createVMRegion("rootNORMAL", attrs);
  testXml(cache);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:13,
代码来源:CacheXml75Test.java

示例35: testBug40714

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public void testBug40714() {
  VM empty = replicate3;
  normal.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createCacheInVm");
  empty.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createCacheInVm");
  replicate1.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createCacheInVm");
  replicate2.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createCacheInVm");

  Integer port1 = (Integer)replicate1.invoke(
      DistributedRegionFunctionExecutionDUnitTest.class, "createServer",
      new Object[] { DataPolicy.REPLICATE });
  Integer port2 = (Integer)replicate2.invoke(
      DistributedRegionFunctionExecutionDUnitTest.class, "createServer",
      new Object[] { DataPolicy.REPLICATE });
  normal.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createPeer", new Object[] { DataPolicy.REPLICATE });
  empty.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "createPeer", new Object[] { DataPolicy.REPLICATE });

  normal.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "registerFunction");
  empty.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "registerFunction");
  replicate1.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "registerFunction");
  replicate2.invoke(DistributedRegionFunctionExecutionDUnitTest.class,
      "registerFunction");
  createCacheInVm();
  createClientAndPopulateClientRegion(DataPolicy.EMPTY, port1, port2);

  registerFunction();
  executeInlineFunction();

}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:38,
代码来源:DistributedRegionFunctionExecutionDUnitTest.java

示例36: bug41118

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
public static void bug41118(){
  InternalDistributedSystem ds = new DistributedRegionFunctionExecutionDUnitTest("temp").getSystem();
  assertNotNull(ds);
  ds.disconnect();
  Properties props = new Properties();
  props.setProperty("mcast-port", "0");
  ds = (InternalDistributedSystem)DistributedSystem.connect(props);
  
  DM dm = ds.getDistributionManager();
  assertEquals("Distributed System is not loner", true, dm instanceof LonerDistributionManager);
  
  Cache cache = CacheFactory.create(ds);
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.LOCAL);
  factory.setDataPolicy(DataPolicy.REPLICATE);
  assertNotNull(cache);
  region = cache.createRegion(REGION_NAME, factory.create());
  try {
    executeInlineFunction();
    ds.disconnect();
  }
  catch (Exception e) {
    getLogWriter().info("Exception Occured : " + e.getMessage());
    e.printStackTrace();
    fail("Test failed", e);
  }
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:28,
代码来源:DistributedRegionFunctionExecutionDUnitTest.java

示例37: createRegionsOnVm3

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void createRegionsOnVm3() {
  new MultiRegionFunctionExecutionDUnitTest("temp").createCache();   
      
  PartitionAttributesFactory pf = new PartitionAttributesFactory();
  pf.setTotalNumBuckets(12);
  pf.setRedundantCopies(1);
  AttributesFactory factory = new AttributesFactory();
  factory.setPartitionAttributes(pf.create());
  cache.createRegion("PR1", factory.create());   
  
  
  pf = new PartitionAttributesFactory();
  pf.setTotalNumBuckets(12);
  pf.setRedundantCopies(1);
  factory = new AttributesFactory();
  factory.setPartitionAttributes(pf.create());
  cache.createRegion("PR2", factory.create());
  
  factory = new AttributesFactory();
  factory.setDataPolicy(DataPolicy.REPLICATE);
  cache.createRegion("RR1", factory.create());
  
  factory = new AttributesFactory();
  factory.setDataPolicy(DataPolicy.REPLICATE);
  cache.createRegion("RR2", factory.create());    
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:28,
代码来源:MultiRegionFunctionExecutionDUnitTest.java

示例38: createRegion

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/**
 * create a client with 2 regions sharing a common writer
 *
 * @throws Exception
 */

public static void createRegion() throws Exception
{
  HARegionQueueDUnitTest test = new HARegionQueueDUnitTest(
      "HARegionQueueDUnitTest_region");
  cache = test.createCache();
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.DISTRIBUTED_ACK);
  factory.setDataPolicy(DataPolicy.REPLICATE);
  HARegion.getInstance("HARegionQueueDUnitTest_region", (GemFireCacheImpl)cache,
      null, factory.create());
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:18,
代码来源:HARegionQueueDUnitTest.java

示例39: createRolePlayerFVm

点赞 2

import com.gemstone.gemfire.cache.DataPolicy; //导入依赖的package包/类
/**
 * Creats a vm playing a role "rolePlayerF". The roles parameter
 * is defined in the conf file for the test by specifing hydra.GemFirePrms-roles
 * property for all the vms.
 * 
 * */
public static void createRolePlayerFVm(){
	Cache cache = CacheUtil.createCache();
       AttributesFactory fac = new AttributesFactory();
       fac.setScope(Scope.DISTRIBUTED_ACK);
       fac.setDataPolicy(DataPolicy.REPLICATE);

       RegionAttributes attr = fac.createRegionAttributes();
       Region region = CacheUtil.createRegion(regionNameF, attr);
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:16,
代码来源:SustainabilityTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)