use of org.apache.geode.internal.cache.ClientServerObserverAdapter in project geode by apache.
the class FailoverDUnitTest method setClientServerObserver.
public static void setClientServerObserver() {
PoolImpl.BEFORE_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = true;
ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {
public void beforePrimaryIdentificationFromBackup() {
primary.invoke(() -> FailoverDUnitTest.putDuringFailover());
PoolImpl.BEFORE_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = false;
}
});
}
use of org.apache.geode.internal.cache.ClientServerObserverAdapter in project geode by apache.
the class DurableResponseMatrixDUnitTest method testRegisterInterest_Destroy_Concurrent.
@Test
public void testRegisterInterest_Destroy_Concurrent() throws Exception {
PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = true;
ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {
public void beforeInterestRegistration() {
Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME);
r.put(KEY, "AgainDummyValue");
r.destroy(KEY);
PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false;
}
});
Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME);
r.put(KEY, "DummyValue");
server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry(KEY, "ValueMatrix1"));
r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES);
assertEquals(null, r.getEntry(KEY));
}
use of org.apache.geode.internal.cache.ClientServerObserverAdapter in project geode by apache.
the class RedundancyLevelPart3DUnitTest method testRegisterInterestAndMakePrimaryWithFullRedundancy.
/**
* This tests failing of a primary server in a situation where teh rest of the server are all
* redundant. After every failure, the order, the dispatcher, the interest registration and the
* makePrimary calls are verified. The failure detection in these tests could be either through
* CCU or cache operation, whichever occurs first
*/
@Test
public void testRegisterInterestAndMakePrimaryWithFullRedundancy() {
try {
CacheServerTestUtil.disableShufflingOfEndpoints();
createClientCache(NetworkUtils.getServerHostName(Host.getHost(0)), PORT1, PORT2, PORT3, PORT4, 3);
createEntriesK1andK2();
registerK1AndK2();
assertEquals(3, pool.getRedundantNames().size());
server0.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsAlive());
server1.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsNotAlive());
server2.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsNotAlive());
server3.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsNotAlive());
server0.invoke(() -> RedundancyLevelTestBase.verifyInterestRegistration());
server1.invoke(() -> RedundancyLevelTestBase.verifyInterestRegistration());
server2.invoke(() -> RedundancyLevelTestBase.verifyInterestRegistration());
server3.invoke(() -> RedundancyLevelTestBase.verifyInterestRegistration());
PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = true;
PoolImpl.BEFORE_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = true;
PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = true;
registerInterestCalled = false;
makePrimaryCalled = false;
ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {
public void beforeInterestRegistration() {
registerInterestCalled = true;
}
public void beforeInterestRecovery() {
registerInterestCalled = true;
}
public void beforePrimaryIdentificationFromBackup() {
makePrimaryCalled = true;
}
});
server0.invoke(() -> RedundancyLevelTestBase.stopServer());
doPuts();
server1.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsAlive());
server2.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsNotAlive());
server3.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsNotAlive());
verifyLiveAndRedundantServers(3, 2);
if (registerInterestCalled) {
fail("register interest should not have been called since we failed to a redundant server !");
}
if (!makePrimaryCalled) {
fail("make primary should have been called since primary did fail and a new primary was to be chosen ");
}
assertEquals(2, pool.getRedundantNames().size());
makePrimaryCalled = false;
server1.invoke(() -> RedundancyLevelTestBase.stopServer());
doPuts();
server2.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsAlive());
server3.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsNotAlive());
verifyLiveAndRedundantServers(2, 1);
if (registerInterestCalled) {
fail("register interest should not have been called since we failed to a redundant server !");
}
if (!makePrimaryCalled) {
fail("make primary should have been called since primary did fail and a new primary was to be chosen ");
}
assertEquals(1, pool.getRedundantNames().size());
makePrimaryCalled = false;
server2.invoke(() -> RedundancyLevelTestBase.stopServer());
doPuts();
server3.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsAlive());
verifyLiveAndRedundantServers(1, 0);
if (registerInterestCalled) {
fail("register interest should not have been called since we failed to a redundant server !");
}
if (!makePrimaryCalled) {
fail("make primary should have been called since primary did fail and a new primary was to be chosen ");
}
assertEquals(0, pool.getRedundantNames().size());
server3.invoke(() -> RedundancyLevelTestBase.stopServer());
server0.invoke(() -> RedundancyLevelTestBase.startServer());
doPuts();
server0.invoke(() -> RedundancyLevelTestBase.verifyDispatcherIsAlive());
server0.invoke(() -> RedundancyLevelTestBase.verifyInterestRegistration());
verifyLiveAndRedundantServers(1, 0);
if (!registerInterestCalled) {
fail("register interest should have been called since a recovered server came up!");
}
assertEquals(0, pool.getRedundantNames().size());
PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false;
PoolImpl.BEFORE_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = false;
PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false;
} catch (Exception ex) {
ex.printStackTrace();
Assert.fail("test failed due to exception in test testRedundancySpecifiedMoreThanEPs ", ex);
}
}
use of org.apache.geode.internal.cache.ClientServerObserverAdapter in project geode by apache.
the class Simple2CacheServerDUnitTest method setClientServerObserver.
public static void setClientServerObserver() {
PoolImpl.AFTER_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = true;
ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {
public void afterPrimaryIdentificationFromBackup(ServerLocation primaryEndpoint) {
LogService.getLogger().info("After primary is set");
afterPrimaryCount++;
}
});
}
use of org.apache.geode.internal.cache.ClientServerObserverAdapter in project geode by apache.
the class DurableClientSimpleDUnitTest method setPeriodicACKObserver.
private void setPeriodicACKObserver(VM vm) {
CacheSerializableRunnable cacheSerializableRunnable = new CacheSerializableRunnable("Set ClientServerObserver") {
@Override
public void run2() throws CacheException {
PoolImpl.BEFORE_SENDING_CLIENT_ACK_CALLBACK_FLAG = true;
ClientServerObserver origObserver = ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {
@Override
public void beforeSendingClientAck() {
LogWriterUtils.getLogWriter().info("beforeSendingClientAck invoked");
}
});
}
};
vm.invoke(cacheSerializableRunnable);
}
Aggregations