use of org.apache.geode.cache.client.internal.ProxyRegion in project geode by apache.
the class FunctionServiceManager method onRegion.
/**
* Returns an {@link Execution} object that can be used to execute a data dependent function on
* the specified Region.<br>
* When invoked from a GemFire client, the method returns an Execution instance that sends a
* message to one of the connected servers as specified by the {@link Pool} for the region. <br>
* Depending on the filters setup on the {@link Execution}, the function is executed on all
* GemFire members that define the data region, or a subset of members.
* {@link Execution#withFilter(Set)}).
*
* For DistributedRegions with DataPolicy.NORMAL, it throws UnsupportedOperationException. For
* DistributedRegions with DataPolicy.EMPTY, execute the function on any random member which has
* DataPolicy.REPLICATE <br>
* . For DistributedRegions with DataPolicy.REPLICATE, execute the function locally. For Regions
* with DataPolicy.PARTITION, it executes on members where the data resides as specified by the
* filter.
*
* @return Execution
* @throws FunctionException if the region passed in is null
* @since GemFire 6.0
*/
public Execution onRegion(Region region) {
if (region == null) {
throw new FunctionException(LocalizedStrings.FunctionService_0_PASSED_IS_NULL.toLocalizedString("Region instance "));
}
ProxyCache proxyCache = null;
String poolName = region.getAttributes().getPoolName();
if (poolName != null) {
Pool pool = PoolManager.find(poolName);
if (pool.getMultiuserAuthentication()) {
if (region instanceof ProxyRegion) {
ProxyRegion proxyRegion = (ProxyRegion) region;
region = proxyRegion.getRealRegion();
proxyCache = proxyRegion.getAuthenticatedCache();
} else {
throw new UnsupportedOperationException();
}
}
}
if (isClientRegion(region)) {
return new ServerRegionFunctionExecutor(region, proxyCache);
}
if (PartitionRegionHelper.isPartitionedRegion(region)) {
return new PartitionedRegionFunctionExecutor(region);
}
return new DistributedRegionFunctionExecutor(region);
}
use of org.apache.geode.cache.client.internal.ProxyRegion in project geode by apache.
the class ClientRegionFactoryJUnitTest method testMultiUserRootRegions.
@Test
public void testMultiUserRootRegions() throws Exception {
DistributedSystem ds = DistributedSystem.connect(createGemFireProperties());
PoolManager.createFactory().addServer(InetAddress.getLocalHost().getHostName(), 7777).setMultiuserAuthentication(true).create("muPool");
PoolManager.createFactory().addServer(InetAddress.getLocalHost().getHostName(), 6666).create("suPool");
ClientCache cc = new ClientCacheFactory().create();
cc.createClientRegionFactory(PROXY).setPoolName("muPool").create("p");
cc.createClientRegionFactory(CACHING_PROXY).setPoolName("suPool").create("cp");
cc.createClientRegionFactory(LOCAL).create("l");
assertEquals(3, cc.rootRegions().size());
{
Properties muProps = new Properties();
muProps.setProperty("user", "foo");
RegionService rs = cc.createAuthenticatedView(muProps, "muPool");
assertNotNull(rs.getRegion("p"));
try {
rs.getRegion("cp");
fail("expected IllegalStateException");
} catch (IllegalStateException expected) {
}
try {
rs.getRegion("l");
fail("expected IllegalStateException");
} catch (IllegalStateException expected) {
}
assertEquals(1, rs.rootRegions().size());
assertEquals(true, rs.getRegion("p") instanceof ProxyRegion);
assertEquals(true, rs.rootRegions().iterator().next() instanceof ProxyRegion);
}
}
Aggregations