- return new SimpleShardDataTreeCohort(this, snapshot);
- }
-
- void recoveryDone(){
- transactionFactory = new RegularShardDataTreeTransactionFactory();
- }
-
- @VisibleForTesting
- ShardDataTreeTransactionFactory getTransactionFactory(){
- return transactionFactory;
- }
-
- @VisibleForTesting
- static interface ShardDataTreeTransactionFactory {
- ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(final String txId, final String chainId);
-
- ReadWriteShardDataTreeTransaction newReadWriteTransaction(final String txId, final String chainId);
- }
-
- @VisibleForTesting
- class RecoveryShardDataTreeTransactionFactory implements ShardDataTreeTransactionFactory {
-
- @Override
- public ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(String txId, String chainId) {
- return new ReadOnlyShardDataTreeTransaction(txId,
- new PruningShardDataTreeSnapshot(dataTree.takeSnapshot(), validNamespaces));
- }
-
- @Override
- public ReadWriteShardDataTreeTransaction newReadWriteTransaction(String txId, String chainId) {
- return new ReadWriteShardDataTreeTransaction(ShardDataTree.this, txId,
- new PruningShardDataTreeSnapshot(dataTree.takeSnapshot(), validNamespaces).newModification());
- }
- }
-
- @VisibleForTesting
- class RegularShardDataTreeTransactionFactory implements ShardDataTreeTransactionFactory {
-
- @Override
- public ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(String txId, String chainId) {
- return new ReadOnlyShardDataTreeTransaction(txId, dataTree.takeSnapshot());
-
- }
-
- @Override
- public ReadWriteShardDataTreeTransaction newReadWriteTransaction(String txId, String chainId) {
- return new ReadWriteShardDataTreeTransaction(ShardDataTree.this, txId, dataTree.takeSnapshot()
- .newModification());
- }