use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class DestroyEntryPropagationDUnitTest method acquireConnectionsAndDestroyEntriesK1andK2.
private void acquireConnectionsAndDestroyEntriesK1andK2() {
try {
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r1);
String poolName = r1.getAttributes().getPoolName();
assertNotNull(poolName);
PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
assertNotNull(pool);
Connection conn = pool.acquireConnection();
final Connection conn1;
if (conn.getServer().getPort() != PORT2) {
// Ensure we have a server with the proper port
conn1 = pool.acquireConnection();
} else {
conn1 = conn;
}
assertNotNull(conn1);
assertEquals(PORT2, conn1.getServer().getPort());
ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
srp.destroyOnForTestsOnly(conn1, "key1", null, Operation.DESTROY, new EventIDHolder(new EventID(new byte[] { 1 }, 100000, 1)), null);
srp.destroyOnForTestsOnly(conn1, "key2", null, Operation.DESTROY, new EventIDHolder(new EventID(new byte[] { 1 }, 100000, 2)), null);
} catch (Exception ex) {
throw new AssertionError("Failed while setting acquireConnectionsAndDestroyEntry ", ex);
}
}
use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class GatewaySenderEventRemoteDispatcher method destroyConnection.
public void destroyConnection() {
this.connectionLifeCycleLock.writeLock().lock();
try {
Connection con = this.connection;
if (con != null) {
if (!con.isDestroyed()) {
con.destroy();
this.sender.getProxy().returnConnection(con);
}
// Reset the connection so the next time through a new one will be
// obtained
this.connection = null;
this.sender.setServerLocation(null);
}
} finally {
this.connectionLifeCycleLock.writeLock().unlock();
}
}
use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class WANLocatorServerDUnitTest method createClient.
public static void createClient(Integer port1, Integer port2, Integer port3) {
ClientCacheFactory cf = new ClientCacheFactory();
cache = (Cache) cf.create();
PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
pf.setReadTimeout(0);
pf.setIdleTimeout(-1);
pf.setMinConnections(4);
pf.setServerGroup(GatewayReceiver.RECEIVER_GROUP);
pf.addLocator("localhost", port1);
pf.addLocator("localhost", port2);
pf.addLocator("localhost", port3);
pf.init((GatewaySender) null);
proxy = ((PoolImpl) pf.create("KISHOR_POOL"));
Connection con1 = proxy.acquireConnection();
try {
con1.close(true);
} catch (Exception e) {
fail("createClient failed", e);
}
}
use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class PooledConnection method switchConnection.
public synchronized boolean switchConnection(Connection newCon) throws InterruptedException {
Connection oldCon = null;
synchronized (this) {
if (shouldDestroy())
return false;
if (this.active && !shouldDestroy()) {
this.waitingToSwitch = true;
try {
while (this.active && !shouldDestroy()) {
wait();
}
} finally {
this.waitingToSwitch = false;
notifyAll();
}
}
if (shouldDestroy())
return false;
assert !this.active;
final long now = System.nanoTime();
oldCon = this.connection;
this.connection = newCon;
this.endpoint = newCon.getEndpoint();
this.birthDate = now;
}
if (oldCon != null) {
try {
// do this outside of sync
oldCon.close(false);
} catch (Exception e) {
// ignore
}
}
return true;
}
use of org.apache.geode.cache.client.internal.Connection in project geode by apache.
the class PooledConnection method internalDestroy.
public void internalDestroy() {
// probably already set but make sure
this.shouldDestroy.set(true);
synchronized (this) {
this.active = false;
notifyAll();
Connection myCon = connection;
if (myCon != null) {
myCon.destroy();
connection = null;
}
}
}
Aggregations