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