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;
}
}
}
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;
}
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;
}
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();
}
}
}
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);
}
}
Aggregations