*
* @return A new snapshot
*/
- protected abstract DataTreeSnapshot getSnapshot();
+ protected abstract DataTreeSnapshot getSnapshot(Object transactionId);
}
private static final class Idle extends State {
}
@Override
- protected DataTreeSnapshot getSnapshot() {
+ protected DataTreeSnapshot getSnapshot(Object transactionId) {
return chain.takeSnapshot();
}
}
}
@Override
- protected DataTreeSnapshot getSnapshot() {
+ protected DataTreeSnapshot getSnapshot(Object transactionId) {
final DataTreeSnapshot ret = snapshot;
- Preconditions.checkState(ret != null, "Previous transaction %s is not ready yet", transaction.getIdentifier());
+ Preconditions.checkState(ret != null, "Could not get snapshot for transaction %s - previous transaction %s is not ready yet",
+ transactionId, transaction.getIdentifier());
return ret;
}
}
@Override
- protected DataTreeSnapshot getSnapshot() {
+ protected DataTreeSnapshot getSnapshot(Object transactionId) {
throw new IllegalStateException(message);
}
}
state = idleState;
}
- private Entry<State, DataTreeSnapshot> getSnapshot() {
+ private Entry<State, DataTreeSnapshot> getSnapshot(T transactionId) {
final State localState = state;
- return new SimpleEntry<>(localState, localState.getSnapshot());
+ return new SimpleEntry<>(localState, localState.getSnapshot(transactionId));
}
private boolean recordTransaction(final State expected, final DOMStoreWriteTransaction transaction) {
@Override
public final DOMStoreReadTransaction newReadOnlyTransaction() {
- final Entry<State, DataTreeSnapshot> entry = getSnapshot();
- return SnapshotBackedTransactions.newReadTransaction(nextTransactionIdentifier(), getDebugTransactions(), entry.getValue());
+ return newReadOnlyTransaction(nextTransactionIdentifier());
+ }
+
+ protected DOMStoreReadTransaction newReadOnlyTransaction(T transactionId) {
+ final Entry<State, DataTreeSnapshot> entry = getSnapshot(transactionId);
+ return SnapshotBackedTransactions.newReadTransaction(transactionId, getDebugTransactions(), entry.getValue());
}
@Override
public final DOMStoreReadWriteTransaction newReadWriteTransaction() {
+ return newReadWriteTransaction(nextTransactionIdentifier());
+ }
+
+ protected DOMStoreReadWriteTransaction newReadWriteTransaction(T transactionId) {
Entry<State, DataTreeSnapshot> entry;
DOMStoreReadWriteTransaction ret;
do {
- entry = getSnapshot();
- ret = new SnapshotBackedReadWriteTransaction<T>(nextTransactionIdentifier(),
- getDebugTransactions(), entry.getValue(), this);
+ entry = getSnapshot(transactionId);
+ ret = new SnapshotBackedReadWriteTransaction<>(transactionId, getDebugTransactions(), entry.getValue(),
+ this);
} while (!recordTransaction(entry.getKey(), ret));
return ret;
@Override
public final DOMStoreWriteTransaction newWriteOnlyTransaction() {
+ return newWriteOnlyTransaction(nextTransactionIdentifier());
+ }
+
+ protected DOMStoreWriteTransaction newWriteOnlyTransaction(T transactionId) {
Entry<State, DataTreeSnapshot> entry;
DOMStoreWriteTransaction ret;
do {
- entry = getSnapshot();
- ret = new SnapshotBackedWriteTransaction<T>(nextTransactionIdentifier(),
- getDebugTransactions(), entry.getValue(), this);
+ entry = getSnapshot(transactionId);
+ ret = new SnapshotBackedWriteTransaction<>(transactionId, getDebugTransactions(), entry.getValue(), this);
} while (!recordTransaction(entry.getKey(), ret));
return ret;
final State localState = state;
do {
- Preconditions.checkState(!CLOSED.equals(localState), "Transaction chain {} has been closed", this);
+ Preconditions.checkState(!CLOSED.equals(localState), "Transaction chain %s has been closed", this);
if (FAILED.equals(localState)) {
LOG.debug("Ignoring user close in failed state");