private void createRegion() {
   String regionName = GemFireCachePrms.getRegionName();
   String regionConfig = ConfigPrms.getRegionConfig();
   if (RegionHelper.getRegion(regionName) == null) {
     RegionHelper.createRegion(regionName, regionConfig);
   }
   Region region = RegionHelper.getRegion(regionName);
   EdgeHelper.addThreadLocalConnection(region);
 }
 /**
  * Set a random DiskStore for the region defined with regionConfigName if it is persistent or has
  * eviction with overflow to disk.
  *
  * @param regionConfigName A hydra region config name. return factory The attributes factory for
  *     the regionConfigName with possibly a DiskStore.
  */
 public static AttributesFactory setDiskStoreIfNeeded(String regionConfigName) {
   AttributesFactory factory = RegionHelper.getAttributesFactory(regionConfigName);
   RegionDescription desc = RegionHelper.getRegionDescription(regionConfigName);
   EvictionAttributes evAttr = desc.getEvictionAttributes();
   if ((desc.getDataPolicy().withPersistence())
       || ((evAttr != null) && (evAttr.getAction().isOverflowToDisk()))) {
     List diskStoreNames = TestConfig.tab().vecAt(DiskStorePrms.names);
     factory.setDiskStoreName(
         (String)
             (diskStoreNames.get(
                 TestConfig.tab().getRandGen().nextInt(1, diskStoreNames.size() - 1))));
   }
   return factory;
 }
Пример #3
0
 /**
  * Create a region with the given region description name.
  *
  * @param regDescriptName The name of a region description.
  */
 protected void initializeRegion(String regDescriptName) {
   CacheHelper.createCache("cache1");
   String key = VmIDStr + RemoteTestModule.getMyVmid();
   String xmlFile = key + ".xml";
   try {
     CacheHelper.generateCacheXmlFile("cache1", regDescriptName, xmlFile);
   } catch (HydraRuntimeException e) {
     if (e.toString().indexOf("Cache XML file was already created") >= 0) {
       // this can occur when reinitializing after a stop-start because
       // the cache xml file is written during the first init tasks
     } else {
       throw new TestException(TestHelper.getStackTrace(e));
     }
   }
   aRegion = RegionHelper.createRegion(regDescriptName);
 }
 private void createDataInRegion() {
   String regionName = GemFireCachePrms.getRegionName();
   Region region = RegionHelper.getRegion(regionName);
   if (this.useTransactions) {
     this.begin();
   }
   do {
     int key = getNextKey();
     executeTaskTerminator(); // commits at task termination
     executeWarmupTerminator(); // commits at warmup termination
     createInRegion(key, region);
     ++this.batchCount;
     ++this.count;
     ++this.keyCount;
     ++this.iterationsSinceTxEnd;
   } while (!executeBatchTerminator()); // commits at batch termination
 }
 /** Creates and initializes a server or peer. */
 public static synchronized void HydraTask_initializeExpectException() throws Throwable {
   if (RecoveryTest.testInstance == null) {
     RecoveryTest.testInstance = new RecoveryTest();
     int numRootRegions = RecoveryPrms.getNumRootRegions();
     int numSubregions = RecoveryPrms.getNumSubregions();
     int hierDepth = RecoveryPrms.getRegionHierarchyDepth();
     if ((numSubregions != 0) || (hierDepth != 1)) {
       throw new TestException("Unable to handle subregions in this test");
     }
     CacheHelper.createCache("cache1");
     final String regionConfigName =
         TestConfig.tasktab()
             .stringAt(
                 RecoveryPrms.regionConfigNames,
                 TestConfig.tab().stringAt(RecoveryPrms.regionConfigNames, null));
     String createdRegions = "";
     for (int i = 1; i <= numRootRegions; i++) {
       try {
         final String regionName = "Region_" + i;
         createdRegions =
             createdRegions
                 + RegionHelper.createRegion(regionName, regionConfigName).getFullPath()
                 + " ";
       } catch (ConflictingPersistentDataException e) {
         Log.getLogWriter().info("Caught expected exception " + TestHelper.getStackTrace(e));
       }
     }
     if (createdRegions.length() > 0) {
       throw new TestException(
           "Expected to get "
               + ConflictingPersistentDataException.class.getName()
               + " on region creation, but the following regions were successfully created: "
               + createdRegions);
     }
   }
 }