use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class DistributionManager method getElderId.
public InternalDistributedMember getElderId() throws DistributedSystemDisconnectedException {
// membershipManager.waitForEventProcessing();
if (closeInProgress) {
throw new DistributedSystemDisconnectedException(LocalizedStrings.DistributionManager_NO_VALID_ELDER_WHEN_SYSTEM_IS_SHUTTING_DOWN.toLocalizedString(), this.getRootCause());
}
getSystem().getCancelCriterion().checkCancelInProgress(null);
// Cache a recent value of the elder
InternalDistributedMember result = elder;
if (result != null && membershipManager.memberExists(result)) {
return result;
}
logger.info(LocalizedMessage.create(LocalizedStrings.DistributionManager_ELDER__0__IS_NOT_CURRENTLY_AN_ACTIVE_MEMBER_SELECTING_NEW_ELDER, elder));
// ShutdownException can be thrown here
selectElder();
logger.info(LocalizedMessage.create(LocalizedStrings.DistributionManager_NEWLY_SELECTED_ELDER_IS_NOW__0_, elder));
return elder;
}
use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class DistributionManager method getAllRoles.
/** Returns a set of all roles currently in the distributed system. */
public Set getAllRoles() {
Set allRoles = new HashSet();
Set mbrs = getDistributionManagerIds();
for (Iterator mbrIter = mbrs.iterator(); mbrIter.hasNext(); ) {
Set roles = ((InternalDistributedMember) mbrIter.next()).getRoles();
for (Iterator rolesIter = roles.iterator(); rolesIter.hasNext(); ) {
Role mbrRole = (Role) rolesIter.next();
allRoles.add(mbrRole);
}
}
return allRoles;
}
use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class DistributionManager method waitForElder.
/**
* Waits until elder if newElder or newElder is no longer a member
*
* @return true if newElder is the elder; false if he is no longer a member or we are the elder.
*/
public boolean waitForElder(final InternalDistributedMember desiredElder) {
MembershipListener l = null;
try {
// desiredElder.getVmKind() != DistributionManager.ADMIN_ONLY_DM_TYPE);
synchronized (this.elderMonitor) {
while (true) {
if (closeInProgress)
return false;
InternalDistributedMember currentElder = this.elder;
// currentElder.getVmKind() != DistributionManager.ADMIN_ONLY_DM_TYPE);
if (desiredElder.equals(currentElder)) {
return true;
}
if (!isCurrentMember(desiredElder)) {
// no longer present
return false;
}
if (this.myid.equals(currentElder)) {
// elder so don't let them wait anymore.
return false;
}
if (l == null) {
l = new MembershipListener() {
public void memberJoined(InternalDistributedMember theId) {
// nothing needed
}
public void memberDeparted(InternalDistributedMember theId, boolean crashed) {
if (desiredElder.equals(theId)) {
notifyElderChangeWaiters();
}
}
public void memberSuspect(InternalDistributedMember id, InternalDistributedMember whoSuspected, String reason) {
}
public void viewInstalled(NetView view) {
}
public void quorumLost(Set<InternalDistributedMember> failures, List<InternalDistributedMember> remaining) {
}
};
addMembershipListener(l);
}
logger.info(LocalizedMessage.create(LocalizedStrings.DistributionManager_CHANGING_ELDER_FROM_0_TO_1, new Object[] { currentElder, desiredElder }));
elderChangeWait();
}
// while true
}
} finally {
if (l != null) {
removeMembershipListener(l);
}
}
}
use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class DistributionChannel method getId.
/**
* Returns the id of this distribution channel. If this channel uses JavaGroups and the conduit to
* communicate with others, then the port of the JavaGroups channel's
* {@link InternalDistributedMember address} is returned.
*
* @since GemFire 3.0
*/
public long getId() {
MembershipManager mgr = this.membershipManager;
if (mgr == null) {
throw new DistributedSystemDisconnectedException(LocalizedStrings.DistributionChannel_I_NO_LONGER_HAVE_A_MEMBERSHIP_ID.toLocalizedString());
}
InternalDistributedMember moi = mgr.getLocalMember();
if (moi == null) {
throw new DistributedSystemDisconnectedException(LocalizedStrings.DistributionChannel_I_NO_LONGER_HAVE_A_MEMBERSHIP_ID.toLocalizedString(), membershipManager.getShutdownCause());
}
return moi.getPort();
}
use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class DistributionManager method setUnfinishedStartups.
public void setUnfinishedStartups(Collection s) {
synchronized (unfinishedStartupsLock) {
Assert.assertTrue(unfinishedStartups == null, "Set unfinished startups twice");
unfinishedStartups = new HashSet(s);
// OK, I don't _quite_ trust the list to be current, so let's
// prune it here.
Iterator it = unfinishedStartups.iterator();
synchronized (this.membersLock) {
while (it.hasNext()) {
InternalDistributedMember m = (InternalDistributedMember) it.next();
if (!isCurrentMember(m)) {
it.remove();
}
}
// while
}
// synchronized
}
}
Aggregations