Search in sources :

Example 11 with ReplyProcessor21

use of org.apache.geode.distributed.internal.ReplyProcessor21 in project geode by apache.

the class AllBucketProfilesUpdateMessage method send.

/**
   * Send a profile update to a set of members.
   * 
   * @param recipients the set of members to be notified
   * @param dm the distribution manager used to send the message
   * @param prId the unique partitioned region identifier
   * @param profiles bucked id to profile map
   * @param requireAck whether or not to expect a reply
   * @return an instance of reply processor if requireAck is true on which the caller can wait until
   *         the event has finished.
   */
public static ReplyProcessor21 send(Set recipients, DM dm, int prId, Map<Integer, BucketAdvisor.BucketProfile> profiles, boolean requireAck) {
    if (recipients.isEmpty()) {
        return null;
    }
    ReplyProcessor21 rp = null;
    int procId = 0;
    if (requireAck) {
        rp = new ReplyProcessor21(dm, recipients);
        procId = rp.getProcessorId();
    }
    AllBucketProfilesUpdateMessage m = new AllBucketProfilesUpdateMessage(recipients, prId, procId, profiles);
    dm.putOutgoing(m);
    return rp;
}
Also used : ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21)

Example 12 with ReplyProcessor21

use of org.apache.geode.distributed.internal.ReplyProcessor21 in project geode by apache.

the class BucketProfileUpdateMessage method send.

/**
   * Send a profile update to a set of members.
   * 
   * @param recipients the set of members to be notified
   * @param dm the distribution manager used to send the message
   * @param prId the unique partitioned region identifier
   * @param bucketId the unique bucket identifier
   * @param bp the updated bucket profile to send
   * @param requireAck whether or not to expect a reply
   * @return an instance of reply processor if requireAck is true on which the caller can wait until
   *         the event has finished.
   */
public static ReplyProcessor21 send(Set recipients, DM dm, int prId, int bucketId, BucketProfile bp, boolean requireAck) {
    if (recipients.isEmpty()) {
        return null;
    }
    ReplyProcessor21 rp = null;
    int procId = 0;
    if (requireAck) {
        rp = new ReplyProcessor21(dm, recipients);
        procId = rp.getProcessorId();
    }
    BucketProfileUpdateMessage m = new BucketProfileUpdateMessage(recipients, prId, procId, bucketId, bp);
    dm.putOutgoing(m);
    return rp;
}
Also used : ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21)

Example 13 with ReplyProcessor21

use of org.apache.geode.distributed.internal.ReplyProcessor21 in project geode by apache.

the class AcceptorImpl method start.

@Override
public void start() throws IOException {
    ThreadGroup tg = LoggingThreadGroup.createThreadGroup("Acceptor " + this.serverSock.getInetAddress() + ":" + this.localPort, logger);
    thread = new Thread(tg, this, "Cache Server Acceptor " + this.serverSock.getInetAddress() + ":" + this.localPort + " local port: " + this.serverSock.getLocalPort());
    this.acceptorId = thread.getId();
    // This thread should not be a daemon to keep BridgeServers created
    // in code from exiting immediately.
    thread.start();
    if (isSelector()) {
        Runnable r = new Runnable() {

            public void run() {
                AcceptorImpl.this.runSelectorLoop();
            }
        };
        this.selectorThread = new Thread(tg, r, "Cache Server Selector " + this.serverSock.getInetAddress() + ":" + this.localPort + " local port: " + this.serverSock.getLocalPort());
        this.selectorThread.start();
    }
    Set<PartitionedRegion> prs = this.cache.getPartitionedRegions();
    for (PartitionedRegion pr : prs) {
        Map<Integer, BucketAdvisor.BucketProfile> profiles = new HashMap<Integer, BucketAdvisor.BucketProfile>();
        // get all local real bucket advisors
        Map<Integer, BucketAdvisor> advisors = pr.getRegionAdvisor().getAllBucketAdvisors();
        for (Map.Entry<Integer, BucketAdvisor> entry : advisors.entrySet()) {
            BucketAdvisor advisor = entry.getValue();
            // addLocally
            BucketProfile bp = (BucketProfile) advisor.createProfile();
            advisor.updateServerBucketProfile(bp);
            // advisor.basicAddClientProfile(bp);
            profiles.put(entry.getKey(), bp);
        }
        Set receipients = new HashSet();
        receipients = pr.getRegionAdvisor().adviseAllPRNodes();
        // send it to all in one messgae
        ReplyProcessor21 reply = AllBucketProfilesUpdateMessage.send(receipients, pr.getDistributionManager(), pr.getPRId(), profiles, true);
        if (reply != null) {
            reply.waitForRepliesUninterruptibly();
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BucketProfile(org.apache.geode.internal.cache.BucketAdvisor.BucketProfile) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LoggingThreadGroup(org.apache.geode.internal.logging.LoggingThreadGroup) BucketAdvisor(org.apache.geode.internal.cache.BucketAdvisor) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet) ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21)

Example 14 with ReplyProcessor21

use of org.apache.geode.distributed.internal.ReplyProcessor21 in project geode by apache.

the class CheckTypeRegistryState method send.

public static void send(DM dm) {
    Set recipients = dm.getOtherDistributionManagerIds();
    ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, recipients);
    CheckTypeRegistryState msg = new CheckTypeRegistryState(replyProcessor.getProcessorId());
    msg.setRecipients(recipients);
    dm.putOutgoing(msg);
    try {
        replyProcessor.waitForReplies();
    } catch (ReplyException e) {
        if (e.getCause() instanceof PdxInitializationException) {
            throw new PdxInitializationException("Bad PDX configuration on member " + e.getSender() + ": " + e.getCause().getMessage(), e.getCause());
        } else {
            throw new InternalGemFireError("Unexpected exception", e);
        }
    } catch (InterruptedException e) {
        throw new InternalGemFireError("Unexpected exception", e);
    }
}
Also used : Set(java.util.Set) ReplyException(org.apache.geode.distributed.internal.ReplyException) PdxInitializationException(org.apache.geode.pdx.PdxInitializationException) ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 15 with ReplyProcessor21

use of org.apache.geode.distributed.internal.ReplyProcessor21 in project geode by apache.

the class TXLockServiceImpl method updateParticipants.

@Override
public void updateParticipants(TXLockId txLockId, final Set updatedParticipants) {
    synchronized (this.txLockIdList) {
        if (!this.txLockIdList.contains(txLockId)) {
            throw new IllegalArgumentException(LocalizedStrings.TXLockServiceImpl_INVALID_TXLOCKID_NOT_FOUND_0.toLocalizedString(txLockId));
        }
    }
    if (updatedParticipants == null) {
        throw new IllegalArgumentException(LocalizedStrings.TXLockServiceImpl_INVALID_UPDATEDPARTICIPANTS_NULL.toLocalizedString());
    }
    if (updatedParticipants.isEmpty()) {
        return;
    }
    if (!this.recovering) {
        // Serializable grantorId = this.dlock.getLockGrantorId();
        if (this.dlock.isLockGrantor()) {
            // Don't need to send a message (or wait for a reply)
            // logger.info("DEBUG: [TXLockServiceImpl.updateParticipants] this VM is the Grantor");
            TXLockUpdateParticipantsMessage.updateParticipants(this.dlock, txLockId, updatedParticipants);
        } else {
            // not lock grantor
            LockGrantorId lockGrantorId = txLockId.getLockGrantorId();
            if (lockGrantorId == null || !this.dlock.isLockGrantorId(lockGrantorId)) {
                // grantor is gone so we cannot update him
                return;
            }
            InternalDistributedMember grantorId = lockGrantorId.getLockGrantorMember();
            // logger.info("DEBUG: [TXLockServiceImpl.updateParticipants] sending update message to
            // Grantor " + grantorId);
            ReplyProcessor21 processor = new ReplyProcessor21(this.dlock.getDistributionManager(), grantorId);
            TXLockUpdateParticipantsMessage dlup = new TXLockUpdateParticipantsMessage(txLockId, this.dlock.getName(), updatedParticipants, processor.getProcessorId());
            dlup.setRecipient(grantorId);
            this.dlock.getDistributionManager().putOutgoing(dlup);
            // for() loop removed for bug 36983 - you can't loop on waitForReplies()
            this.dlock.getDistributionManager().getCancelCriterion().checkCancelInProgress(null);
            try {
                processor.waitForRepliesUninterruptibly();
            } catch (ReplyException e) {
                e.handleAsUnexpected();
            }
        }
    // not lock grantor
    }
// not recovering
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) LockGrantorId(org.apache.geode.distributed.internal.locks.LockGrantorId) ReplyException(org.apache.geode.distributed.internal.ReplyException) ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21)

Aggregations

ReplyProcessor21 (org.apache.geode.distributed.internal.ReplyProcessor21)28 HashSet (java.util.HashSet)11 Set (java.util.Set)10 DM (org.apache.geode.distributed.internal.DM)7 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)7 ReplyException (org.apache.geode.distributed.internal.ReplyException)5 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 CancelException (org.apache.geode.CancelException)2 BucketAdvisor (org.apache.geode.internal.cache.BucketAdvisor)2 BucketProfile (org.apache.geode.internal.cache.BucketAdvisor.BucketProfile)2 ConcurrentHashSet (org.apache.geode.internal.concurrent.ConcurrentHashSet)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 ForcedDisconnectException (org.apache.geode.ForcedDisconnectException)1