use of org.apache.geode.cache.RegionService in project geode by apache.
the class ClientCacheFactoryJUnitTest method test003DPmultiplePool.
/**
* Make sure if we have more than one pool that we do not have a default
*/
@Test
public void test003DPmultiplePool() throws Exception {
Properties dsProps = new Properties();
dsProps.setProperty(MCAST_PORT, "0");
DistributedSystem ds = DistributedSystem.connect(dsProps);
PoolManager.createFactory().addServer(InetAddress.getLocalHost().getHostName(), 7777).create("p7");
PoolManager.createFactory().addServer(InetAddress.getLocalHost().getHostName(), 6666).create("p6");
this.cc = new ClientCacheFactory().create();
GemFireCacheImpl gfc = (GemFireCacheImpl) this.cc;
assertEquals(true, gfc.isClient());
Pool defPool = gfc.getDefaultPool();
assertEquals(null, defPool);
// exists that is not multiuser enabled
try {
Properties suProps = new Properties();
suProps.setProperty("user", "foo");
RegionService cc = this.cc.createAuthenticatedView(suProps);
fail("expected IllegalStateException");
} catch (IllegalStateException ignore) {
}
// however we should be to to create it by configuring a pool
{
Properties suProps = new Properties();
suProps.setProperty("user", "foo");
Pool pool = PoolManager.createFactory().addServer(InetAddress.getLocalHost().getHostName(), CacheServer.DEFAULT_PORT).setMultiuserAuthentication(true).create("pool1");
RegionService cc = this.cc.createAuthenticatedView(suProps, pool.getName());
ProxyCache pc = (ProxyCache) cc;
UserAttributes ua = pc.getUserAttributes();
Pool proxyDefPool = ua.getPool();
assertEquals(Collections.singletonList(new InetSocketAddress(InetAddress.getLocalHost(), CacheServer.DEFAULT_PORT)), proxyDefPool.getServers());
assertEquals(true, proxyDefPool.getMultiuserAuthentication());
}
}
use of org.apache.geode.cache.RegionService in project geode by apache.
the class ClientCacheFactoryJUnitTest method test002DPsinglePool.
/**
* Make sure if we have a single pool that it will be used as the default
*/
@Test
public void test002DPsinglePool() throws Exception {
Properties dsProps = new Properties();
dsProps.setProperty(MCAST_PORT, "0");
DistributedSystem ds = DistributedSystem.connect(dsProps);
Pool p = PoolManager.createFactory().addServer(InetAddress.getLocalHost().getHostName(), 7777).create("singlePool");
this.cc = new ClientCacheFactory().create();
GemFireCacheImpl gfc = (GemFireCacheImpl) this.cc;
assertEquals(true, gfc.isClient());
Pool defPool = gfc.getDefaultPool();
assertEquals(p, defPool);
// exists that is not multiuser enabled
try {
Properties suProps = new Properties();
suProps.setProperty("user", "foo");
RegionService cc = this.cc.createAuthenticatedView(suProps);
fail("expected IllegalStateException");
} catch (IllegalStateException ignore) {
}
// however we should be to to create it by configuring a pool
{
Properties suProps = new Properties();
suProps.setProperty("user", "foo");
Pool pool = PoolManager.createFactory().addServer(InetAddress.getLocalHost().getHostName(), CacheServer.DEFAULT_PORT).setMultiuserAuthentication(true).create("pool1");
RegionService cc = this.cc.createAuthenticatedView(suProps, pool.getName());
ProxyCache pc = (ProxyCache) cc;
UserAttributes ua = pc.getUserAttributes();
Pool proxyDefPool = ua.getPool();
assertEquals(Collections.singletonList(new InetSocketAddress(InetAddress.getLocalHost(), CacheServer.DEFAULT_PORT)), proxyDefPool.getServers());
assertEquals(true, proxyDefPool.getMultiuserAuthentication());
}
}
use of org.apache.geode.cache.RegionService in project geode by apache.
the class MemoryAllocatorImpl method getRegionLiveChunks.
/**
* Returns a possibly empty list that contains all the Chunks used by regions.
*/
private List<OffHeapStoredObject> getRegionLiveChunks() {
ArrayList<OffHeapStoredObject> result = new ArrayList<OffHeapStoredObject>();
RegionService gfc = GemFireCacheImpl.getInstance();
if (gfc != null) {
Iterator<Region<?, ?>> rootIt = gfc.rootRegions().iterator();
while (rootIt.hasNext()) {
Region<?, ?> rr = rootIt.next();
getRegionLiveChunks(rr, result);
Iterator<Region<?, ?>> srIt = rr.subregions(true).iterator();
while (srIt.hasNext()) {
getRegionLiveChunks(srIt.next(), result);
}
}
}
return result;
}
use of org.apache.geode.cache.RegionService in project geode by apache.
the class ClientCacheFactoryJUnitTest method test005SecureUserDefaults.
@Test
public void test005SecureUserDefaults() throws Exception {
Properties suProps = new Properties();
suProps.setProperty("user", "foo");
GemFireCacheImpl gfc = (GemFireCacheImpl) new ClientCacheFactory().setPoolMultiuserAuthentication(true).create();
this.cc = gfc;
RegionService cc1 = this.cc.createAuthenticatedView(suProps);
assertEquals(true, gfc.isClient());
Properties dsProps = this.cc.getDistributedSystem().getProperties();
assertEquals("0", dsProps.getProperty(MCAST_PORT));
assertEquals("", dsProps.getProperty(LOCATORS));
Pool defPool = gfc.getDefaultPool();
assertEquals("DEFAULT", defPool.getName());
assertEquals(new ArrayList(), defPool.getLocators());
assertEquals(Collections.singletonList(new InetSocketAddress(InetAddress.getLocalHost(), CacheServer.DEFAULT_PORT)), defPool.getServers());
assertEquals(true, defPool.getMultiuserAuthentication());
// make sure we can create another secure user cache
RegionService cc2 = this.cc.createAuthenticatedView(suProps);
assertEquals(true, gfc.isClient());
assertEquals("0", dsProps.getProperty(MCAST_PORT));
assertEquals("", dsProps.getProperty(LOCATORS));
defPool = gfc.getDefaultPool();
assertEquals("DEFAULT", defPool.getName());
assertEquals(new ArrayList(), defPool.getLocators());
assertEquals(Collections.singletonList(new InetSocketAddress(InetAddress.getLocalHost(), CacheServer.DEFAULT_PORT)), defPool.getServers());
assertEquals(true, defPool.getMultiuserAuthentication());
if (cc1 == cc2) {
fail("expected two different secure user caches");
}
}
Aggregations