use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class ConnectionProxyJUnitTest method testListenerOnServerSitForever.
/**
* This test verifies the behaviour of client request when the listener on the server sits
* forever. This is done in following steps:<br>
* 1)create server<br>
* 2)initialize proxy object and create region for client having a CacheListener and make
* afterCreate in the listener to wait infinitely<br>
* 3)perform a PUT on client by acquiring Connection through proxy<br>
* 4)Verify that exception occurs due to infinite wait in the listener<br>
* 5)Verify that above exception occurs sometime after the readTimeout configured for the client
* <br>
*
*/
@Ignore
@Test
public void testListenerOnServerSitForever() throws Exception {
int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
Region testRegion = null;
CacheServer server = this.cache.addCacheServer();
server.setMaximumTimeBetweenPings(10000);
server.setPort(port3);
server.start();
try {
PoolFactory pf = PoolManager.createFactory();
pf.addServer("localhost", port3);
pf.setSubscriptionEnabled(false);
pf.setSubscriptionRedundancy(-1);
pf.setReadTimeout(2000);
pf.setThreadLocalConnections(true);
pf.setSocketBufferSize(32768);
pf.setRetryAttempts(1);
pf.setPingInterval(10000);
proxy = (PoolImpl) pf.create("clientPool");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setCacheListener(new CacheListenerAdapter() {
public void afterCreate(EntryEvent event) {
synchronized (ConnectionProxyJUnitTest.this) {
try {
ConnectionProxyJUnitTest.this.wait();
} catch (InterruptedException e) {
fail("interrupted");
}
}
}
});
RegionAttributes attrs = factory.create();
testRegion = cache.createRegion("testregion", attrs);
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to initialize client");
}
Connection conn = (proxy).acquireConnection();
long t1 = 0;
try {
t1 = System.currentTimeMillis();
EntryEventImpl event = new EntryEventImpl((Object) null);
try {
event.setEventId(new EventID(new byte[] { 1 }, 1, 1));
PutOp.execute(conn, proxy, testRegion.getFullPath(), "key1", "val1", event, null, false);
} finally {
event.release();
}
fail("Test failed as exception was expected");
} catch (Exception e) {
long t2 = System.currentTimeMillis();
long net = (t2 - t1);
assertTrue(net / 1000 < 5);
}
synchronized (ConnectionProxyJUnitTest.this) {
ConnectionProxyJUnitTest.this.notify();
}
}
use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class EventIdOptimizationDUnitTest method generateEventsByPutOperation.
/**
* Generates events having specific values of threadId and sequenceId, via put operation through
* connection object
*
* @throws Exception - thrown if any problem occurs in put operation
*/
public static void generateEventsByPutOperation() throws Exception {
Connection connection = pool.acquireConnection();
String regionName = Region.SEPARATOR + REGION_NAME;
ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);
for (int i = 0; i < eventIds.length; i++) {
srp.putOnForTestsOnly(connection, "KEY-" + i, "VAL-" + i, eventIds[i], null);
}
srp.putOnForTestsOnly(connection, LAST_KEY, "LAST_VAL", eventIdForLastKey, null);
}
use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class EventIdOptimizationDUnitTest method generateEventsByClearRegionOperation.
/**
* Generates events having specific values of threadId and sequenceId, via clearRegionOperation
* through connection object
*
* @throws Exception - thrown if any problem occurs in clearRegionOperation
*/
public static void generateEventsByClearRegionOperation() throws Exception {
Connection connection = pool.acquireConnection();
String regionName = Region.SEPARATOR + REGION_NAME;
ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);
for (int i = 0; i < eventIds.length; i++) {
srp.clearOnForTestsOnly(connection, eventIds[i], null);
}
srp.clearOnForTestsOnly(connection, eventIdForLastKey, null);
}
use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class EventIdOptimizationDUnitTest method generateEventsByDestroyRegionOperation.
/**
* Generates events having specific values of threadId and sequenceId, via destroyRegionOperation
* through connection object
*
* @throws Exception - thrown if any problem occurs in destroyRegionOperation
*/
public static void generateEventsByDestroyRegionOperation() throws Exception {
Connection connection = pool.acquireConnection();
String regionName = Region.SEPARATOR + REGION_NAME;
for (int i = 0; i < 1; i++) {
ServerRegionProxy srp = new ServerRegionProxy(regionName + i, pool);
srp.destroyRegionOnForTestsOnly(connection, eventIds[i], null);
}
{
ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);
srp.destroyRegionOnForTestsOnly(connection, eventIdForLastKey, null);
}
}
use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class RemoteParallelGatewaySenderEventProcessor method shouldSendVersionEvents.
/**
* Returns if corresponding receiver WAN site of this GatewaySender has GemfireVersion > 7.0.1
*
* @param disp
* @return true if remote site Gemfire Version is >= 7.0.1
*/
private boolean shouldSendVersionEvents(GatewaySenderEventDispatcher disp) throws GatewaySenderException {
try {
GatewaySenderEventRemoteDispatcher remoteDispatcher = (GatewaySenderEventRemoteDispatcher) disp;
// This will create a new connection if no batch has been sent till
// now.
Connection conn = remoteDispatcher.getConnection(false);
if (conn != null) {
short remoteSiteVersion = conn.getWanSiteVersion();
if (Version.GFE_701.compareTo(remoteSiteVersion) <= 0) {
return true;
}
}
} catch (GatewaySenderException e) {
Throwable cause = e.getCause();
if (cause instanceof IOException || e instanceof GatewaySenderConfigurationException || cause instanceof ConnectionDestroyedException) {
try {
int sleepInterval = GatewaySender.CONNECTION_RETRY_INTERVAL;
if (logger.isDebugEnabled()) {
logger.debug("Sleeping for {} milliseconds", sleepInterval);
}
Thread.sleep(sleepInterval);
} catch (InterruptedException ie) {
// log the exception
if (logger.isDebugEnabled()) {
logger.debug(ie.getMessage(), ie);
}
}
}
throw e;
}
return false;
}
Aggregations