use of org.apache.geode.cache.client.internal.ServerRegionProxy 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.ServerRegionProxy in project geode by apache.
the class ClearPropagationDUnitTest method acquireConnectionsAndClear.
public static void acquireConnectionsAndClear(String host) {
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 conn1 = pool.acquireConnection(new ServerLocation(host, PORT2));
assertNotNull(conn1);
assertEquals(PORT2, conn1.getServer().getPort());
ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
srp.clearOnForTestsOnly(conn1, new EventID(new byte[] { 1 }, 1, 1), null);
} catch (Exception ex) {
ex.printStackTrace();
fail("while setting acquireConnections " + ex);
}
}
use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.
the class Bug36269DUnitTest method acquireConnectionsAndDestroyRegion.
public static void acquireConnectionsAndDestroyRegion(String host) {
try {
Connection desCon = pool.acquireConnection(new ServerLocation(host, PORT2));
ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
srp.destroyRegionOnForTestsOnly(desCon, new EventID(new byte[] { 1 }, 1, 1), null);
} catch (Exception ex) {
Assert.fail("while setting acquireConnections", ex);
}
}
use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.
the class HAInterestTestCase method stopSecondaryAndRegisterK1AndK2AndVerifyResponse.
/**
* returns the secondary that was stopped
*/
public static VM stopSecondaryAndRegisterK1AndK2AndVerifyResponse() {
LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r);
ServerRegionProxy srp = new ServerRegionProxy(r);
WaitCriterion wc = new WaitCriterion() {
@Override
public boolean done() {
return pool.getConnectedServerCount() == 3;
}
@Override
public String description() {
return "Never got three connected servers";
}
};
Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
// close secondary EP
VM result = getBackupVM();
result.invoke(() -> HAInterestTestCase.stopServer());
List list = new ArrayList();
list.add(k1);
list.add(k2);
List serverKeys = srp.registerInterest(list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
assertNotNull(serverKeys);
List resultKeys = (List) serverKeys.get(0);
assertEquals(2, resultKeys.size());
assertTrue(resultKeys.contains(k1));
assertTrue(resultKeys.contains(k2));
return result;
}
use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.
the class HAInterestTestCase method registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse.
public static void registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse() {
ServerLocation primary = pool.getPrimary();
ServerLocation secondary = (ServerLocation) pool.getRedundants().get(0);
LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r);
ServerRegionProxy srp = new ServerRegionProxy(r);
List list = new ArrayList();
list.add(k1);
list.add(k2);
// Primary server
List serverKeys1 = srp.registerInterestOn(primary, list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
assertNotNull(serverKeys1);
// expect serverKeys in response from primary
List resultKeys = (List) serverKeys1.get(0);
assertEquals(2, resultKeys.size());
assertTrue(resultKeys.contains(k1));
assertTrue(resultKeys.contains(k2));
// Secondary server
List serverKeys2 = srp.registerInterestOn(secondary, list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
// if the list is null then it is empty
if (serverKeys2 != null) {
// no serverKeys in response from secondary
assertTrue(serverKeys2.isEmpty());
}
}
Aggregations