use of org.apache.geode.distributed.internal.direct.DirectChannel in project geode by apache.
the class GMSMembershipManager method waitForMessageState.
public void waitForMessageState(DistributedMember otherMember, Map state) throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
DirectChannel dc = directChannel;
if (dc != null) {
dc.waitForChannelState(otherMember, state);
}
services.getMessenger().waitForMessageState((InternalDistributedMember) otherMember, state);
if (services.getConfig().getTransport().isMcastEnabled() && !services.getConfig().getDistributionConfig().getDisableTcp()) {
// GEODE-2865: wait for scheduled multicast messages to be applied to the cache
waitForSerialMessageProcessing((InternalDistributedMember) otherMember);
}
}
use of org.apache.geode.distributed.internal.direct.DirectChannel in project geode by apache.
the class GMSMembershipManager method waitForDeparture.
/*
* (non-Javadoc) MembershipManager method: wait for the given member to be gone. Throws
* TimeoutException if the wait goes too long
*
* @see
* org.apache.geode.distributed.internal.membership.MembershipManager#waitForDeparture(org.apache.
* geode.distributed.DistributedMember)
*/
public boolean waitForDeparture(DistributedMember mbr) throws TimeoutException, InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
boolean result = false;
DirectChannel dc = directChannel;
InternalDistributedMember idm = (InternalDistributedMember) mbr;
int memberTimeout = this.services.getConfig().getDistributionConfig().getMemberTimeout();
long pauseTime = (memberTimeout < 1000) ? 100 : memberTimeout / 10;
boolean wait;
int numWaits = 0;
do {
wait = false;
if (dc != null) {
if (dc.hasReceiversFor(idm)) {
wait = true;
}
if (wait && logger.isDebugEnabled()) {
logger.info("waiting for receivers for {} to shut down", mbr);
}
}
if (!wait) {
latestViewReadLock.lock();
try {
wait = this.latestView.contains(idm);
} finally {
latestViewReadLock.unlock();
}
if (wait && logger.isDebugEnabled()) {
logger.debug("waiting for {} to leave the membership view", mbr);
}
}
if (!wait) {
if (waitForSerialMessageProcessing(idm)) {
result = true;
}
}
if (wait) {
numWaits++;
if (numWaits > 40) {
// waited over 4 * memberTimeout ms. Give up at this point
throw new TimeoutException("waited too long for " + idm + " to be removed");
}
Thread.sleep(pauseTime);
}
} while (wait && (dc != null && dc.isOpen()) && !services.getCancelCriterion().isCancelInProgress());
if (logger.isDebugEnabled()) {
logger.debug("operations for {} should all be in the cache at this point", mbr);
}
return result;
}
use of org.apache.geode.distributed.internal.direct.DirectChannel in project geode by apache.
the class GMSMembershipManagerJUnitTest method setUpDirectChannelMock.
/**
* Some tests require a DirectChannel mock
*/
private void setUpDirectChannelMock() throws Exception {
dc = mock(DirectChannel.class);
when(dc.send(any(GMSMembershipManager.class), any(mockMembers.getClass()), any(DistributionMessage.class), anyInt(), anyInt())).thenReturn(100);
manager.start();
manager.started();
manager.setDirectChannel(dc);
NetView view = new NetView(myMemberId, 1, members);
manager.installView(view);
when(joinLeave.getView()).thenReturn(view);
manager.startEventProcessing();
}
use of org.apache.geode.distributed.internal.direct.DirectChannel in project geode by apache.
the class GMSMembershipManager method getMessageState.
/*
* non-thread-owned serial channels and high priority channels are not included
*/
public Map getMessageState(DistributedMember member, boolean includeMulticast) {
Map result = new HashMap();
DirectChannel dc = directChannel;
if (dc != null) {
dc.getChannelStates(member, result);
}
services.getMessenger().getMessageState((InternalDistributedMember) member, result, includeMulticast);
return result;
}
use of org.apache.geode.distributed.internal.direct.DirectChannel in project geode by apache.
the class GMSMembershipManager method destroyMember.
/**
* Clean up and create consistent new view with member removed. No uplevel events are generated.
*
* Must be called with the {@link #latestViewLock} held.
*/
private void destroyMember(final InternalDistributedMember member, final String reason) {
// Make sure it is removed from the view
latestViewWriteLock.lock();
try {
if (latestView.contains(member)) {
NetView newView = new NetView(latestView, latestView.getViewId());
newView.remove(member);
latestView = newView;
}
} finally {
latestViewWriteLock.unlock();
}
surpriseMembers.remove(member);
// here breaks the recursion.
if (!isShunned(member)) {
addShunnedMember(member);
}
final DirectChannel dc = directChannel;
if (dc != null) {
// if (crashed) {
// dc.closeEndpoint(member, reason);
// }
// else
// Bug 37944: make sure this is always done in a separate thread,
// so that shutdown conditions don't wedge the view lock
{
// fix for bug 34010
Thread t = new Thread() {
@Override
public void run() {
try {
Thread.sleep(Integer.getInteger("p2p.disconnectDelay", 3000).intValue());
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
// Keep going, try to close the endpoint.
}
if (!dc.isOpen()) {
return;
}
if (logger.isDebugEnabled())
logger.debug("Membership: closing connections for departed member {}", member);
// close connections, but don't do membership notification since it's already been done
dc.closeEndpoint(member, reason, false);
}
};
t.setDaemon(true);
t.setName("disconnect thread for " + member);
t.start();
}
// fix for bug 34010
}
}
Aggregations