Search in sources :

Example 6 with DistributedSystemDisconnectedException

use of org.apache.geode.distributed.DistributedSystemDisconnectedException 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 7 with DistributedSystemDisconnectedException

use of org.apache.geode.distributed.DistributedSystemDisconnectedException in project geode by apache.

the class DistributionManager method handleManagerDeparture.

/**
   * used by the DistributedMembershipListener and startup and shutdown operations, this method
   * decrements the number of nodes and handles lower-level clean up of the resources used by the
   * departed manager
   */
public void handleManagerDeparture(InternalDistributedMember theId, boolean p_crashed, String p_reason) {
    boolean crashed = p_crashed;
    String reason = p_reason;
    AlertAppender.getInstance().removeAlertListener(theId);
    // but still in the javagroup view.
    try {
        selectElder();
    } catch (DistributedSystemDisconnectedException e) {
    // keep going
    }
    int vmType = theId.getVmKind();
    if (vmType == ADMIN_ONLY_DM_TYPE) {
        removeUnfinishedStartup(theId, true);
        handleConsoleShutdown(theId, crashed, reason);
        return;
    }
    // not an admin VM...
    if (!isCurrentMember(theId)) {
        // fault tolerance
        return;
    }
    removeUnfinishedStartup(theId, true);
    if (removeManager(theId, crashed, reason)) {
        if (theId.getVmKind() != DistributionManager.LOCATOR_DM_TYPE) {
            this.stats.incNodes(-1);
        }
        StringId msg;
        if (crashed && !isCloseInProgress()) {
            msg = LocalizedStrings.DistributionManager_MEMBER_AT_0_UNEXPECTEDLY_LEFT_THE_DISTRIBUTED_CACHE_1;
            addMemberEvent(new MemberCrashedEvent(theId, reason));
        } else {
            msg = LocalizedStrings.DistributionManager_MEMBER_AT_0_GRACEFULLY_LEFT_THE_DISTRIBUTED_CACHE_1;
            addMemberEvent(new MemberDepartedEvent(theId, reason));
        }
        logger.info(LocalizedMessage.create(msg, new Object[] { theId, prettifyReason(reason) }));
        // Remove this manager from the serialQueueExecutor.
        if (this.serialQueuedExecutorPool != null) {
            serialQueuedExecutorPool.handleMemberDeparture(theId);
        }
    }
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) StringId(org.apache.geode.i18n.StringId)

Example 8 with DistributedSystemDisconnectedException

use of org.apache.geode.distributed.DistributedSystemDisconnectedException 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 9 with DistributedSystemDisconnectedException

use of org.apache.geode.distributed.DistributedSystemDisconnectedException in project geode by apache.

the class GMSMembershipManager method addSurpriseMember.

/**
   * Logic for handling a direct connection event (message received from a member not in the view).
   * Does not employ the startup queue.
   * <p>
   * Must be called with {@link #latestViewLock} held. Waits until there is a stable view. If the
   * member has already been added, simply returns; else adds the member.
   *
   * @param dm the member joining
   */
public boolean addSurpriseMember(DistributedMember dm) {
    final InternalDistributedMember member = (InternalDistributedMember) dm;
    boolean warn = false;
    latestViewWriteLock.lock();
    try {
        // other means.
        if (latestView.contains(member)) {
            return true;
        }
        if (surpriseMembers.containsKey(member)) {
            return true;
        }
        if (member.getVmViewId() < 0) {
            logger.warn("adding a surprise member that has not yet joined the distributed system: " + member, new Exception("stack trace"));
        }
        if (latestView.getViewId() > member.getVmViewId()) {
            // tell the process that it should shut down distribution.
            // Run in a separate thread so we don't hold the view lock during the request. Bug #44995
            new Thread(Thread.currentThread().getThreadGroup(), "Removing shunned GemFire node " + member) {

                @Override
                public void run() {
                    // fix for bug #42548
                    // this is an old member that shouldn't be added
                    logger.warn(LocalizedMessage.create(LocalizedStrings.GroupMembershipService_Invalid_Surprise_Member, new Object[] { member, latestView }));
                    requestMemberRemoval(member, "this member is no longer in the view but is initiating connections");
                }
            }.start();
            addShunnedMember(member);
            return false;
        }
        // Adding him to this set ensures we won't remove him if a new
        // view comes in and he's still not visible.
        surpriseMembers.put(member, Long.valueOf(System.currentTimeMillis()));
        if (shutdownInProgress()) {
            // Force disconnect, esp. the TCPConduit
            String msg = LocalizedStrings.GroupMembershipService_THIS_DISTRIBUTED_SYSTEM_IS_SHUTTING_DOWN.toLocalizedString();
            if (directChannel != null) {
                try {
                    directChannel.closeEndpoint(member, msg);
                } catch (DistributedSystemDisconnectedException e) {
                // ignore - happens during shutdown
                }
            }
            // for good luck
            destroyMember(member, msg);
            // allow during shutdown
            return true;
        }
        if (isShunned(member)) {
            warn = true;
            surpriseMembers.remove(member);
        } else {
            // Ensure that the member is accounted for in the view
            // Conjure up a new view including the new member. This is necessary
            // because we are about to tell the listener about a new member, so
            // the listener should rightfully expect that the member is in our
            // membership view.
            // However, we put the new member at the end of the list. This
            // should ensure he's not chosen as an elder.
            // This will get corrected when he finally shows up in the
            // view.
            NetView newMembers = new NetView(latestView, latestView.getViewId());
            newMembers.add(member);
            latestView = newMembers;
        }
    } finally {
        latestViewWriteLock.unlock();
    }
    if (warn) {
        // fix for bug #41538 - deadlock while alerting
        logger.warn(LocalizedMessage.create(LocalizedStrings.GroupMembershipService_MEMBERSHIP_IGNORING_SURPRISE_CONNECT_FROM_SHUNNED_MEMBER_0, member));
    } else {
        listener.newMemberConnected(member);
    }
    return !warn;
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) MemberShunnedException(org.apache.geode.internal.tcp.MemberShunnedException) TimeoutException(java.util.concurrent.TimeoutException) ShunnedMemberException(org.apache.geode.distributed.internal.direct.ShunnedMemberException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) CancelException(org.apache.geode.CancelException) DistributionException(org.apache.geode.distributed.internal.DistributionException) ForcedDisconnectException(org.apache.geode.ForcedDisconnectException) SystemConnectException(org.apache.geode.SystemConnectException) GemFireConfigException(org.apache.geode.GemFireConfigException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) ToDataException(org.apache.geode.ToDataException)

Example 10 with DistributedSystemDisconnectedException

use of org.apache.geode.distributed.DistributedSystemDisconnectedException in project geode by apache.

the class DirectChannel method acquireGroupSendPermission.

private void acquireGroupSendPermission(boolean ordered) {
    if (this.disconnected) {
        throw new org.apache.geode.distributed.DistributedSystemDisconnectedException(LocalizedStrings.DirectChannel_DIRECT_CHANNEL_HAS_BEEN_STOPPED.toLocalizedString());
    }
    // @todo darrel: add some stats
    final Semaphore s = getGroupSem(ordered);
    for (; ; ) {
        this.conduit.getCancelCriterion().checkCancelInProgress(null);
        boolean interrupted = Thread.interrupted();
        try {
            s.acquire();
            break;
        } catch (InterruptedException ex) {
            interrupted = true;
        } finally {
            if (interrupted) {
                Thread.currentThread().interrupt();
            }
        }
    }
    // for
    if (this.disconnected) {
        s.release();
        throw new DistributedSystemDisconnectedException(LocalizedStrings.DirectChannel_COMMUNICATIONS_DISCONNECTED.toLocalizedString());
    }
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) org.apache.geode(org.apache.geode) ReentrantSemaphore(org.apache.geode.internal.util.concurrent.ReentrantSemaphore) Semaphore(java.util.concurrent.Semaphore)

Aggregations

DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)42 IOException (java.io.IOException)15 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)15 Test (org.junit.Test)9 CancelException (org.apache.geode.CancelException)7 ReplyException (org.apache.geode.distributed.internal.ReplyException)7 Iterator (java.util.Iterator)6 CacheClosedException (org.apache.geode.cache.CacheClosedException)6 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)6 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 Cache (org.apache.geode.cache.Cache)4 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 InternalCache (org.apache.geode.internal.cache.InternalCache)4 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)4 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)4 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)4 InterruptedIOException (java.io.InterruptedIOException)3