}
private OperationLimiter getOperationLimiter() {
- return parent.getLimiter();
+ return transactionContextAdapter.getLimiter();
}
private TransactionIdentifier getIdentifier() {
/**
* Sets the target primary shard and initiates a CreateTransaction try.
*/
- void setPrimaryShard(ActorSelection primaryShard) {
+ void setPrimaryShard(ActorSelection primaryShard, short primaryVersion) {
this.primaryShard = primaryShard;
- if (getTransactionType() == TransactionType.WRITE_ONLY &&
+ if (getTransactionType() == TransactionType.WRITE_ONLY && primaryVersion >= DataStoreVersions.LITHIUM_VERSION &&
getActorContext().getDatastoreContext().isWriteOnlyTransactionOptimizationsEnabled()) {
LOG.debug("Tx {} Primary shard {} found - creating WRITE_ONLY transaction context",
getIdentifier(), primaryShard);
// For write-only Tx's we prepare the transaction modifications directly on the shard actor
// to avoid the overhead of creating a separate transaction actor.
- // FIXME: can't assume the shard version is LITHIUM_VERSION - need to obtain it somehow.
transactionContextAdapter.executePriorTransactionOperations(createValidTransactionContext(this.primaryShard,
- this.primaryShard.path().toString(), DataStoreVersions.LITHIUM_VERSION));
+ this.primaryShard.path().toString(), primaryVersion));
} else {
tryCreateTransaction();
}
if(failure != null) {
LOG.debug("Tx {} Creating NoOpTransaction because of error", getIdentifier(), failure);
- localTransactionContext = new NoOpTransactionContext(failure, getIdentifier(), getOperationLimiter());
+ localTransactionContext = new NoOpTransactionContext(failure, getIdentifier());
} else if (CreateTransactionReply.SERIALIZABLE_CLASS.equals(response.getClass())) {
localTransactionContext = createValidTransactionContext(
CreateTransactionReply.fromSerializable(response));
IllegalArgumentException exception = new IllegalArgumentException(String.format(
"Invalid reply type %s for CreateTransaction", response.getClass()));
- localTransactionContext = new NoOpTransactionContext(exception, getIdentifier(), getOperationLimiter());
+ localTransactionContext = new NoOpTransactionContext(exception, getIdentifier());
}
transactionContextAdapter.executePriorTransactionOperations(localTransactionContext);
final TransactionContext ret;
if (remoteTransactionVersion < DataStoreVersions.LITHIUM_VERSION) {
- ret = new PreLithiumTransactionContextImpl(transactionPath, transactionActor, getIdentifier(),
- getActorContext(), isTxActorLocal, remoteTransactionVersion, parent.getLimiter());
+ ret = new PreLithiumTransactionContextImpl(transactionContextAdapter.getIdentifier(), transactionPath, transactionActor,
+ getActorContext(), isTxActorLocal, remoteTransactionVersion, transactionContextAdapter.getLimiter());
} else {
- ret = new RemoteTransactionContext(transactionActor, getIdentifier(), getActorContext(),
- isTxActorLocal, remoteTransactionVersion, parent.getLimiter());
+ ret = new RemoteTransactionContext(transactionContextAdapter.getIdentifier(), transactionActor, getActorContext(),
+ isTxActorLocal, remoteTransactionVersion, transactionContextAdapter.getLimiter());
}
if(parent.getType() == TransactionType.READ_ONLY) {