Search in sources :

Example 1 with ShunnedMemberException

use of org.apache.geode.distributed.internal.direct.ShunnedMemberException in project geode by apache.

the class GMSMembershipManager method directChannelSend.

/**
   * Perform the grossness associated with sending a message over a DirectChannel
   *
   * @param destinations the list of destinations
   * @param content the message
   * @param theStats the statistics object to update
   * @return all recipients who did not receive the message (null if all received it)
   * @throws NotSerializableException if the message is not serializable
   */
protected Set<InternalDistributedMember> directChannelSend(InternalDistributedMember[] destinations, DistributionMessage content, DMStats theStats) throws NotSerializableException {
    boolean allDestinations;
    InternalDistributedMember[] keys;
    if (content.forAll()) {
        allDestinations = true;
        latestViewReadLock.lock();
        try {
            List<InternalDistributedMember> keySet = latestView.getMembers();
            keys = new InternalDistributedMember[keySet.size()];
            keys = keySet.toArray(keys);
        } finally {
            latestViewReadLock.unlock();
        }
    } else {
        allDestinations = false;
        keys = destinations;
    }
    int sentBytes;
    try {
        sentBytes = directChannel.send(this, keys, content, this.services.getConfig().getDistributionConfig().getAckWaitThreshold(), this.services.getConfig().getDistributionConfig().getAckSevereAlertThreshold());
        if (theStats != null) {
            theStats.incSentBytes(sentBytes);
        }
        if (sentBytes == 0) {
            if (services.getCancelCriterion().isCancelInProgress()) {
                throw new DistributedSystemDisconnectedException();
            }
        }
    } catch (DistributedSystemDisconnectedException ex) {
        if (services.getShutdownCause() != null) {
            throw new DistributedSystemDisconnectedException("DistributedSystem is shutting down", services.getShutdownCause());
        } else {
            // see bug 41416
            throw ex;
        }
    } catch (ConnectExceptions ex) {
        // Check if the connect exception is due to system shutting down.
        if (shutdownInProgress()) {
            if (services.getShutdownCause() != null) {
                throw new DistributedSystemDisconnectedException("DistributedSystem is shutting down", services.getShutdownCause());
            } else {
                throw new DistributedSystemDisconnectedException();
            }
        }
        if (allDestinations)
            return null;
        // We
        List<InternalDistributedMember> members = (List<InternalDistributedMember>) ex.getMembers();
        // need
        // to
        // return
        // this
        // list
        // of
        // failures
        // SANITY CHECK: If we fail to send a message to an existing member
        // of the view, we have a serious error (bug36202).
        // grab a recent view, excluding shunned
        NetView view = services.getJoinLeave().getView();
        // members
        // Iterate through members and causes in tandem :-(
        Iterator it_mem = members.iterator();
        Iterator it_causes = ex.getCauses().iterator();
        while (it_mem.hasNext()) {
            InternalDistributedMember member = (InternalDistributedMember) it_mem.next();
            Throwable th = (Throwable) it_causes.next();
            if (!view.contains(member) || (th instanceof ShunnedMemberException)) {
                continue;
            }
            logger.fatal(LocalizedMessage.create(LocalizedStrings.GroupMembershipService_FAILED_TO_SEND_MESSAGE_0_TO_MEMBER_1_VIEW_2, new Object[] { content, member, view }), th);
        // Assert.assertTrue(false, "messaging contract failure");
        }
        return new HashSet<>(members);
    }// catch ConnectionExceptions
     catch (ToDataException | CancelException e) {
        throw e;
    } catch (IOException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Membership: directChannelSend caught exception: {}", e.getMessage(), e);
        }
        if (e instanceof NotSerializableException) {
            throw (NotSerializableException) e;
        }
    } catch (RuntimeException | Error e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Membership: directChannelSend caught exception: {}", e.getMessage(), e);
        }
        throw e;
    }
    return null;
}
Also used : ShunnedMemberException(org.apache.geode.distributed.internal.direct.ShunnedMemberException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) ConnectExceptions(org.apache.geode.internal.tcp.ConnectExceptions) NetView(org.apache.geode.distributed.internal.membership.NetView) InternalGemFireError(org.apache.geode.InternalGemFireError) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ToDataException(org.apache.geode.ToDataException) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) CancelException(org.apache.geode.CancelException)

Aggregations

IOException (java.io.IOException)1 NotSerializableException (java.io.NotSerializableException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 CancelException (org.apache.geode.CancelException)1 InternalGemFireError (org.apache.geode.InternalGemFireError)1 ToDataException (org.apache.geode.ToDataException)1 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)1 ShunnedMemberException (org.apache.geode.distributed.internal.direct.ShunnedMemberException)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 NetView (org.apache.geode.distributed.internal.membership.NetView)1 ConnectExceptions (org.apache.geode.internal.tcp.ConnectExceptions)1