use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class DeltaPropagationDUnitTest method testS2CDeltaPropagationWithGIIAndFailover.
@Test
public void testS2CDeltaPropagationWithGIIAndFailover() throws Exception {
prepareDeltas();
VM0.invoke(() -> DeltaPropagationDUnitTest.prepareDeltas());
VM1.invoke(() -> DeltaPropagationDUnitTest.prepareDeltas());
VM2.invoke(() -> DeltaPropagationDUnitTest.prepareDeltas());
VM0.invoke(() -> DeltaPropagationDUnitTest.closeCache());
PORT1 = ((Integer) VM0.invoke(() -> DeltaPropagationDUnitTest.createServerCache(HARegionQueue.HA_EVICTION_POLICY_NONE, new Integer(1), new Integer(NO_LISTENER)))).intValue();
PORT2 = ((Integer) VM1.invoke(() -> DeltaPropagationDUnitTest.createServerCache(HARegionQueue.HA_EVICTION_POLICY_NONE, new Integer(1), new Integer(NO_LISTENER)))).intValue();
int port3 = ((Integer) VM2.invoke(() -> DeltaPropagationDUnitTest.createServerCache(HARegionQueue.HA_EVICTION_POLICY_NONE, new Integer(1), new Integer(NO_LISTENER)))).intValue();
// Do puts after slowing the dispatcher.
try {
VM0.invoke(() -> ConflationDUnitTest.setIsSlowStart("60000"));
VM1.invoke(() -> ConflationDUnitTest.setIsSlowStart("60000"));
VM2.invoke(() -> ConflationDUnitTest.setIsSlowStart("60000"));
createClientCache(new int[] { PORT1, PORT2, port3 }, "1", DistributionConfig.CLIENT_CONFLATION_PROP_VALUE_DEFAULT, new Integer(CLIENT_LISTENER), null, null);
Region r = cache.getRegion("/" + regionName);
assertNotNull(r);
r.registerInterest("ALL_KEYS");
VM primary = (((PoolImpl) pool).getPrimaryPort() == PORT1) ? VM0 : ((((PoolImpl) pool).getPrimaryPort() == PORT2) ? VM1 : VM2);
primary.invoke(() -> DeltaPropagationDUnitTest.createAndUpdateDeltas());
Thread.sleep(5000);
primary.invoke(() -> DeltaPropagationDUnitTest.closeCache());
Thread.sleep(5000);
primary = (((PoolImpl) pool).getPrimaryPort() == PORT1) ? VM0 : ((((PoolImpl) pool).getPrimaryPort() == PORT2) ? VM1 : VM2);
VM0.invoke(() -> ConflationDUnitTest.unsetIsSlowStart());
VM1.invoke(() -> ConflationDUnitTest.unsetIsSlowStart());
VM2.invoke(() -> ConflationDUnitTest.unsetIsSlowStart());
primary.invoke(() -> DeltaPropagationDUnitTest.closeCache());
Thread.sleep(5000);
primary = (((PoolImpl) pool).getPrimaryPort() == PORT1) ? VM0 : ((((PoolImpl) pool).getPrimaryPort() == PORT2) ? VM1 : VM2);
org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("waiting for client to receive last_key");
waitForLastKey();
long fromDeltasOnClient = DeltaTestImpl.getFromDeltaInvokations().longValue();
assertTrue((EVENTS_SIZE - 1) + " deltas were to be received but were " + fromDeltasOnClient, fromDeltasOnClient == (EVENTS_SIZE - 1));
} finally {
VM0.invoke(() -> ConflationDUnitTest.unsetIsSlowStart());
VM1.invoke(() -> ConflationDUnitTest.unsetIsSlowStart());
VM2.invoke(() -> ConflationDUnitTest.unsetIsSlowStart());
}
}
use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class DurableClientSimpleDUnitTest method testReadyForEventsNotCalledImplicitly.
@Test
public void testReadyForEventsNotCalledImplicitly() {
// Start a server
int serverPort = ((Integer) this.server1VM.invoke(() -> CacheServerTestUtil.createCacheServer(regionName, new Boolean(true)))).intValue();
// Start a durable client that is not kept alive on the server when it
// stops normally
final String durableClientId = getName() + "_client";
// make the client use ClientCacheFactory so it will have a default pool
this.durableClientVM.invoke(() -> CacheServerTestUtil.createClientCache(getClientPool(getServerHostName(durableClientVM.getHost()), serverPort, true), regionName, getClientDistributedSystemProperties(durableClientId)));
// verify that readyForEvents has not yet been called on the client's default pool
this.durableClientVM.invoke(new CacheSerializableRunnable("check readyForEvents not called") {
@Override
public void run2() throws CacheException {
for (Pool p : PoolManager.getAll().values()) {
assertEquals(false, ((PoolImpl) p).getReadyForEventsCalled());
}
}
});
// Send clientReady message
this.durableClientVM.invoke(new CacheSerializableRunnable("Send clientReady") {
@Override
public void run2() throws CacheException {
CacheServerTestUtil.getCache().readyForEvents();
}
});
// Verify durable clients on server
this.server1VM.invoke(new CacheSerializableRunnable("Verify durable client") {
@Override
public void run2() throws CacheException {
// Get the CacheClientNotifier
CacheClientNotifier notifier = getBridgeServer().getAcceptor().getCacheClientNotifier();
// Iterate the CacheClientProxies and verify they are correct
checkNumberOfClientProxies(1);
boolean durableClient1Found = false, durableClient2Found = false;
for (Iterator i = notifier.getClientProxies().iterator(); i.hasNext(); ) {
CacheClientProxy proxy = (CacheClientProxy) i.next();
assertTrue(proxy.isDurable());
if (proxy.getDurableId().equals(durableClientId)) {
durableClient1Found = true;
}
assertEquals(DistributionConfig.DEFAULT_DURABLE_CLIENT_TIMEOUT, proxy.getDurableTimeout());
}
assertTrue(durableClient1Found);
}
});
// Stop the durable clients
this.durableClientVM.invoke(() -> CacheServerTestUtil.closeCache());
// Stop the server
this.server1VM.invoke(() -> CacheServerTestUtil.closeCache());
}
use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class HAInterestTestCase method createClientPoolCacheWithSmallRetryInterval.
public static void createClientPoolCacheWithSmallRetryInterval(String testName, String host) throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
new HAInterestTestCase().createCache(props);
CacheServerTestUtil.disableShufflingOfEndpoints();
PoolImpl p;
try {
p = (PoolImpl) PoolManager.createFactory().addServer(host, PORT1).addServer(host, PORT2).setSubscriptionEnabled(true).setSubscriptionRedundancy(-1).setReadTimeout(10000).setSocketBufferSize(32768).setMinConnections(6).setPingInterval(200).create("HAInterestBaseTestPool");
} finally {
CacheServerTestUtil.enableShufflingOfEndpoints();
}
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setConcurrencyChecksEnabled(true);
factory.setPoolName(p.getName());
cache.createRegion(REGION_NAME, factory.create());
pool = p;
conn = pool.acquireConnection();
assertNotNull(conn);
}
use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class HAStartupAndFailoverDUnitTest method createClientCacheWithLargeRetryInterval.
public static void createClientCacheWithLargeRetryInterval(String testName, String host) throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
new HAStartupAndFailoverDUnitTest().createCache(props);
PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(host, PORT1.intValue()).addServer(host, PORT2.intValue()).addServer(host, PORT3.intValue()).setSubscriptionEnabled(true).setSubscriptionRedundancy(-1).setReadTimeout(10000).create("HAStartupAndFailoverDUnitTestPool");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setPoolName(p.getName());
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
pool = p;
conn = pool.acquireConnection();
assertNotNull(conn);
}
use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class HAStartupAndFailoverDUnitTest method createClientCacheWithLargeRetryIntervalAndWithoutCallbackConnection.
public static void createClientCacheWithLargeRetryIntervalAndWithoutCallbackConnection(String testName, String host) throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
new HAStartupAndFailoverDUnitTest().createCache(props);
CacheServerTestUtil.disableShufflingOfEndpoints();
PoolImpl p;
try {
p = (PoolImpl) PoolManager.createFactory().addServer(host, PORT1.intValue()).addServer(host, PORT2.intValue()).addServer(host, PORT3.intValue()).setPingInterval(500).create("HAStartupAndFailoverDUnitTestPool");
} finally {
CacheServerTestUtil.enableShufflingOfEndpoints();
}
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setPoolName(p.getName());
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
pool = p;
// since the default minConnections is 1 we currently have a connection to
// server1 (vm_0). Now we create a connection to server2 (vm_1)
conn = pool.acquireConnection(new ServerLocation(Host.getHost(0).getHostName(), PORT2));
// assert that the conn is to server2 since the tests assume that this is so
assertNotNull(conn);
assertTrue(conn.getEndpoint().getLocation().getPort() == PORT2);
}
Aggregations