@Override
  @SuppressWarnings({"rawtypes", "unchecked"})
  public Family createMappedForm(PersistentEntity entity) {
    ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(entity.getJavaClass());
    final Closure value = cpf.getStaticPropertyValue(GormProperties.MAPPING, Closure.class);
    if (value == null) {
      return new Region();
    }

    final Region family = new Region();
    AttributesFactory factory =
        new AttributesFactory() {
          @SuppressWarnings("unused")
          public void setRegion(String name) {
            family.setRegion(name);
          }
        };
    factory.setDataPolicy(defaultDataPolicy);

    MappingConfigurationBuilder builder = new MappingConfigurationBuilder(factory, KeyValue.class);
    builder.evaluate(value);
    entityToPropertyMap.put(entity, builder.getProperties());
    final RegionAttributes regionAttributes = factory.create();
    family.setRegionAttributes(regionAttributes);
    family.setCacheListeners(regionAttributes.getCacheListeners());
    family.setDataPolicy(regionAttributes.getDataPolicy());
    family.setCacheLoader(regionAttributes.getCacheLoader());
    family.setCacheWriter(regionAttributes.getCacheWriter());

    builder = new MappingConfigurationBuilder(family, KeyValue.class);
    builder.evaluate(value);
    return family;
  }
 /** function to create client cache * */
 public static void createClientCache1(String host, Integer port1) throws Exception {
   PORT1 = port1.intValue();
   Properties props = new Properties();
   props.setProperty("mcast-port", "0");
   props.setProperty("locators", "");
   new PutAllDUnitTest("temp").createCache(props);
   props.setProperty("retryAttempts", "2");
   props.setProperty("endpoints", "ep1=" + host + ":" + PORT1);
   props.setProperty("redundancyLevel", "-1");
   props.setProperty("establishCallbackConnection", "true");
   props.setProperty("LBPolicy", "Sticky");
   props.setProperty("readTimeout", "2000");
   props.setProperty("socketBufferSize", "1000");
   props.setProperty("retryInterval", "250");
   props.setProperty("connectionsPerServer", "2");
   AttributesFactory factory = new AttributesFactory();
   factory.setScope(Scope.DISTRIBUTED_ACK);
   PoolImpl p =
       (PoolImpl)
           ClientServerTestCase.configureConnectionPool(
               factory, host, PORT1, -1, true, -1, 2, null);
   CacheListener clientListener = new HAEventIdPropagationListenerForClient1();
   factory.setCacheListener(clientListener);
   RegionAttributes attrs = factory.create();
   cache.createRegion(REGION_NAME, attrs);
   Region region = cache.getRegion(Region.SEPARATOR + REGION_NAME);
   assertNotNull(region);
   region.registerInterest("ALL_KEYS", InterestResultPolicy.NONE);
   pool = p;
 }
  @Test
  public void testAllIndexesOnCommitForPut() throws Exception {
    // create region
    AttributesFactory af = new AttributesFactory();
    af.setDataPolicy(DataPolicy.REPLICATE);
    Region region = cache.createRegion("sample", af.create());

    // put data
    for (int i = 0; i < 10; i++) {
      region.put(i, new Portfolio(i));
    }

    String[] queries = {
      "select * from /sample where ID = 5",
      "select ID from /sample where ID < 5",
      "select ID from /sample where ID > 5",
      "select ID from /sample where ID != 5",
      "select status from /sample where status = 'active'",
      "select status from /sample where status > 'active'",
      "select status from /sample where status < 'active'",
      "select status from /sample where status != 'active'",
      "select pos.secId from /sample p, p.positions.values pos where pos.secId = 'IBM'",
      "select pos.secId from /sample p, p.positions.values pos where pos.secId < 'VMW'",
      "select pos.secId from /sample p, p.positions.values pos where pos.secId > 'IBM'",
      "select pos.secId from /sample p, p.positions.values pos where pos.secId != 'IBM'"
    };

    SelectResults[][] sr = new SelectResults[queries.length][2];

    // execute queries without indexes
    for (int i = 0; i < queries.length; i++) {
      sr[i][0] = (SelectResults) qs.newQuery(queries[i]).execute();
    }

    // create indexes
    qs.createKeyIndex("IDIndex", "ID", "/sample");
    qs.createIndex("statusIndex", "status", "/sample");
    qs.createIndex("secIdIndex", "pos.secId", "/sample p, p.positions.values pos");

    // begin transaction
    Context ctx = cache.getJNDIContext();
    UserTransaction utx = (UserTransaction) ctx.lookup("java:/UserTransaction");
    utx.begin();

    // update data
    for (int i = 0; i < 10; i++) {
      region.put(i, new Portfolio(i));
    }

    // execute queries with indexes during transaction
    for (int i = 0; i < queries.length; i++) {
      sr[i][1] = (SelectResults) qs.newQuery(queries[i]).execute();
    }

    // complete transaction
    utx.commit();

    // verify results
    com.gemstone.gemfire.cache.query.CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
  }
 /** Helper Methods */
 private void createLocalRegion() throws ParseException {
   Cache cache = CacheUtils.getCache();
   AttributesFactory attributesFactory = new AttributesFactory();
   attributesFactory.setDataPolicy(DataPolicy.NORMAL);
   RegionAttributes regionAttributes = attributesFactory.create();
   Region region = cache.createRegion(regionName, regionAttributes);
 }
  @Test
  public void testFailedIndexUpdateOnCommitForPut() throws Exception {
    Person.THROW_ON_INDEX = true;
    AttributesFactory af = new AttributesFactory();
    af.setDataPolicy(DataPolicy.REPLICATE);
    SimpleListener sl = new SimpleListener();
    af.setCacheListener(sl);
    Region region = cache.createRegion("sample", af.create());
    qs.createIndex("foo", IndexType.FUNCTIONAL, "index", "/sample");
    Context ctx = cache.getJNDIContext();

    Integer x = new Integer(0);
    region.getCache().getCacheTransactionManager().begin();
    region.create(x, new Person("xyz", 45));
    try {
      region.getCache().getCacheTransactionManager().commit();
      fail("commit should have thrown an exception because the index maintenance threw");
    } catch (com.gemstone.gemfire.cache.query.IndexMaintenanceException ie) {
      // this is the desired case
    }
    Person p = (Person) region.get(x);
    assertEquals("object shouldn't have made it into region", null, p);
    assertEquals(0, sl.creates);
    assertEquals(0, sl.updates);
  }
 public void DISABLED_testTxWithCloning() {
   AttributesFactory af = new AttributesFactory();
   af.setDataPolicy(DataPolicy.REPLICATE);
   af.setScope(Scope.DISTRIBUTED_ACK);
   af.setCloningEnabled(true);
   basicTest(af.create());
 }
  public static void createClientCache(String host, Integer port1, Integer port2) throws Exception {
    PORT1 = port1.intValue();
    PORT2 = port2.intValue();
    Properties props = new Properties();
    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
    props.setProperty(DistributionConfig.LOCATORS_NAME, "");
    new DestroyEntryPropagationDUnitTest("temp").createCache(props);
    CacheServerTestUtil.disableShufflingOfEndpoints();
    Pool p;
    try {
      p =
          PoolManager.createFactory()
              .addServer(host, PORT1)
              .addServer(host, PORT2)
              .setSubscriptionEnabled(true)
              .setSubscriptionRedundancy(-1)
              .setReadTimeout(2000)
              .setSocketBufferSize(1000)
              .setMinConnections(4)
              // .setRetryAttempts(2)
              // .setRetryInterval(250)
              .create("EntryPropagationDUnitTestPool");
    } finally {
      CacheServerTestUtil.enableShufflingOfEndpoints();
    }

    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setPoolName(p.getName());
    factory.setCacheListener(new CertifiableTestCacheListener(getLogWriter()));
    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);
  }
 private RegionAttributes createRegionAttributes(boolean isConcurrencyChecksEnabled) {
   AttributesFactory factory = new AttributesFactory();
   factory.setScope(Scope.DISTRIBUTED_ACK);
   factory.setDataPolicy(DataPolicy.REPLICATE);
   factory.setConcurrencyChecksEnabled(isConcurrencyChecksEnabled); //
   RegionAttributes ra = factory.create();
   return ra;
 }
 /**
  * create a client with 2 regions sharing a common writer
  *
  * @throws Exception
  */
 public static void createRegion() throws Exception {
   HARegionDUnitTest test = new HARegionDUnitTest(REGION_NAME);
   cache = test.createCache();
   AttributesFactory factory = new AttributesFactory();
   factory.setScope(Scope.DISTRIBUTED_ACK);
   factory.setDataPolicy(DataPolicy.REPLICATE);
   HARegion.getInstance(REGION_NAME, (GemFireCacheImpl) cache, null, factory.create());
 }
 @Override
 public Region createRegion(String regionName, Class valueConstraint) {
   PartitionAttributesFactory paf = new PartitionAttributesFactory();
   AttributesFactory af = new AttributesFactory();
   af.setPartitionAttributes(paf.create());
   af.setValueConstraint(valueConstraint);
   Region r1 = CacheUtils.createRegion(regionName, af.create(), false);
   return r1;
 }
 @Before
 public void setUp() throws Exception {
   tblName = CacheUtils.init("CacheTest");
   cache = CacheUtils.getCache();
   AttributesFactory attributesFactory = new AttributesFactory();
   attributesFactory.setValueConstraint(Portfolio.class);
   RegionAttributes regionAttributes = attributesFactory.create();
   currRegion = cache.createRegion("portfolios", regionAttributes);
   qs = CacheUtils.getQueryService();
 }
 @SuppressWarnings({"unchecked", "deprecation", "rawtypes"})
 void createRegion(String name, boolean accessor, int redundantCopies, CacheWriter<?, ?> cw) {
   AttributesFactory af = new AttributesFactory();
   af.setPartitionAttributes(
       new PartitionAttributesFactory()
           .setLocalMaxMemory(accessor ? 0 : 12)
           .setRedundantCopies(redundantCopies)
           .create());
   af.setCacheWriter(cw);
   getCache().createRegion(name, af.create());
 }
  protected AttributesFactory getServerCacheAttributesFactory(boolean enableStorage) {
    AttributesFactory factory = new AttributesFactory();
    PartitionAttributesFactory paf = new PartitionAttributesFactory();
    factory.setDataPolicy(DataPolicy.PARTITION);
    paf.setRedundantCopies(0).setTotalNumBuckets(1);
    if (!enableStorage) {
      paf.setLocalMaxMemory(0);
    }

    factory.setPartitionAttributes(paf.create());
    return factory;
  }
Exemplo n.º 14
0
 /**
  * Tests the where clause formed with CompiledComparison nesting with CompiledIN
  *
  * @throws Exception
  */
 @Test
 public void testBug40333_InLocalRegion_2() throws Exception {
   CacheUtils.startCache();
   final Cache cache = CacheUtils.getCache();
   AttributesFactory attributesFactory = new AttributesFactory();
   RegionAttributes ra = attributesFactory.create();
   final Region region = cache.createRegion("new_pos", ra);
   String queryStr =
       " select distinct r.name, pVal, r.\"type\"  "
           + " from /new_pos r , r.positions.values pVal where "
           + " ( r.name IN Set('name_11' , 'name_12') OR false ) AND pVal.mktValue = 1.00";
   this.bug40333Simulation(region, queryStr);
 }
 public static void createCacheClient(Pool poolAttr, String regionName1, String regionName2)
     throws Exception {
   new CacheServerTestUtil("temp").createCache(getClientProperties());
   PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
   pf.init(poolAttr);
   PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil");
   AttributesFactory factory = new AttributesFactory();
   factory.setScope(Scope.LOCAL);
   factory.setPoolName(p.getName());
   RegionAttributes attrs = factory.create();
   cache.createRegion(regionName1, attrs);
   cache.createRegion(regionName2, attrs);
   pool = p;
 }
 /**
  * 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;
 }
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 protected RegionAttributes getRegionAttributes() {
   Compressor compressor = null;
   try {
     compressor = SnappyCompressor.getDefaultInstance();
   } catch (Throwable t) {
     // Not a supported OS
     return super.getRegionAttributes();
   }
   RegionAttributes attrs = super.getRegionAttributes();
   AttributesFactory factory = new AttributesFactory(attrs);
   factory.setCompressor(compressor);
   return factory.create();
 }
Exemplo n.º 18
0
  protected void setUp() throws Exception {
    CacheUtils.startCache();
    cache = CacheUtils.getCache();
    AttributesFactory attributesFactory = new AttributesFactory();
    //    attributesFactory.setValueConstraint(Portfolio.class);
    RegionAttributes regionAttributes = attributesFactory.create();

    region = cache.createRegion("pos", regionAttributes);
    region.put("0", new Portfolio(0));
    region.put("1", new Portfolio(1));
    region.put("2", new Portfolio(2));
    region.put("3", new Portfolio(3));

    qs = cache.getQueryService();
  }
  /**
   * Tests that we are in {@link GemFireHealth#OKAY_HEALTH okay} health if the hit ratio dips below
   * the threshold.
   */
  public void testCheckHitRatio() throws CacheException {
    Cache cache = CacheFactory.create(this.system);
    //    CachePerfStats stats = ((GemFireCache) cache).getCachePerfStats();

    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.LOCAL);
    factory.setCacheLoader(
        new CacheLoader() {
          public Object load(LoaderHelper helper) throws CacheLoaderException {

            return "Loaded";
          }

          public void close() {}
        });

    RegionAttributes attrs = factory.create();
    Region region = cache.createRegion(this.getName(), attrs);

    GemFireHealthConfig config = new GemFireHealthConfigImpl(null);
    config.setMinHitRatio(0.5);

    CacheHealthEvaluator eval =
        new CacheHealthEvaluator(config, this.system.getDistributionManager());
    List status = new ArrayList();
    eval.evaluate(status);
    assertEquals(0, status.size());

    region.get("One");
    region.get("One");
    region.get("One");

    status = new ArrayList();
    eval.evaluate(status);
    assertEquals(0, status.size());

    for (int i = 0; i < 50; i++) {
      region.get("Miss " + i);
    }

    status = new ArrayList();
    eval.evaluate(status);

    AbstractHealthEvaluator.HealthStatus ill = (AbstractHealthEvaluator.HealthStatus) status.get(0);
    assertEquals(GemFireHealth.OKAY_HEALTH, ill.getHealthCode());
    String s = "The hit ratio of this Cache";
    assertTrue(ill.getDiagnosis().indexOf(s) != -1);
  }
  public static Integer createServerCache() throws Exception {
    new DestroyEntryPropagationDUnitTest("temp").createCache(new Properties());
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setDataPolicy(DataPolicy.REPLICATE);
    factory.setCacheListener(new CertifiableTestCacheListener(getLogWriter()));
    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);

    BridgeServer server = cache.addBridgeServer();
    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    server.setPort(port);
    server.setNotifyBySubscription(true);
    server.start();
    return new Integer(server.getPort());
  }
Exemplo n.º 21
0
 /**
  * Commented the test as it is for some reason causing OOM when run in the suite. It is due to
  * presence of PR Tests the where clause formed with CompiledComparison nesting with CompiledIN
  *
  * @throws Exception
  */
 public void _testBug40333_InPartitionedRegion_2() throws Exception {
   CacheUtils.startCache();
   final Cache cache = CacheUtils.getCache();
   AttributesFactory attributesFactory = new AttributesFactory();
   PartitionAttributesFactory paf = new PartitionAttributesFactory();
   paf.setTotalNumBuckets(10);
   PartitionAttributes pa = paf.create();
   attributesFactory.setPartitionAttributes(pa);
   RegionAttributes ra = attributesFactory.create();
   final Region region = cache.createRegion("new_pos", ra);
   String queryStr =
       " select distinct r.name, pVal, r.\"type\"  "
           + " from /new_pos r , r.positions.values pVal where "
           + " ( r.name IN Set('name_11' , 'name_12') OR false ) AND pVal.mktValue < 1.00";
   this.bug40333Simulation(region, queryStr);
 }
 protected RegionAttributes getDiskRegionAttributes() {
   AttributesFactory factory = new AttributesFactory(getRegionAttributes());
   File[] diskDirs = new File[1];
   diskDirs[0] = new File("diskRegionDirs/" + OSProcess.getId());
   diskDirs[0].mkdirs();
   factory.setDiskStoreName(
       getCache()
           .createDiskStoreFactory()
           .setDiskDirs(diskDirs)
           .setTimeInterval(1000)
           .setQueueSize(0)
           .create("TXRestrictionsDUnitTest")
           .getName());
   factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
   return factory.create();
 }
 /** create the server * */
 public static Integer createServerCache() throws Exception {
   new PutAllDUnitTest("temp").createCache(new Properties());
   AttributesFactory factory = new AttributesFactory();
   factory.setScope(Scope.DISTRIBUTED_ACK);
   factory.setDataPolicy(DataPolicy.REPLICATE);
   CacheListener clientListener = new HAEventIdPropagationListenerForClient1();
   factory.setCacheListener(clientListener);
   RegionAttributes attrs = factory.create();
   cache.createRegion(REGION_NAME, attrs);
   server = (CacheServerImpl) cache.addCacheServer();
   assertNotNull(server);
   int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
   server.setPort(port);
   server.setNotifyBySubscription(true);
   server.start();
   return new Integer(server.getPort());
 }
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 protected RegionAttributes getRegionAttributes(String type) {
   Compressor compressor = null;
   try {
     compressor = SnappyCompressor.getDefaultInstance();
   } catch (Throwable t) {
     // Not a supported OS
     return super.getRegionAttributes(type);
   }
   RegionAttributes ra = super.getRegionAttributes(type);
   AttributesFactory factory = new AttributesFactory(ra);
   if (!ra.getDataPolicy().isEmpty()) {
     factory.setCompressor(compressor);
   }
   return factory.create();
 }
 public static void createCacheClient(
     Pool poolAttr, String regionName, Properties dsProperties, Boolean addControlListener)
     throws Exception {
   new CacheServerTestUtil("temp").createCache(dsProperties);
   PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
   pf.init(poolAttr);
   PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil");
   AttributesFactory factory = new AttributesFactory();
   factory.setScope(Scope.LOCAL);
   factory.setPoolName(p.getName());
   if (addControlListener.booleanValue()) {
     factory.addCacheListener(new ControlListener());
   }
   RegionAttributes attrs = factory.create();
   cache.createRegion(regionName, attrs);
   pool = p;
 }
Exemplo n.º 26
0
  @Test
  public void testBug40441() throws Exception {
    CacheUtils.startCache();
    final Cache cache = CacheUtils.getCache();
    AttributesFactory attributesFactory = new AttributesFactory();
    RegionAttributes ra = attributesFactory.create();
    final Region region = cache.createRegion("new_pos", ra);
    String queryStr1 =
        " select distinct r.name, pVal, r.\"type\"  "
            + " from /new_pos r , r.positions.values pVal where "
            + " ( r.undefinedTestField.toString = UNDEFINED  OR false ) "; // AND pVal.mktValue =
                                                                           // 1.00";
    String queryStr2 =
        " select distinct r.name, pVal, r.\"type\"  "
            + " from /new_pos r , r.positions.values pVal where "
            + " ( r.undefinedTestField.toString = UNDEFINED  AND true ) AND pVal.mktValue = 1.00";
    final QueryService qs = CacheUtils.getQueryService();
    for (int i = 1; i < 100; ++i) {
      NewPortfolio pf = new NewPortfolio("name" + i, i);
      region.put("name" + i, pf);
    }

    Index indx1 =
        qs.createIndex(
            "MarketValues",
            IndexType.FUNCTIONAL,
            "itr2.mktValue",
            "/new_pos itr1, itr1.positions.values itr2");
    Index indx2 = qs.createIndex("Name", IndexType.FUNCTIONAL, "itr1.name", "/new_pos itr1");
    Index indx3 = qs.createIndex("nameIndex", IndexType.PRIMARY_KEY, "name", "/new_pos");
    Index indx4 = qs.createIndex("idIndex", IndexType.FUNCTIONAL, "id", "/new_pos");
    Index indx5 = qs.createIndex("statusIndex", IndexType.FUNCTIONAL, "status", "/new_pos");
    Index indx6 =
        qs.createIndex(
            "undefinedFieldIndex", IndexType.FUNCTIONAL, "undefinedTestField.toString", "/new_pos");
    final Query q1 = qs.newQuery(queryStr1);
    final Query q2 = qs.newQuery(queryStr2);
    try {
      SelectResults sr1 = (SelectResults) q1.execute();
      SelectResults sr2 = (SelectResults) q2.execute();
    } catch (Throwable e) {
      e.printStackTrace();
      fail("Test failed due to = " + e.toString());
    }
  }
  /**
   * Tests that a local writer receives a modified version of the callback argument on an update.
   */
  public void testLocalUpdateModifiedCallbackArgument() throws CacheException {

    final String name = this.getUniqueName();
    final Object key = "KEY";
    final Object value = "VALUE";
    final Object one = "ONE";
    final Object two = "TWO";

    TestCacheLoader loader =
        new TestCacheLoader() {
          public Object load2(LoaderHelper helper) throws CacheLoaderException {

            Object[] array = (Object[]) helper.getArgument();
            assertEquals(one, array[0]);
            array[0] = two;

            return value;
          }
        };

    TestCacheWriter writer =
        new TestCacheWriter() {
          public void beforeCreate2(EntryEvent event) throws CacheWriterException {}

          public void beforeUpdate2(EntryEvent event) throws CacheWriterException {

            Object[] array = (Object[]) event.getCallbackArgument();
            assertEquals(two, array[0]);
          }
        };

    AttributesFactory factory = new AttributesFactory(getRegionAttributes());
    factory.setCacheLoader(loader);
    factory.setCacheWriter(writer);
    Region region = createRegion(name, factory.create());

    region.create(key, null);
    assertFalse(loader.wasInvoked());
    assertTrue(writer.wasInvoked());

    Object[] array = new Object[] {one};
    assertEquals(value, region.get(key, array));
    assertTrue(loader.wasInvoked());
    assertTrue(writer.wasInvoked());
  }
 // @Test
 public void _testFailedIndexUpdateOnJTACommitForPut() throws Exception {
   Person.THROW_ON_INDEX = true;
   AttributesFactory af = new AttributesFactory();
   af.setDataPolicy(DataPolicy.REPLICATE);
   Region region = cache.createRegion("sample", af.create());
   qs.createIndex("foo", IndexType.FUNCTIONAL, "index", "/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));
   try {
     utx.commit();
     fail("Commit should have thrown an exception because the index update threw");
   } catch (Exception e) {
     // this is desired
   }
 }
  public static void createPool(PoolAttributes poolAttr) throws Exception {
    Properties props = new Properties();
    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
    props.setProperty(DistributionConfig.LOCATORS_NAME, "");

    DistributedSystem ds = new CacheServerTestUtil("tmp").getSystem(props);
    ;

    PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
    pf.init(poolAttr);
    PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil");
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.LOCAL);
    factory.setPoolName(p.getName());

    RegionAttributes attrs = factory.create();
    pool = p;
  }
 /** Initializes proxy object and creates region for client */
 private void createProxyAndRegionForClient() {
   try {
     // props.setProperty("retryAttempts", "5");
     PoolFactory pf = PoolManager.createFactory();
     proxy =
         (PoolImpl)
             pf.addServer("localhost", PORT)
                 .setThreadLocalConnections(true)
                 .setReadTimeout(10000)
                 .setPingInterval(10000)
                 .setMinConnections(0)
                 .create("junitPool");
     AttributesFactory factory = new AttributesFactory();
     factory.setScope(Scope.DISTRIBUTED_ACK);
     cache.createVMRegion(regionName, factory.createRegionAttributes());
   } catch (Exception ex) {
     ex.printStackTrace();
     fail("Failed to initialize client");
   }
 }