use of org.apache.geode.internal.cache.tx.DistTxKeyInfo in project geode by apache.
the class DistTXState method postPutAll.
/*
* [DISTTX] Note: This has been overridden here to associate DistKeyInfo with event to disable
* primary check(see DistKeyInfo.setCheckPrimary(false)) when this gets called on secondary of a
* PR
*
* For TX this needs to be a PR passed in as region
*
*
* @see org.apache.geode.internal.cache.InternalDataView#postPutAll(org.apache
* .gemfire.internal.cache.DistributedPutAllOperation, java.util.Map,
* org.apache.geode.internal.cache.LocalRegion)
*/
public void postPutAll(final DistributedPutAllOperation putallOp, final VersionedObjectList successfulPuts, LocalRegion reg) {
final LocalRegion theRegion;
if (reg instanceof BucketRegion) {
theRegion = ((BucketRegion) reg).getPartitionedRegion();
} else {
theRegion = reg;
}
/*
* Don't fire events here.
*/
/*
* We are on the data store, we don't need to do anything here. Commit will push them out.
*/
/*
* We need to put this into the tx state.
*/
theRegion.syncBulkOp(new Runnable() {
public void run() {
// final boolean requiresRegionContext =
// theRegion.keyRequiresRegionContext();
InternalDistributedMember myId = theRegion.getDistributionManager().getDistributionManagerId();
for (int i = 0; i < putallOp.putAllDataSize; ++i) {
@Released EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(theRegion, myId, myId, i, putallOp.putAllData, false, putallOp.getBaseEvent().getContext(), false, !putallOp.getBaseEvent().isGenerateCallbacks());
try {
// distKeyInfo.setCheckPrimary(false);
if (isUpdatingTxStateDuringPreCommit()) {
KeyInfo keyInfo = ev.getKeyInfo();
DistTxKeyInfo distKeyInfo = new DistTxKeyInfo(keyInfo);
distKeyInfo.setCheckPrimary(false);
ev.setKeyInfo(distKeyInfo);
}
/*
* Whenever commit is called, especially when its a DistTxStateOnCoordinator the txState
* is set to null in @see TXManagerImpl.commit() and thus when @see LocalRegion.basicPut
* will be called as in this function, they will not found a TxState with call for
* getDataView()
*/
if (!(theRegion.getDataView() instanceof TXStateInterface)) {
if (putEntry(ev, false, false, null, false, 0L, false)) {
successfulPuts.addKeyAndVersion(putallOp.putAllData[i].key, null);
}
} else if (theRegion.basicPut(ev, false, false, null, false)) {
successfulPuts.addKeyAndVersion(putallOp.putAllData[i].key, null);
}
} finally {
ev.release();
}
}
}
}, putallOp.getBaseEvent().getEventId());
}
use of org.apache.geode.internal.cache.tx.DistTxKeyInfo in project geode by apache.
the class DistTXState method applyOpsOnRedundantCopy.
protected boolean applyOpsOnRedundantCopy(DistributedMember sender, ArrayList<DistTxEntryEvent> secondaryTransactionalOperations) {
boolean returnValue = true;
try {
boolean result = true;
// Start TxState Update During PreCommit phase
setUpdatingTxStateDuringPreCommit(true);
if (logger.isDebugEnabled()) {
logger.debug("DistTXState.applyOpOnRedundantCopy: size of " + "secondaryTransactionalOperations = {}", secondaryTransactionalOperations.size());
}
/*
* Handle Put Operations meant for secondary.
*
* @see org.apache.geode.internal.cache.partitioned.PutMessage.
* operateOnPartitionedRegion(DistributionManager, PartitionedRegion, long)
*
* [DISTTX] TODO need to handle other operations
*/
for (DistTxEntryEvent dtop : secondaryTransactionalOperations) {
if (logger.isDebugEnabled()) {
logger.debug("DistTXState.applyOpOnRedundantCopy: processing dist " + "tx operation {}", dtop);
}
dtop.setDistributedMember(sender);
dtop.setOriginRemote(false);
/*
* [DISTTX} TODO handle call back argument version tag and other settings in PutMessage
*/
String failureReason = null;
try {
if (dtop.getKeyInfo().isDistKeyInfo()) {
dtop.getKeyInfo().setCheckPrimary(false);
} else {
dtop.setKeyInfo(new DistTxKeyInfo(dtop.getKeyInfo()));
dtop.getKeyInfo().setCheckPrimary(false);
}
// apply the op
result = applyIndividualOp(dtop);
if (!result) {
// make sure the region hasn't gone away
dtop.getRegion().checkReadiness();
}
} catch (CacheWriterException cwe) {
result = false;
failureReason = "CacheWriterException";
} catch (PrimaryBucketException pbe) {
result = false;
failureReason = "PrimaryBucketException";
} catch (InvalidDeltaException ide) {
result = false;
failureReason = "InvalidDeltaException";
} catch (DataLocationException e) {
result = false;
failureReason = "DataLocationException";
}
if (logger.isDebugEnabled()) {
logger.debug("DistTXState.applyOpOnRedundantCopy {} ##op {}, " + "##region {}, ##key {}", (result ? " sucessfully applied op " : " failed to apply op due to " + failureReason), dtop.getOperation(), dtop.getRegion().getName(), dtop.getKey());
}
if (!result) {
returnValue = false;
break;
}
}
} finally {
// End TxState Update During PreCommit phase
setUpdatingTxStateDuringPreCommit(false);
}
return returnValue;
}
use of org.apache.geode.internal.cache.tx.DistTxKeyInfo in project geode by apache.
the class DistTXState method postRemoveAll.
@Override
public void postRemoveAll(final DistributedRemoveAllOperation op, final VersionedObjectList successfulOps, LocalRegion reg) {
final LocalRegion theRegion;
if (reg instanceof BucketRegion) {
theRegion = ((BucketRegion) reg).getPartitionedRegion();
} else {
theRegion = reg;
}
/*
* Don't fire events here. We are on the data store, we don't need to do anything here. Commit
* will push them out. We need to put this into the tx state.
*/
theRegion.syncBulkOp(new Runnable() {
public void run() {
InternalDistributedMember myId = theRegion.getDistributionManager().getDistributionManagerId();
for (int i = 0; i < op.removeAllDataSize; ++i) {
@Released EntryEventImpl ev = RemoveAllPRMessage.getEventFromEntry(theRegion, myId, myId, i, op.removeAllData, false, op.getBaseEvent().getContext(), false, !op.getBaseEvent().isGenerateCallbacks());
try {
ev.setRemoveAllOperation(op);
// distKeyInfo.setCheckPrimary(false);
if (isUpdatingTxStateDuringPreCommit()) {
KeyInfo keyInfo = ev.getKeyInfo();
DistTxKeyInfo distKeyInfo = new DistTxKeyInfo(keyInfo);
distKeyInfo.setCheckPrimary(false);
ev.setKeyInfo(distKeyInfo);
}
/*
* Whenever commit is called, especially when its a DistTxStateOnCoordinator the txState
* is set to null in @see TXManagerImpl.commit() and thus when basicDestroy will be
* called will be called as in i.e. @see LocalRegion.basicDestroy, they will not found a
* TxState with call for getDataView()
*
* [DISTTX] TODO verify if this is correct to call destroyExistingEntry directly?
*/
try {
if (!(theRegion.getDataView() instanceof TXStateInterface)) {
destroyExistingEntry(ev, true, /* should we invoke cacheWriter? */
null);
} else {
theRegion.basicDestroy(ev, true, /* should we invoke cacheWriter? */
null);
}
} catch (EntryNotFoundException ignore) {
}
successfulOps.addKeyAndVersion(op.removeAllData[i].key, null);
} finally {
ev.release();
}
}
}
}, op.getBaseEvent().getEventId());
}
Aggregations