use of org.apache.geode.distributed.internal.ReplyMessage in project geode by apache.
the class MembershipFlushRequest method process.
@Override
protected void process(DistributionManager dm) {
int initLevel = LocalRegion.ANY_INIT;
int oldLevel = LocalRegion.setThreadInitLevelRequirement(initLevel);
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());
PartitionedRegion region = (PartitionedRegion) cache.getRegion(this.regionPath);
if (region != null && region.getRegionAdvisor().isInitialized()) {
ProxyBucketRegion[] proxyBuckets = region.getRegionAdvisor().getProxyBucketArray();
// buckets are null if initPRInternals is still not complete
if (proxyBuckets != null) {
for (ProxyBucketRegion bucket : proxyBuckets) {
final BucketPersistenceAdvisor persistenceAdvisor = bucket.getPersistenceAdvisor();
if (persistenceAdvisor != null) {
persistenceAdvisor.flushMembershipChanges();
}
}
}
}
} catch (RegionDestroyedException e) {
// ignore
} catch (CancelException e) {
// ignore
} 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 PersistentStateQueryMessage 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;
PersistentMemberID myInitializingId = null;
DiskStoreID diskStoreId = null;
HashSet<PersistentMemberID> onlineMembers = null;
ReplyException exception = null;
boolean successfulReply = false;
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) {
state = persistenceAdvisor.getPersistedStateOfMember(id);
}
if (initializingId != null && state == null) {
state = persistenceAdvisor.getPersistedStateOfMember(initializingId);
}
myId = persistenceAdvisor.getPersistentID();
myInitializingId = persistenceAdvisor.getInitializingID();
onlineMembers = persistenceAdvisor.getPersistedOnlineOrEqualMembers();
diskStoreId = persistenceAdvisor.getDiskStoreID();
successfulReply = true;
}
} 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;
if (successfulReply) {
PersistentStateQueryReplyMessage persistentReplyMessage = new PersistentStateQueryReplyMessage();
persistentReplyMessage.myId = myId;
persistentReplyMessage.persistedStateOfPeer = state;
persistentReplyMessage.myInitializingId = myInitializingId;
persistentReplyMessage.diskStoreId = diskStoreId;
persistentReplyMessage.onlineMembers = onlineMembers;
replyMsg = persistentReplyMessage;
} else {
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 DestroyLuceneIndexMessage method process.
@Override
protected void process(DistributionManager dm) {
ReplyException replyException = null;
try {
if (logger.isDebugEnabled()) {
logger.debug("DestroyLuceneIndexMessage: Destroying regionPath=" + this.regionPath + "; indexName=" + this.indexName);
}
try {
InternalCache cache = GemFireCacheImpl.getInstance();
LuceneServiceImpl impl = (LuceneServiceImpl) LuceneServiceProvider.get(cache);
impl.destroyIndex(this.indexName, this.regionPath, false);
if (logger.isDebugEnabled()) {
logger.debug("DestroyLuceneIndexMessage: Destroyed regionPath=" + this.regionPath + "; indexName=" + this.indexName);
}
} catch (Throwable e) {
replyException = new ReplyException(e);
if (logger.isDebugEnabled()) {
logger.debug("DestroyLuceneIndexMessage: Caught the following exception attempting to destroy indexName=" + this.indexName + "; regionPath=" + this.regionPath + ":", e);
}
}
} finally {
ReplyMessage replyMsg = new ReplyMessage();
replyMsg.setRecipient(getSender());
replyMsg.setProcessorId(this.processorId);
if (replyException != null) {
replyMsg.setException(replyException);
}
dm.putOutgoing(replyMsg);
}
}
Aggregations