Search in sources :

Example 6 with ReplyProcessor21

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

the class StateFlushOperation method flushTo.

/** flush current ops to the given members for the given region */
public static void flushTo(Set<InternalDistributedMember> targets, DistributedRegion region) {
    DM dm = region.getDistributionManager();
    boolean initialized = region.isInitialized();
    if (initialized) {
        // force a new "view" so we can track current ops
        region.getDistributionAdvisor().forceNewMembershipVersion();
        try {
            region.getDistributionAdvisor().waitForCurrentOperations();
        } catch (RegionDestroyedException ignore) {
            return;
        }
    }
    // send all state-flush messages and then wait for replies
    Set<ReplyProcessor21> processors = new HashSet<ReplyProcessor21>();
    for (InternalDistributedMember target : targets) {
        StateStabilizationMessage gr = new StateStabilizationMessage();
        // new for flushTo operation
        gr.isSingleFlushTo = true;
        gr.requestingMember = dm.getDistributionManagerId();
        gr.setRecipient(target);
        ReplyProcessor21 processor = new ReplyProcessor21(dm, target);
        gr.processorId = processor.getProcessorId();
        gr.channelState = dm.getMembershipManager().getMessageState(target, false);
        if (logger.isTraceEnabled(LogMarker.STATE_FLUSH_OP) && ((gr.channelState != null) && (gr.channelState.size() > 0))) {
            logger.trace(LogMarker.STATE_FLUSH_OP, "channel states: {}", gr.channelStateDescription(gr.channelState));
        }
        if (logger.isTraceEnabled(LogMarker.STATE_FLUSH_OP)) {
            logger.trace(LogMarker.STATE_FLUSH_OP, "Sending {}", gr);
        }
        dm.putOutgoing(gr);
        processors.add(processor);
    }
    if (region.getRegionMap().getARMLockTestHook() != null) {
        region.getRegionMap().getARMLockTestHook().beforeStateFlushWait();
    }
    for (ReplyProcessor21 processor : processors) {
        try {
            processor.waitForReplies();
        } catch (InterruptedException ignore) {
            Thread.currentThread().interrupt();
            return;
        }
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) DM(org.apache.geode.distributed.internal.DM) HashSet(java.util.HashSet) ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21)

Example 7 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 8 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 9 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 10 with ReplyProcessor21

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

the class AdminWaiters method sendResponse.

/**
   * Call to send a {@link AdminResponse} and notify the thread waiting for it.
   */
public static void sendResponse(AdminResponse msg) {
    int id = msg.getMsgId();
    ReplyProcessor21 processor = (ReplyProcessor21) ReplyProcessor21.getProcessor(id);
    if (processor == null) {
        // must've been cancelled
        return;
    } else {
        processor.process(msg);
    }
}
Also used : 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