com.gemstone.gemfire.cache.Region Java Examples

The following examples show how to use com.gemstone.gemfire.cache.Region. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DistinctResultsWithDupValuesInRegionTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void createPartitionedRegionWithNullValues() {
  Cache cache = CacheUtils.getCache();
  PartitionAttributesFactory prAttFactory = new PartitionAttributesFactory();
  AttributesFactory attributesFactory = new AttributesFactory();
  attributesFactory.setPartitionAttributes(prAttFactory.create());
  RegionAttributes regionAttributes = attributesFactory.create();
  Region region = cache.createRegion(regionName, regionAttributes);

  for (int i = 1; i <= numElem; i++) {
    Portfolio obj = new Portfolio(i);
    region.put(i, obj);
    if (i%(numElem/5) == 0) obj.status = null;
    region.put(i + numElem, obj);
    System.out.println(obj);
  }
}
 
Example #2
Source File: ClientSnapshotDUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void testInvalidate() throws Exception {
  SerializableCallable invalid = new SerializableCallable() {
    @Override
    public Object call() throws Exception {
      Region<Integer, MyObject> r = getCache().getRegion("clienttest");

      r.put(1, new MyObject(1, "invalidate"));
      r.invalidate(1);

      File f = new File(getDiskDirs()[0], "client-invalidate.snapshot");
      r.getSnapshotService().save(f, SnapshotFormat.GEMFIRE);
      r.getSnapshotService().load(f, SnapshotFormat.GEMFIRE);
      
      return null;
    }
  };
  
  Host.getHost(0).getVM(3).invoke(invalid);
  
  assertTrue(region.containsKey(1));
  assertFalse(region.containsValueForKey(1));
  assertNull(region.get(1));
}
 
Example #3
Source File: LimitClauseTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void testLikeWithLimitWithParameter() throws Exception {
  String queryString = "SELECT DISTINCT entry FROM $1 entry WHERE entry.key like $2 ORDER BY entry.key LIMIT $3 ";
  SelectResults result;
  Region region = CacheUtils.createRegion("portfolios1", Portfolio.class);
  for (int i = 0; i < 100; i++) {
    region.put( "p"+i, new Portfolio(i));
  }
  
  Object[] params = new Object[3];
  params[0] = region.entrySet();
  params[1] = "p%";
  params[2] = 5;

  SelectResults results = (SelectResults)qs.newQuery(queryString).execute(params);
  assertEquals(5, results.size());
}
 
Example #4
Source File: DescribeDiskStoreFunctionJUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@Test
public void testIsRegionPersistentWhenDataPolicyIsPartition() {
  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.PARTITION));
  }});

  final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);

  assertFalse(function.isPersistent(mockRegion));
}
 
Example #5
Source File: PRRegionReadWriteStatsDUnit.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
protected static void validateGetStats(int expectedVal) {

    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
    Region r = cache.getRegion("/TRADE/CUSTOMERS");
    assertNotNull(r);
    assert (r instanceof PartitionedRegion);

    PartitionedRegion parRegion = (PartitionedRegion) r;
    int val = parRegion.getPrStats().getStats().get("getsCompleted").intValue();
    assertEquals(expectedVal, val);
    
    Region r1 = cache.getRegion("/TRADE/PROSPECTIVES");
    
    assert (r1 instanceof DistributedRegion);
    
    LocalRegion lRegion = (LocalRegion)r1;
    val = lRegion.getCachePerfStats().getStats().get("gets").intValue();
    assertEquals(expectedVal, val);

  }
 
Example #6
Source File: HDFSIntegrationUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static String getLeaderRegionPath(String regionPath,
    RegionAttributes regionAttributes, Cache cache) {
  String colocated;
  while(regionAttributes.getPartitionAttributes() != null 
      && (colocated = regionAttributes.getPartitionAttributes().getColocatedWith()) != null) {
    // Do not waitOnInitialization() for PR
    GemFireCacheImpl gfc = (GemFireCacheImpl)cache;
    Region colocatedRegion = gfc.getPartitionedRegion(colocated, false);
    if(colocatedRegion == null) {
      Assert.fail("Could not find parent region " + colocated + " for " + regionPath);
    }
    regionAttributes = colocatedRegion.getAttributes();
    regionPath = colocatedRegion.getFullPath();
  }
  return regionPath;
}
 
Example #7
Source File: VersionHelper.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
protected static String getDiskAttributes(Region r) {
  String dsn = r.getAttributes().getDiskStoreName();
  if (dsn == null) {
    throw new HydraConfigException("Persistence is not configured");
  }
  DiskStore ds = DiskStoreHelper.getDiskStore(dsn);
  return "the DiskStore is" + ds
       + ", the allow force compaction is "
       + ds.getAllowForceCompaction()
       + ", the auto compact is "
       + ds.getAutoCompact()
       + ", the compaction threshold is "
       + ds.getCompactionThreshold()
       + ", the disk dir num is "
       + ds.getDiskDirs().length
       + ", the max oplog size is "
       + ds.getMaxOplogSize()
       + ", the queue size is "
       + ds.getQueueSize()
       + ", the synchronous (from the region) is "
       + r.getAttributes().isDiskSynchronous()
       ;
}
 
Example #8
Source File: PDXWanDUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void waitForValue(VM vm, final String key, final int value) {
  SerializableCallable createSystem = new SerializableCallable() {
    public Object call() throws Exception {
      Cache cache = getCache();
      final Region region1 = cache.getRegion("region");
      waitForCriterion(new WaitCriterion() {

        public String description() {
          return "Didn't receive update over the WAN";
        }

        public boolean done() {
          return region1.get(key) != null;
        }
        
      }, 30000, 100, true);
      assertEquals(new SimpleClass(value, (byte) value), region1.get(key));
      return null;
    }
    
  };
  vm.invoke(createSystem);
}
 
Example #9
Source File: OfflineSnapshotJUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void testExport() throws Exception {
  int rcount = 0;
  for (final RegionType rt : RegionType.persistentValues()) {
    for (final SerializationType st : SerializationType.offlineValues()) {
      Region<Integer, MyObject> region = rgen.createRegion(cache, ds.getName(), rt, "test" + rcount++);
      final Map<Integer, MyObject> expected = createExpected(st, 1000);
      
      region.putAll(expected);
      cache.close();
      
      DiskStoreImpl.exportOfflineSnapshot(ds.getName(), new File[] { new File(".") }, new File("."));
      checkSnapshotEntries(expected, ds.getName(), region.getName());
      
      reset();
    }
  }
}
 
Example #10
Source File: MBeanProxyInvocationHandler.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param member
 *          member to which this MBean belongs
 * @param monitoringRegion
 *          corresponding MonitoringRegion
 * @param objectName
 *          ObjectName of the MBean
 * @param interfaceClass
 *          on which interface the proxy to be exposed
 * @return Object
 * @throws ClassNotFoundException
 * @throws IntrospectionException
 */
public static Object newProxyInstance(DistributedMember member,
    Region<String, Object> monitoringRegion, ObjectName objectName,
    Class interfaceClass) throws ClassNotFoundException,
    IntrospectionException {
  boolean isMXBean = JMX.isMXBeanInterface(interfaceClass);
  boolean notificationBroadcaster = ((FederationComponent) monitoringRegion
      .get(objectName.toString())).isNotificationEmitter();

  InvocationHandler handler = new MBeanProxyInvocationHandler(member,
      objectName, monitoringRegion, isMXBean);

  Class[] interfaces;

  if (notificationBroadcaster) {
    interfaces = new Class[] { interfaceClass, ProxyInterface.class,
        NotificationBroadCasterProxy.class };
  } else {
    interfaces = new Class[] { interfaceClass, ProxyInterface.class };
  }

  Object proxy = Proxy.newProxyInstance(MBeanProxyInvocationHandler.class
      .getClassLoader(), interfaces, handler);

  return interfaceClass.cast(proxy);
}
 
Example #11
Source File: WANConfigurationJUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void test_GatewaySenderIdAndAsyncEventId() {
    cache = new CacheFactory().create();
    AttributesFactory factory = new AttributesFactory();
    factory.addGatewaySenderId("ln");
    factory.addGatewaySenderId("ny");
    factory.addAsyncEventQueueId("Async_LN");
    RegionAttributes attrs = factory.create();
    
    Set<String> senderIds = new HashSet<String>();
    senderIds.add("ln");
    senderIds.add("ny");
    Set<String> attrsSenderIds = attrs.getGatewaySenderIds();
    assertEquals(senderIds, attrsSenderIds);
    Region r = cache.createRegion("Customer", attrs);
    assertEquals(senderIds, ((LocalRegion)r).getGatewaySenderIds());
}
 
Example #12
Source File: InterestListFailoverDUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void createEntries()
{
  try {
    Region r = CacheServerTestUtil.getCache().getRegion("/"+ REGION_NAME);
    assertNotNull(r);

    if (!r.containsKey("key-1")) {
      r.create("key-1", "key-1");
    }
    if (!r.containsKey("key-6")) {
      r.create("key-6", "key-6");
    }
    // Verify that no invalidates occurred to this region
    assertEquals(r.getEntry("key-1").getValue(), "key-1");
    assertEquals(r.getEntry("key-6").getValue(), "key-6");
  }
  catch (Exception ex) {
    fail("failed while createEntries()", ex);
  }
}
 
Example #13
Source File: Bug36805DUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void registerInterest()
{
  cache.getLogger().info(
      "<ExpectedException action=add>" + "RegionDestroyedException"
      + "</ExpectedException>");
  try {
    Region r = cache.getRegion("/" + regionName);
    assertNotNull(r);
    List listOfKeys = new ArrayList();
    listOfKeys.add("key-1");
    listOfKeys.add("key-2");
    listOfKeys.add("key-3");
    listOfKeys.add("key-4");
    listOfKeys.add("key-5");
    r.registerInterest(listOfKeys);
    fail("expected RegionDestroyedException");
  } catch (ServerOperationException expected) {
    assertEquals(RegionDestroyedException.class, expected.getCause().getClass());
  }
  finally {
    cache.getLogger().info(
        "<ExpectedException action=remove>" + "RegionDestroyedException"
        + "</ExpectedException>");
  }
}
 
Example #14
Source File: QueryDataDUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * This function puts portfolio objects into the created Region (PR or Local)
 * *
 */
public CacheSerializableRunnable getCacheSerializableRunnableForPRPuts(final String regionName,
    final Object[] portfolio, final int from, final int to) {
  SerializableRunnable puts = new CacheSerializableRunnable("Region Puts") {
    @Override
    public void run2() throws CacheException {
      Cache cache = CacheFactory.getAnyInstance();
      Region region = cache.getRegion(regionName);
      for (int j = from; j < to; j++)
        region.put(new Integer(j), portfolio[j]);
      getLogWriter()
          .info(
              "PRQueryDUnitHelper#getCacheSerializableRunnableForPRPuts: Inserted Portfolio data on Region "
                  + regionName);
    }
  };
  return (CacheSerializableRunnable) puts;
}
 
Example #15
Source File: DynamicRegionTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/** 
 *  Hydra task to create a BridgeServer, creates the cache & regions to act as
 *  parents of dynamically created regions.
 */
public synchronized static void HydraTask_initBridgeServer() {

   // configure DynamicRegionFactory - required before cache is open
   File d = new File("DynamicRegionData" + ProcessMgr.getProcessId());
   d.mkdirs();
   DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(d, null));

   // create cache
   CacheHelper.createCache("bridge");

   // create regions to act as parent(s) of dynamic regions
   int numRoots = TestConfig.tab().intAt(DynamicRegionPrms.numRootRegions);
   int breadth = TestConfig.tab().intAt(DynamicRegionPrms.numSubRegions);
   int depth = TestConfig.tab().intAt(DynamicRegionPrms.regionDepth);

   for (int i=0; i<numRoots; i++) {
     String rootName = "root" + (i+1);
     Region rootRegion = RegionHelper.createRegion(rootName, "bridge");
     Log.getLogWriter().info("Created root region " + rootName);
     createSubRegions(rootRegion, breadth, depth, "Region");
   }

   // start the bridge server
   BridgeHelper.startBridgeServer("bridge");
}
 
Example #16
Source File: FailoverDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void registerInterestList()
{
  try {
    Region r = cache.getRegion("/"+ regionName);
    assertNotNull(r);
    r.registerInterest("key-1");
    r.registerInterest("key-2");
    r.registerInterest("key-3");
    r.registerInterest("key-4");
    r.registerInterest("key-5");
  }
  catch (Exception ex) {
    fail("failed while registering keys k1 to k5", ex);
  }
}
 
Example #17
Source File: PRColocationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void closeRegion(String partitionedRegionName) {
  assertNotNull(basicGetCache());
  Region partitionedregion = basicGetCache().getRegion(
      Region.SEPARATOR + partitionedRegionName);
  assertNotNull(partitionedregion);
  try {
    partitionedregion.close();
  } catch (Exception e) {
    fail(
        "closeRegion : failed to close region : " + partitionedregion,
        e);
  }
}
 
Example #18
Source File: PersistentColocatedPartitionedRegionDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private SerializableRunnable getCreateChildPRRunnable() {
  return new SerializableRunnable("createChildPR") {
    public void run() {
      Cache cache = getCache();
      
      final CountDownLatch recoveryDone = new CountDownLatch(1);
      ResourceObserver observer = new InternalResourceManager.ResourceObserverAdapter() {
        @Override
        public void recoveryFinished(Region region) {
          if(region.getName().equals("region2")){
            recoveryDone.countDown();
          }
        }
      };
      InternalResourceManager.setResourceObserver(observer );

      AttributesFactory af = new AttributesFactory();
      PartitionAttributesFactory paf = new PartitionAttributesFactory();
      paf.setRedundantCopies(1);
      paf.setColocatedWith(PR_REGION_NAME);
      af.setPartitionAttributes(paf.create());
      cache.createRegion("region2", af.create());
      
      try {
        recoveryDone.await(MAX_WAIT, TimeUnit.MILLISECONDS);
      } catch (InterruptedException e) {
        fail("interrupted", e);
      } 
    }
  };
}
 
Example #19
Source File: PersistentPartitionedRegionTestBase.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void removeData(VM vm, final int startKey, final int endKey) {
  SerializableRunnable createData = new SerializableRunnable() {
    
    public void run() {
      Cache cache = getCache();
      Region region = cache.getRegion(PR_REGION_NAME);
      
      for(int i =startKey; i < endKey; i++) {
        region.destroy(i);
      }
    }
  };
  vm.invoke(createData);
}
 
Example #20
Source File: CacheXml65Test.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testLOCAL_PERSISTENT_OVERFLOW() throws CacheException {
  CacheCreation cache = new CacheCreation();
  RegionCreation root = (RegionCreation)
    cache.createRegion("cpolocal", "LOCAL_PERSISTENT_OVERFLOW");
  testXml(cache);
  GemFireCacheImpl c = (GemFireCacheImpl) getCache();
  Region r = c.getRegion("cpolocal");
  assertNotNull(r);
  RegionAttributes ra = r.getAttributes();
  assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy());
  assertEquals(Scope.LOCAL, ra.getScope());
  assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes());
  assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE,
               c.getResourceManager().getEvictionHeapPercentage());
}
 
Example #21
Source File: HAClearDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private void putKnownKeys()
{
  Region region = cache.getRegion(Region.SEPARATOR + REGION_NAME);
  assertNotNull(region);
  for (int i = 0; i < NO_OF_PUTS; i++) {
    region.put("key" + i, "value" + i);
  }
}
 
Example #22
Source File: StructMemberAcessTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void setUp() throws java.lang.Exception {
  CacheUtils.startCache();
  Region region = CacheUtils.createRegion("Portfolios", Portfolio.class);
  for (int i = 0; i < 4; i++) {
    region.put("" + i, new Portfolio(i));
  }
}
 
Example #23
Source File: HARegionDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * do three puts on key-1
 * 
 */
public static void putValue2()
{
  try {
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    r1.put("key-1", "value-2");
  }
  catch (Exception ex) {
    ex.printStackTrace();
    fail("failed while region.put()", ex);
  }
}
 
Example #24
Source File: RangePartitionResolverAllTypesTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testRangesInfinity() throws SQLException, StandardException {
  Connection conn = getConnection();
  Statement s = conn.createStatement();
  s.execute("create schema EMP");

  Cache cache = CacheFactory.getAnyInstance();
  for (int i = 0; i < Set2_CreateTableStmntDiffDataType.length; i++) {
    s.execute(Set2_CreateTableStmntDiffDataType[i]);
    Region regtwo = cache.getRegion(Region_Names[i]);
    System.out.println("Region Name = " + Region_Names[i]);
    RegionAttributes rattr = regtwo.getAttributes();
    PartitionResolver pr = rattr.getPartitionAttributes()
        .getPartitionResolver();
    GfxdRangePartitionResolver rpr = (GfxdRangePartitionResolver)pr;

    Object[] eachTypeArray = (Object[])Set2_params[i];
    // System.out.println("eachTypeArray index = " + eachDataType);
    for (int eachCase = 0; eachCase < eachTypeArray.length; eachCase++) {
      Object[] params = (Object[])eachTypeArray[eachCase];
      Object[] routingObjects = rpr.getRoutingObjectsForRange((DataValueDescriptor)params[0],
          ((Boolean)params[1]).booleanValue(), (DataValueDescriptor)params[2],
          ((Boolean)params[3]).booleanValue());
      Integer[] verifyRoutingObjects = (Integer[])params[4];
      if (verifyRoutingObjects == null) {
        assertNull(routingObjects);
      }
      else {
        assertEquals(verifyRoutingObjects.length, routingObjects.length);
        for (int v = 0; v < verifyRoutingObjects.length; v++) {
          assertEquals(verifyRoutingObjects[v], routingObjects[v]);
        }
      }
    }

  }
  s.close();
  conn.close();
}
 
Example #25
Source File: WanDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * does a put on the client expecting an exception
 * @throws Exception
 */
public static void doPutsOnClientExpectingException() throws Exception
{
  Region region1 = cache.getRegion(Region.SEPARATOR+ REGION_NAME);
  try {
    region1.put("newKey", "newValue");
    fail("Exception did not occur although was supposed to occur");
  }
  catch (Exception e) {
    //e.printStackTrace();
  }
  assertEquals(null,region1.getEntry("newKey"));
}
 
Example #26
Source File: DefaultPartitionTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testDefaultPartitionWhenPKFKExists_composite_pkIn2ndtoo()
    throws SQLException, StandardException {
  Connection conn = getConnection();
  Statement s = conn.createStatement();
  s.execute("create schema EMP");
  Cache cache = CacheFactory.getAnyInstance();
  s
      .execute("create table EMP.PARTITIONTESTTABLE (ID int not null, "
          + " SECONDID int not null, THIRDID int not null, primary key (ID, SECONDID))"
          + " PARTITION BY PRIMARY KEY");
  s
      .execute("create table EMP.PARTITIONTESTTABLE_FK (ID_FK int not null, "
          + " SECONDID_FK int not null, THIRDID int not null, primary key (THIRDID), "
          + "foreign key (ID_FK, SECONDID_FK) references EMP.PARTITIONTESTTABLE(ID, SECONDID))");
  Region regtwo = cache.getRegion("/EMP/PARTITIONTESTTABLE_FK");
  RegionAttributes rattr = regtwo.getAttributes();
  PartitionResolver pr = rattr.getPartitionAttributes()
      .getPartitionResolver();
  assertNotNull(pr);
  GfxdPartitionByExpressionResolver scpr = (GfxdPartitionByExpressionResolver)pr;
  assertEquals("/EMP/PARTITIONTESTTABLE", scpr.getMasterTable(false /* immediate master*/));
  assertEquals(2, scpr.getColumnNames().length);
  assertEquals("ID_FK", scpr.getColumnNames()[0]);
  assertEquals("SECONDID_FK", scpr.getColumnNames()[1]);

  String colocateTable = rattr.getPartitionAttributes().getColocatedWith();
  assertEquals("/EMP/PARTITIONTESTTABLE", colocateTable);
}
 
Example #27
Source File: IndexCommandsDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #28
Source File: HDFSBucketRegionQueue.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public HDFSGatewayEventImpl get(Region region, byte[] regionKey,
    long minValue) {
  SortedEventQueue queue = regionToEventQueue.get(region.getFullPath());
  if(queue == null) {
    return null;
  }
  return queue.get(region, regionKey, minValue);
}
 
Example #29
Source File: PRClientServerRegionFunctionExecutionDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void regionSingleKeyExecutionNonHA(Boolean isByName,
    Function function, Boolean toRegister) {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final String testKey = "execKey";
  final Set testKeysSet = new HashSet();
  testKeysSet.add(testKey);
  DistributedSystem.setThreadsSocketPolicy(false);

  if (toRegister.booleanValue()) {
    FunctionService.registerFunction(function);
  } else {
    FunctionService.unregisterFunction(function.getId());
    assertNull(FunctionService.getFunction(function.getId()));
  }

  Execution dataSet = FunctionService.onRegion(region);

  region.put(testKey, new Integer(1));
  try {
    ArrayList<String> args = new ArrayList<String>();
    args.add(retryRegionName);
    args.add("regionSingleKeyExecutionNonHA");

    ResultCollector rs = execute(dataSet, testKeysSet, args,
        function, isByName);
    fail("Expected ServerConnectivityException not thrown!");
  } catch (Exception ex) {
    if (!(ex.getCause() instanceof ServerConnectivityException)
        && !(ex.getCause() instanceof FunctionInvocationTargetException)) {
      ex.printStackTrace();
      getLogWriter().info("Exception : ", ex);
      fail("Test failed after the execute operation");
    }
  }
}
 
Example #30
Source File: PartitionedRegionAsSubRegionDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void run2() throws CacheException
{
  Cache cache = getCache();
  Region parentRegion = cache.getRegion(Region.SEPARATOR + parentRegionName
      + Region.SEPARATOR + childRegionName);
  parentRegion.destroyRegion();
}