Search in sources :

Example 11 with InternalDistributedMember

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;
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember)

Example 12 with InternalDistributedMember

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;
}
Also used : Role(org.apache.geode.distributed.Role) Set(java.util.Set) HashSet(java.util.HashSet) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 13 with InternalDistributedMember

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);
        }
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) DistributedMembershipListener(org.apache.geode.distributed.internal.membership.DistributedMembershipListener)

Example 14 with InternalDistributedMember

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();
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) MembershipManager(org.apache.geode.distributed.internal.membership.MembershipManager)

Example 15 with InternalDistributedMember

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
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Aggregations

InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)516 Test (org.junit.Test)162 HashSet (java.util.HashSet)124 Set (java.util.Set)77 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)63 NetView (org.apache.geode.distributed.internal.membership.NetView)60 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)56 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)55 ArrayList (java.util.ArrayList)54 DistributedMember (org.apache.geode.distributed.DistributedMember)49 UnitTest (org.apache.geode.test.junit.categories.UnitTest)49 HashMap (java.util.HashMap)46 IOException (java.io.IOException)36 Iterator (java.util.Iterator)34 PartitionedRegionLoadModel (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel)34 CompositeDirector (org.apache.geode.internal.cache.partitioned.rebalance.CompositeDirector)33 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)32 Map (java.util.Map)29 CancelException (org.apache.geode.CancelException)29 DM (org.apache.geode.distributed.internal.DM)29