use of org.apache.geode.internal.cache.partitioned.PutMessage.PutResult in project geode by apache.
the class PartitionedRegion method putRemotely.
/**
* Puts the key/value pair into the remote target that is managing the key's bucket.
*
* @param recipient the member to receive the message
* @param event the event prompting this action
* @param ifNew the mysterious ifNew parameter
* @param ifOld the mysterious ifOld parameter
* @return whether the operation succeeded
* @throws PrimaryBucketException if the remote bucket was not the primary
* @throws ForceReattemptException if the peer is no longer available
*/
public boolean putRemotely(final DistributedMember recipient, final EntryEventImpl event, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue) throws PrimaryBucketException, ForceReattemptException {
// boolean forceAck = basicGetWriter() != null
// || getDistributionAdvisor().adviseNetWrite().size() > 0;
long eventTime = event.getEventTime(0L);
PutMessage.PutResponse response = (PutMessage.PutResponse) PutMessage.send(recipient, this, event, eventTime, ifNew, ifOld, expectedOldValue, requireOldValue);
PutResult pr = null;
if (response != null) {
this.prStats.incPartitionMessagesSent();
try {
pr = response.waitForResult();
event.setOperation(pr.op);
event.setVersionTag(pr.versionTag);
if (requireOldValue) {
event.setOldValue(pr.oldValue, true);
}
return pr.returnValue;
} catch (RegionDestroyedException rde) {
if (logger.isDebugEnabled()) {
logger.debug("putRemotely: caught RegionDestroyedException", rde);
}
throw new RegionDestroyedException(toString(), getFullPath());
} catch (TransactionException te) {
throw te;
} catch (CacheException ce) {
// Fix for bug 36014
throw new PartitionedRegionDistributionException(LocalizedStrings.PartitionedRegion_PUTTING_ENTRY_ON_0_FAILED.toLocalizedString(recipient), ce);
}
}
// ???:ezoerner:20080728 why return true if response was null?
return true;
}
use of org.apache.geode.internal.cache.partitioned.PutMessage.PutResult in project geode by apache.
the class PartitionedRegion method createRemotely.
/**
* Creates the key/value pair into the remote target that is managing the key's bucket.
*
* @param recipient member id of the recipient of the operation
* @param bucketId the id of the bucket that the key hashed to
* @param event the event prompting this request
* @throws PrimaryBucketException if the bucket on that node is not the primary copy
* @throws ForceReattemptException if the peer is no longer available
*/
private boolean createRemotely(DistributedMember recipient, Integer bucketId, EntryEventImpl event, boolean requireOldValue) throws PrimaryBucketException, ForceReattemptException {
boolean ret = false;
long eventTime = event.getEventTime(0L);
PutMessage.PutResponse reply = (PutMessage.PutResponse) PutMessage.send(recipient, this, event, // expectedOldValue
eventTime, // expectedOldValue
true, // expectedOldValue
false, // expectedOldValue
null, requireOldValue);
PutResult pr = null;
if (reply != null) {
this.prStats.incPartitionMessagesSent();
try {
pr = reply.waitForResult();
event.setOperation(pr.op);
event.setVersionTag(pr.versionTag);
if (requireOldValue) {
event.setOldValue(pr.oldValue, true);
}
ret = pr.returnValue;
} catch (EntryExistsException ignore) {
// This might not be necessary and is here for safety sake
ret = false;
} catch (TransactionDataNotColocatedException tdnce) {
throw tdnce;
} catch (TransactionDataRebalancedException e) {
throw e;
} catch (CacheException ce) {
throw new PartitionedRegionException(LocalizedStrings.PartitionedRegion_CREATE_OF_ENTRY_ON_0_FAILED.toLocalizedString(recipient), ce);
} catch (RegionDestroyedException rde) {
if (logger.isDebugEnabled()) {
logger.debug("createRemotely: caught exception", rde);
}
throw new RegionDestroyedException(toString(), getFullPath());
}
}
return ret;
}
Aggregations