Search in sources :

Example 81 with NetView

use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.

the class GMSMembershipManager method memberExists.

public boolean memberExists(DistributedMember m) {
    latestViewReadLock.lock();
    NetView v = latestView;
    latestViewReadLock.unlock();
    return v.contains(m);
}
Also used : NetView(org.apache.geode.distributed.internal.membership.NetView)

Example 82 with NetView

use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.

the class JGroupsMessenger method handleJGroupsIOException.

/**
   * If JGroups is unable to send a message it may mean that the network is down. If so we need to
   * initiate suspect processing on the recipient.
   * <p>
   * see Transport._send()
   */
@SuppressWarnings("UnusedParameters")
public void handleJGroupsIOException(IOException e, Address dest) {
    if (services.getManager().shutdownInProgress()) {
        // shutdown
        return;
    }
    if (addressesWithIoExceptionsProcessed.contains(dest)) {
        return;
    }
    addressesWithIoExceptionsProcessed.add(dest);
    NetView v = this.view;
    JGAddress jgMbr = (JGAddress) dest;
    if (jgMbr != null && v != null) {
        List<InternalDistributedMember> members = v.getMembers();
        InternalDistributedMember recipient = null;
        for (InternalDistributedMember mbr : members) {
            GMSMember gmsMbr = ((GMSMember) mbr.getNetMember());
            if (jgMbr.getUUIDLsbs() == gmsMbr.getUuidLSBs() && jgMbr.getUUIDMsbs() == gmsMbr.getUuidMSBs() && jgMbr.getVmViewId() == gmsMbr.getVmViewId()) {
                recipient = mbr;
                break;
            }
        }
        if (recipient != null) {
            services.getHealthMonitor().suspect(recipient, "Unable to send messages to this member via JGroups");
        }
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) GMSMember(org.apache.geode.distributed.internal.membership.gms.GMSMember) NetView(org.apache.geode.distributed.internal.membership.NetView)

Example 83 with NetView

use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.

the class JGroupsMessenger method getQuorumChecker.

public QuorumChecker getQuorumChecker() {
    NetView view = this.view;
    if (view == null) {
        view = services.getJoinLeave().getView();
        if (view == null) {
            view = services.getJoinLeave().getPreviousView();
            if (view == null) {
                return null;
            }
        }
    }
    GMSQuorumChecker qc = new GMSQuorumChecker(view, services.getConfig().getLossThreshold(), this.myChannel);
    qc.initialize();
    return qc;
}
Also used : NetView(org.apache.geode.distributed.internal.membership.NetView)

Example 84 with NetView

use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.

the class GMSHealthMonitor method processSuspectMembersRequest.

/**
   * Process a Suspect request from another member. This may cause this member to become the new
   * membership coordinator. it will to final check on that member and then it will send remove
   * request for that member
   */
private void processSuspectMembersRequest(SuspectMembersMessage incomingRequest) {
    this.stats.incSuspectsReceived();
    NetView cv = currentView;
    if (cv == null) {
        return;
    }
    List<SuspectRequest> sMembers = incomingRequest.getMembers();
    InternalDistributedMember sender = incomingRequest.getSender();
    int viewId = sender.getVmViewId();
    if (cv.getViewId() >= viewId && !cv.contains(incomingRequest.getSender())) {
        logger.info("Membership ignoring suspect request for " + incomingRequest + " from non-member " + incomingRequest.getSender());
        services.getJoinLeave().remove(sender, "this process is initiating suspect processing but is no longer a member");
        return;
    }
    // take care of any suspicion of this member by sending a heartbeat back
    if (!playingDead) {
        for (Iterator<SuspectRequest> it = incomingRequest.getMembers().iterator(); it.hasNext(); ) {
            SuspectRequest req = it.next();
            if (req.getSuspectMember().equals(localAddress)) {
                HeartbeatMessage message = new HeartbeatMessage(-1);
                message.setRecipient(sender);
                try {
                    services.getMessenger().send(message);
                    this.stats.incHeartbeatsSent();
                    it.remove();
                } catch (CancelException e) {
                    return;
                }
            }
        }
    }
    if (cv.getCoordinator().equals(localAddress)) {
        for (SuspectRequest req : incomingRequest.getMembers()) {
            logger.info("received suspect message from {} for {}: {}", sender, req.getSuspectMember(), req.getReason());
        }
        checkIfAvailable(sender, sMembers, cv);
    } else // coordinator ends
    {
        NetView check = new NetView(cv, cv.getViewId() + 1);
        ArrayList<SuspectRequest> smbr = new ArrayList<>();
        synchronized (viewVsSuspectedMembers) {
            recordSuspectRequests(sMembers, cv);
            Set<SuspectRequest> viewVsMembers = viewVsSuspectedMembers.get(cv);
            for (final SuspectRequest sr : viewVsMembers) {
                check.remove(sr.getSuspectMember());
                smbr.add(sr);
            }
        }
        InternalDistributedMember coordinator = check.getCoordinator();
        if (coordinator != null && coordinator.equals(localAddress)) {
            // new coordinator
            for (SuspectRequest req : incomingRequest.getMembers()) {
                logger.info("received suspect message from {} for {}: {}", sender, req.getSuspectMember(), req.getReason());
            }
            checkIfAvailable(sender, smbr, cv);
        } else {
            recordSuspectRequests(sMembers, cv);
        }
    }
}
Also used : HeartbeatMessage(org.apache.geode.distributed.internal.membership.gms.messages.HeartbeatMessage) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) ArrayList(java.util.ArrayList) CancelException(org.apache.geode.CancelException) SuspectRequest(org.apache.geode.distributed.internal.membership.gms.messages.SuspectRequest)

Example 85 with NetView

use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.

the class GMSHealthMonitor method checkMember.

private void checkMember(final InternalDistributedMember mbr) {
    final NetView cv = GMSHealthMonitor.this.currentView;
    // as check may take time
    setNextNeighbor(cv, mbr);
    // we need to check this member
    checkExecutor.execute(() -> {
        boolean pinged = false;
        try {
            pinged = GMSHealthMonitor.this.doCheckMember(mbr, true);
        } catch (CancelException e) {
            return;
        }
        if (!pinged) {
            suspectedMemberInView.put(mbr, currentView);
            String reason = "Member isn't responding to heartbeat requests";
            GMSHealthMonitor.this.initiateSuspicion(mbr, reason);
        } else {
            logger.trace("Setting next neighbor as member {} has responded.", mbr);
            suspectedMemberInView.remove(mbr);
            // back to previous one
            setNextNeighbor(GMSHealthMonitor.this.currentView, null);
        }
    });
}
Also used : NetView(org.apache.geode.distributed.internal.membership.NetView) CancelException(org.apache.geode.CancelException)

Aggregations

NetView (org.apache.geode.distributed.internal.membership.NetView)101 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)65 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)59 Test (org.junit.Test)59 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)57 HashSet (java.util.HashSet)25 InstallViewMessage (org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage)18 Message (org.jgroups.Message)14 ArrayList (java.util.ArrayList)12 JoinResponseMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage)10 UnitTest (org.apache.geode.test.junit.categories.UnitTest)10 LinkedList (java.util.LinkedList)9 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)9 IOException (java.io.IOException)8 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)8 Properties (java.util.Properties)7 FindCoordinatorResponse (org.apache.geode.distributed.internal.membership.gms.locator.FindCoordinatorResponse)7 CancelException (org.apache.geode.CancelException)6 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)6 JoinRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)6