use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class RemoteQueryDUnitTest method stopBridgeServer.
/**
* Stops the bridge server that serves up the given cache.
*/
protected void stopBridgeServer(Cache cache) {
CacheServer bridge = (CacheServer) cache.getCacheServers().iterator().next();
bridge.stop();
assertFalse(bridge.isRunning());
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class RemoteQueryDUnitTest method startBridgeServer.
/**
* Starts a bridge server on the given port, using the given deserializeValues and
* notifyBySubscription to serve up the given region.
*/
protected void startBridgeServer(int port, boolean notifyBySubscription) throws IOException {
Cache cache = getCache();
CacheServer bridge = cache.addCacheServer();
bridge.setPort(port);
bridge.setNotifyBySubscription(notifyBySubscription);
bridge.start();
bridgeServerPort = bridge.getPort();
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class QueryParamsAuthorizationDUnitTest method testQueryParamsInAuthCallback.
@Ignore("Bug 51079")
@Test
public void testQueryParamsInAuthCallback() throws Exception {
final Host host = Host.getHost(0);
final VM server1 = host.getVM(0);
final VM client = host.getVM(1);
// create servers and regions
final int port = (Integer) server1.invoke(new SerializableCallable("Create Server1") {
@Override
public Object call() throws Exception {
CacheFactory cf = new CacheFactory().set(MCAST_PORT, "0").set(SECURITY_CLIENT_ACCESSOR, "org.apache.geode.cache.query.dunit.QueryAuthorization.create").set(SECURITY_CLIENT_AUTHENTICATOR, DummyAuthenticator.class.getName() + ".create");
Cache cache = getCache(cf);
cache.createRegionFactory(RegionShortcut.REPLICATE).create(regName);
CacheServer server = cache.addCacheServer();
int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
server.setPort(port);
server.start();
return port;
}
});
// create client
client.invoke(new SerializableCallable("Create client") {
@Override
public Object call() throws Exception {
ClientCacheFactory ccf = new ClientCacheFactory().addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port).set(SECURITY_CLIENT_AUTH_INIT, UserPasswordAuthInit.class.getName() + ".create").set(SECURITY_PREFIX + "username", "root").set(SECURITY_PREFIX + "password", "root");
ClientCache cache = getClientCache(ccf);
Region r1 = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regName);
for (int i = 0; i < 20; i++) {
r1.put("key-" + i, new Portfolio(i));
}
QueryService qs = cache.getQueryService();
Object[] params = new Object[] { "active", 0 };
SelectResults sr = (SelectResults) qs.newQuery("select * from " + r1.getFullPath() + " where status = $1 and ID > $2 ").execute(params);
assertTrue("Result size should be greater than 0 ", sr.size() > 0);
return null;
}
});
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class CacheXml66DUnitTest method testDynamicRegionFactoryConnectionPool.
@Test
public void testDynamicRegionFactoryConnectionPool() throws Exception, IOException {
IgnoredException.addIgnoredException("Connection reset");
IgnoredException.addIgnoredException("SocketTimeoutException");
IgnoredException.addIgnoredException("ServerConnectivityException");
IgnoredException.addIgnoredException("Socket Closed");
getSystem();
VM vm0 = Host.getHost(0).getVM(0);
final int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
vm0.invoke(new SerializableCallable("Create cache server") {
public Object call() throws IOException {
DynamicRegionFactory.get().open();
Cache cache = getCache();
CacheServer bridge = cache.addCacheServer();
bridge.setPort(port);
bridge.setNotifyBySubscription(true);
bridge.start();
return null;
}
});
CacheCreation cache = new CacheCreation();
cache.createPoolFactory().addServer(NetworkUtils.getServerHostName(vm0.getHost()), port).setSubscriptionEnabled(true).create("connectionPool");
cache.setDynamicRegionFactoryConfig(new DynamicRegionFactory.Config(null, "connectionPool", false, false));
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
cache.createRegion("root", attrs);
// note that testXml can't check if they are same because enabling
// dynamic regions causes a meta region to be produced.
testXml(cache, false);
assertEquals(false, DynamicRegionFactory.get().getConfig().getRegisterInterest());
assertEquals(false, DynamicRegionFactory.get().getConfig().getPersistBackup());
assertEquals(true, DynamicRegionFactory.get().isOpen());
assertEquals(null, DynamicRegionFactory.get().getConfig().getDiskDir());
assertEquals("connectionPool", DynamicRegionFactory.get().getConfig().getPoolName());
Region dr = getCache().getRegion("__DynamicRegions");
if (dr != null) {
dr.localDestroyRegion();
}
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class CacheXml66DUnitTest method testTwoCacheServerGroups.
@Test
public void testTwoCacheServerGroups() throws Exception {
CacheCreation cache = new CacheCreation();
CacheServer bs = cache.addCacheServer();
bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
String[] groups = new String[] { "group1", "group2" };
bs.setGroups(groups);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
assertNotNull(server);
assertEquals(Arrays.asList(groups), Arrays.asList(server.getGroups()));
}
Aggregations