use of org.apache.geode.distributed.internal.membership.MembershipTestHook in project geode by apache.
the class GMSMembershipManager method uncleanShutdown.
public void uncleanShutdown(String reason, final Exception e) {
inhibitForcedDisconnectLogging(false);
if (services.getShutdownCause() == null) {
services.setShutdownCause(e);
}
if (this.directChannel != null) {
this.directChannel.disconnect(e);
}
// first shut down communication so we don't do any more harm to other
// members
services.emergencyClose();
if (e != null) {
try {
if (membershipTestHooks != null) {
List l = membershipTestHooks;
for (final Object aL : l) {
MembershipTestHook dml = (MembershipTestHook) aL;
dml.beforeMembershipFailure(reason, e);
}
}
listener.membershipFailure(reason, e);
if (membershipTestHooks != null) {
List l = membershipTestHooks;
for (final Object aL : l) {
MembershipTestHook dml = (MembershipTestHook) aL;
dml.afterMembershipFailure(reason, e);
}
}
} catch (RuntimeException re) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GroupMembershipService_EXCEPTION_CAUGHT_WHILE_SHUTTING_DOWN), re);
}
}
}
use of org.apache.geode.distributed.internal.membership.MembershipTestHook in project geode by apache.
the class ReconnectWithCacheXMLDUnitTest method testCacheServerLauncherPortRetained.
@Test
public void testCacheServerLauncherPortRetained() throws Exception {
CacheServerLauncher.setDisableDefaultServer(true);
CacheServerLauncher.setServerPort(AvailablePortHelper.getRandomAvailableTCPPort());
Cache cache = getCache();
final AtomicBoolean membershipFailed = new AtomicBoolean();
MembershipManagerHelper.addTestHook(cache.getDistributedSystem(), new MembershipTestHook() {
@Override
public void beforeMembershipFailure(String reason, Throwable cause) {
membershipFailed.set(true);
}
@Override
public void afterMembershipFailure(String reason, Throwable cause) {
}
});
MembershipManagerHelper.crashDistributedSystem(cache.getDistributedSystem());
assertTrue(membershipFailed.get());
WaitCriterion wc = new WaitCriterion() {
@Override
public boolean done() {
return cache.getReconnectedCache() != null;
}
@Override
public String description() {
return "waiting for cache to reconnect";
}
};
Wait.waitForCriterion(wc, 60000, 5000, true);
await().atMost(60, TimeUnit.SECONDS).until(() -> cache.getReconnectedCache() != null);
Cache newCache = cache.getReconnectedCache();
CacheServer server = newCache.getCacheServers().iterator().next();
assertEquals(CacheServerLauncher.getServerPort().intValue(), server.getPort());
// this setting is in the XML file
assertEquals(20, server.getMaxConnections());
}
Aggregations