use of org.apache.geode.cache.client.internal.UserAttributes 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.client.internal.UserAttributes 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.client.internal.UserAttributes in project geode by apache.
the class CqServiceImpl method addToCqMap.
/**
* Adds the given CQ and cqQuery object into the CQ map.
*/
void addToCqMap(CqQueryImpl cq) throws CqExistsException, CqException {
// On server side cqName will be server side cqName.
String sCqName = cq.getServerCqName();
if (logger.isDebugEnabled()) {
logger.debug("Adding to CQ Repository. CqName : {} ServerCqName : {}", cq.getName(), sCqName);
}
HashMap<String, CqQueryImpl> cqMap = cqQueryMap;
if (cqMap.containsKey(sCqName)) {
throw new CqExistsException(LocalizedStrings.CqService_A_CQ_WITH_THE_GIVEN_NAME_0_ALREADY_EXISTS.toLocalizedString(sCqName));
}
synchronized (cqQueryMapLock) {
HashMap<String, CqQueryImpl> tmpCqQueryMap = new HashMap<>(cqQueryMap);
try {
tmpCqQueryMap.put(sCqName, cq);
} catch (Exception ex) {
StringId errMsg = LocalizedStrings.CqQueryImpl_FAILED_TO_STORE_CONTINUOUS_QUERY_IN_THE_REPOSITORY_CQNAME_0_1;
Object[] errMsgArgs = new Object[] { sCqName, ex.getLocalizedMessage() };
String s = errMsg.toLocalizedString(errMsgArgs);
logger.error(s);
throw new CqException(s, ex);
}
UserAttributes attributes = UserAttributes.userAttributes.get();
if (attributes != null) {
this.cqNameToUserAttributesMap.put(cq.getName(), attributes);
}
cqQueryMap = tmpCqQueryMap;
}
}
Aggregations