}
private static final Logger LOG = LoggerFactory.getLogger(TransactionProxy.class);
- private final Map<String, TransactionContextWrapper> txContextAdapters = new HashMap<>();
+ private final Map<String, TransactionContextWrapper> txContextWrappers = new HashMap<>();
private final AbstractTransactionContextFactory<?> txContextFactory;
private final TransactionType type;
private TransactionState state = TransactionState.OPEN;
LOG.debug("Tx {} exists {}", getIdentifier(), path);
final SettableFuture<Boolean> proxyFuture = SettableFuture.create();
- TransactionContextWrapper contextAdapter = getContextAdapter(path);
- contextAdapter.maybeExecuteTransactionOperation(new TransactionOperation() {
+ TransactionContextWrapper contextWrapper = getContextWrapper(path);
+ contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() {
@Override
public void invoke(TransactionContext transactionContext) {
transactionContext.dataExists(path, proxyFuture);
private CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> singleShardRead(
final String shardName, final YangInstanceIdentifier path) {
final SettableFuture<Optional<NormalizedNode<?, ?>>> proxyFuture = SettableFuture.create();
- TransactionContextWrapper contextAdapter = getContextAdapter(shardName);
- contextAdapter.maybeExecuteTransactionOperation(new TransactionOperation() {
+ TransactionContextWrapper contextWrapper = getContextWrapper(shardName);
+ contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() {
@Override
public void invoke(TransactionContext transactionContext) {
transactionContext.readData(path, proxyFuture);
LOG.debug("Tx {} delete {}", getIdentifier(), path);
- TransactionContextWrapper contextAdapter = getContextAdapter(path);
- contextAdapter.maybeExecuteTransactionOperation(new TransactionOperation() {
+ TransactionContextWrapper contextWrapper = getContextWrapper(path);
+ contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() {
@Override
public void invoke(TransactionContext transactionContext) {
transactionContext.deleteData(path);
LOG.debug("Tx {} merge {}", getIdentifier(), path);
- TransactionContextWrapper contextAdapter = getContextAdapter(path);
- contextAdapter.maybeExecuteTransactionOperation(new TransactionOperation() {
+ TransactionContextWrapper contextWrapper = getContextWrapper(path);
+ contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() {
@Override
public void invoke(TransactionContext transactionContext) {
transactionContext.mergeData(path, data);
LOG.debug("Tx {} write {}", getIdentifier(), path);
- TransactionContextWrapper contextAdapter = getContextAdapter(path);
- contextAdapter.maybeExecuteTransactionOperation(new TransactionOperation() {
+ TransactionContextWrapper contextWrapper = getContextWrapper(path);
+ contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() {
@Override
public void invoke(TransactionContext transactionContext) {
transactionContext.writeData(path, data);
return;
}
- for (TransactionContextWrapper contextAdapter : txContextAdapters.values()) {
- contextAdapter.maybeExecuteTransactionOperation(new TransactionOperation() {
+ for (TransactionContextWrapper contextWrapper : txContextWrappers.values()) {
+ contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() {
@Override
public void invoke(TransactionContext transactionContext) {
transactionContext.closeTransaction();
}
- txContextAdapters.clear();
+ txContextWrappers.clear();
}
@Override
final boolean success = seal(TransactionState.READY);
Preconditions.checkState(success, "Transaction %s is %s, it cannot be readied", getIdentifier(), state);
- LOG.debug("Tx {} Readying {} components for commit", getIdentifier(), txContextAdapters.size());
+ LOG.debug("Tx {} Readying {} components for commit", getIdentifier(), txContextWrappers.size());
final AbstractThreePhaseCommitCohort<?> ret;
- switch (txContextAdapters.size()) {
+ switch (txContextWrappers.size()) {
case 0:
ret = NoOpDOMStoreThreePhaseCommitCohort.INSTANCE;
break;
case 1:
- final Entry<String, TransactionContextWrapper> e = Iterables.getOnlyElement(txContextAdapters.entrySet());
+ final Entry<String, TransactionContextWrapper> e = Iterables.getOnlyElement(txContextWrappers.entrySet());
ret = createSingleCommitCohort(e.getKey(), e.getValue());
break;
default:
- ret = createMultiCommitCohort(txContextAdapters.entrySet());
+ ret = createMultiCommitCohort(txContextWrappers.entrySet());
}
txContextFactory.onTransactionReady(getIdentifier(), ret.getCohortFutures());
}
private AbstractThreePhaseCommitCohort<?> createSingleCommitCohort(final String shardName,
- final TransactionContextWrapper contextAdapter) {
+ final TransactionContextWrapper contextWrapper) {
LOG.debug("Tx {} Readying transaction for shard {}", getIdentifier(), shardName);
final OperationCallback.Reference operationCallbackRef =
new OperationCallback.Reference(OperationCallback.NO_OP_CALLBACK);
- final TransactionContext transactionContext = contextAdapter.getTransactionContext();
+ final TransactionContext transactionContext = contextWrapper.getTransactionContext();
final Future future;
if (transactionContext == null) {
final Promise promise = akka.dispatch.Futures.promise();
- contextAdapter.maybeExecuteTransactionOperation(new TransactionOperation() {
+ contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() {
@Override
public void invoke(TransactionContext transactionContext) {
promise.completeWith(getReadyOrDirectCommitFuture(transactionContext, operationCallbackRef));
}
private AbstractThreePhaseCommitCohort<ActorSelection> createMultiCommitCohort(
- final Set<Entry<String, TransactionContextWrapper>> txContextAdapterEntries) {
+ final Set<Entry<String, TransactionContextWrapper>> txContextWrapperEntries) {
- final List<Future<ActorSelection>> cohortFutures = new ArrayList<>(txContextAdapterEntries.size());
- for (Entry<String, TransactionContextWrapper> e : txContextAdapterEntries) {
+ final List<Future<ActorSelection>> cohortFutures = new ArrayList<>(txContextWrapperEntries.size());
+ for (Entry<String, TransactionContextWrapper> e : txContextWrapperEntries) {
LOG.debug("Tx {} Readying transaction for shard {}", getIdentifier(), e.getKey());
cohortFutures.add(e.getValue().readyTransaction());
return ShardStrategyFactory.getStrategy(path).findShard(path);
}
- private TransactionContextWrapper getContextAdapter(final YangInstanceIdentifier path) {
- return getContextAdapter(shardNameFromIdentifier(path));
+ private TransactionContextWrapper getContextWrapper(final YangInstanceIdentifier path) {
+ return getContextWrapper(shardNameFromIdentifier(path));
}
- private TransactionContextWrapper getContextAdapter(final String shardName) {
- final TransactionContextWrapper existing = txContextAdapters.get(shardName);
+ private TransactionContextWrapper getContextWrapper(final String shardName) {
+ final TransactionContextWrapper existing = txContextWrappers.get(shardName);
if (existing != null) {
return existing;
}
- final TransactionContextWrapper fresh = txContextFactory.newTransactionAdapter(this, shardName);
- txContextAdapters.put(shardName, fresh);
+ final TransactionContextWrapper fresh = txContextFactory.newTransactionContextWrapper(this, shardName);
+ txContextWrappers.put(shardName, fresh);
return fresh;
}