use of org.apache.geode.distributed.internal.ReplyMessage in project geode by apache.
the class BackupDUnitTest method testBackupWhileBucketIsMovedBackupAfterSendDestroy.
@Test
public void testBackupWhileBucketIsMovedBackupAfterSendDestroy() throws Throwable {
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
final VM vm2 = host.getVM(2);
DistributionMessageObserver observer = new SerializableDistributionMessageObserver() {
private volatile boolean done;
private AtomicInteger count = new AtomicInteger();
private volatile int replyId = -0xBAD;
@Override
public void beforeSendMessage(DistributionManager dm, DistributionMessage msg) {
// The bucket move will send a destroy region message.
if (msg instanceof DestroyRegionOperation.DestroyRegionMessage && !done) {
this.replyId = msg.getProcessorId();
}
}
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof ReplyMessage && replyId != -0xBAD && replyId == message.getProcessorId() && !done && // we need two replies
count.incrementAndGet() == 2) {
backup(vm2);
done = true;
}
}
};
backupWhileBucketIsMoved(observer);
}
use of org.apache.geode.distributed.internal.ReplyMessage in project geode by apache.
the class ReleaseClearLockMessage method process.
@Override
protected void process(DistributionManager dm) {
ReplyException exception = null;
try {
DistributedRegion region = DistributedClearOperation.regionUnlocked(getSender(), regionPath);
if (region != null && region.getVersionVector() != null) {
region.getVersionVector().unlockForClear(getSender());
}
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
throw e;
} catch (Throwable t) {
SystemFailure.checkFailure();
exception = new ReplyException(t);
} finally {
ReplyMessage replyMsg = new ReplyMessage();
replyMsg.setProcessorId(processorId);
replyMsg.setRecipient(getSender());
if (exception != null) {
replyMsg.setException(exception);
}
if (logger.isDebugEnabled()) {
logger.debug("Received {}, replying with {}", this, replyMsg);
}
dm.putOutgoing(replyMsg);
}
}
use of org.apache.geode.distributed.internal.ReplyMessage in project geode by apache.
the class PrepareNewPersistentMemberMessage method process.
@Override
protected void process(DistributionManager dm) {
// Set thread local flag to allow entrance through initialization Latch
int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.ANY_INIT);
PersistentMemberState state = null;
PersistentMemberID myId = null;
ReplyException exception = null;
try {
// get the region from the path, but do NOT wait on initialization,
// otherwise we could have a distributed deadlock
Cache cache = CacheFactory.getInstance(dm.getSystem());
Region region = cache.getRegion(this.regionPath);
PersistenceAdvisor persistenceAdvisor = null;
if (region instanceof DistributedRegion) {
persistenceAdvisor = ((DistributedRegion) region).getPersistenceAdvisor();
} else if (region == null) {
Bucket proxy = PartitionedRegionHelper.getProxyBucketRegion(GemFireCacheImpl.getInstance(), this.regionPath, false);
if (proxy != null) {
persistenceAdvisor = proxy.getPersistenceAdvisor();
}
}
if (persistenceAdvisor != null) {
persistenceAdvisor.prepareNewMember(getSender(), oldId, newId);
}
} catch (RegionDestroyedException e) {
logger.debug("<RegionDestroyed> {}", this);
} catch (CancelException e) {
logger.debug("<CancelException> {}", this);
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
throw e;
} catch (Throwable t) {
SystemFailure.checkFailure();
exception = new ReplyException(t);
} finally {
LocalRegion.setThreadInitLevelRequirement(oldLevel);
ReplyMessage replyMsg = new ReplyMessage();
replyMsg.setRecipient(getSender());
replyMsg.setProcessorId(processorId);
if (exception != null) {
replyMsg.setException(exception);
}
dm.putOutgoing(replyMsg);
}
}
use of org.apache.geode.distributed.internal.ReplyMessage in project geode by apache.
the class RemovePersistentMemberMessage method process.
@Override
protected void process(DistributionManager dm) {
// Set thread local flag to allow entrance through initialization Latch
int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.ANY_INIT);
PersistentMemberState state = null;
PersistentMemberID myId = null;
ReplyException exception = null;
try {
// get the region from the path, but do NOT wait on initialization,
// otherwise we could have a distributed deadlock
Cache cache = CacheFactory.getInstance(dm.getSystem());
Region region = cache.getRegion(this.regionPath);
PersistenceAdvisor persistenceAdvisor = null;
if (region instanceof DistributedRegion) {
persistenceAdvisor = ((DistributedRegion) region).getPersistenceAdvisor();
} else if (region == null) {
Bucket proxy = PartitionedRegionHelper.getProxyBucketRegion(GemFireCacheImpl.getInstance(), this.regionPath, false);
if (proxy != null) {
persistenceAdvisor = proxy.getPersistenceAdvisor();
}
}
if (persistenceAdvisor != null) {
if (id != null) {
persistenceAdvisor.removeMember(id);
}
if (initializingId != null) {
persistenceAdvisor.removeMember(initializingId);
}
}
} catch (RegionDestroyedException e) {
logger.debug("<RegionDestroyed> {}", this);
} catch (CancelException e) {
logger.debug("<CancelException> {}", this);
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
throw e;
} catch (Throwable t) {
SystemFailure.checkFailure();
exception = new ReplyException(t);
} finally {
LocalRegion.setThreadInitLevelRequirement(oldLevel);
ReplyMessage replyMsg = new ReplyMessage();
replyMsg.setRecipient(getSender());
replyMsg.setProcessorId(processorId);
if (exception != null) {
replyMsg.setException(exception);
}
dm.putOutgoing(replyMsg);
}
}
use of org.apache.geode.distributed.internal.ReplyMessage in project geode by apache.
the class ServerInterestRegistrationMessage method process.
@Override
protected void process(DistributionManager dm) {
// Get the proxy for the proxy id
try {
CacheClientNotifier clientNotifier = CacheClientNotifier.getInstance();
if (clientNotifier != null) {
CacheClientProxy proxy = clientNotifier.getClientProxy(this.clientId);
// message on to the proxy for processing
if (proxy != null) {
proxy.processInterestMessage(this.clientMessage);
}
}
} finally {
ReplyMessage reply = new ReplyMessage();
reply.setProcessorId(this.processorId);
reply.setRecipient(getSender());
try {
dm.putOutgoing(reply);
} catch (CancelException ignore) {
// can't send a reply, so ignore the exception
}
}
}
Aggregations