X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDistributedDataStore.java;h=18266658d3de421f592a5892b06b7a8baeec07f5;hp=8051f7d49bab43e48ad1a82215d35b49a55281e5;hb=2f7c93174d7834a4c4aedacc9b88aa53a5a0422c;hpb=864f3c5bb156a7f6f6e2d91a6c7d43e916909e84 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java index 8051f7d49b..18266658d3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java @@ -63,6 +63,8 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, private final String type; + private final TransactionContextFactory txContextFactory; + public DistributedDataStore(ActorSystem actorSystem, ClusterWrapper cluster, Configuration configuration, DatastoreContext datastoreContext) { Preconditions.checkNotNull(actorSystem, "actorSystem should not be null"); @@ -85,6 +87,7 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, this.waitTillReadyTimeInMillis = actorContext.getDatastoreContext().getShardLeaderElectionTimeout().duration().toMillis() * READY_WAIT_FACTOR; + this.txContextFactory = TransactionContextFactory.create(actorContext); datastoreConfigMXBean = new DatastoreConfigurationMXBeanImpl(datastoreContext.getDataStoreMXBeanType()); datastoreConfigMXBean.setContext(datastoreContext); @@ -96,10 +99,10 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, public DistributedDataStore(ActorContext actorContext) { this.actorContext = Preconditions.checkNotNull(actorContext, "actorContext should not be null"); + this.txContextFactory = TransactionContextFactory.create(actorContext); this.type = UNKNOWN_TYPE; this.waitTillReadyTimeInMillis = actorContext.getDatastoreContext().getShardLeaderElectionTimeout().duration().toMillis() * READY_WAIT_FACTOR; - } public void setCloseable(AutoCloseable closeable) { @@ -144,24 +147,24 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, @Override public DOMStoreTransactionChain createTransactionChain() { - return new TransactionChainProxy(actorContext); + return txContextFactory.createTransactionChain(); } @Override public DOMStoreReadTransaction newReadOnlyTransaction() { - return new TransactionProxy(actorContext, TransactionType.READ_ONLY); + return new TransactionProxy(txContextFactory, TransactionType.READ_ONLY); } @Override public DOMStoreWriteTransaction newWriteOnlyTransaction() { actorContext.acquireTxCreationPermit(); - return new TransactionProxy(actorContext, TransactionType.WRITE_ONLY); + return new TransactionProxy(txContextFactory, TransactionType.WRITE_ONLY); } @Override public DOMStoreReadWriteTransaction newReadWriteTransaction() { actorContext.acquireTxCreationPermit(); - return new TransactionProxy(actorContext, TransactionType.READ_WRITE); + return new TransactionProxy(txContextFactory, TransactionType.READ_WRITE); } @Override @@ -182,7 +185,7 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, datastoreConfigMXBean.unregisterMBean(); datastoreInfoMXBean.unregisterMBean(); - if(closeable != null) { + if (closeable != null) { try { closeable.close(); } catch (Exception e) { @@ -190,6 +193,7 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, } } + txContextFactory.close(); actorContext.shutdown(); DistributedDataStoreFactory.destroyInstance(this); }