BUG-5280: refactor CohortEntry
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / CohortEntry.java
index 073f081..06d3ec9 100644 (file)
@@ -47,7 +47,7 @@ final class CohortEntry {
     private ActorRef replySender;
     private Shard shard;
 
-    CohortEntry(TransactionIdentifier transactionID, ReadWriteShardDataTreeTransaction transaction,
+    private CohortEntry(TransactionIdentifier transactionID, ReadWriteShardDataTreeTransaction transaction,
             DataTreeCohortActorRegistry cohortRegistry, SchemaContext schema, short clientVersion) {
         this.transaction = Preconditions.checkNotNull(transaction);
         this.transactionID = Preconditions.checkNotNull(transactionID);
@@ -55,7 +55,7 @@ final class CohortEntry {
         this.userCohorts = new CompositeDataTreeCohort(cohortRegistry, transactionID, schema, COMMIT_STEP_TIMEOUT);
     }
 
-    CohortEntry(TransactionIdentifier transactionID, ShardDataTreeCohort cohort, DataTreeCohortActorRegistry cohortRegistry,
+    private CohortEntry(TransactionIdentifier transactionID, ShardDataTreeCohort cohort, DataTreeCohortActorRegistry cohortRegistry,
             SchemaContext schema, short clientVersion) {
         this.transactionID = Preconditions.checkNotNull(transactionID);
         this.cohort = cohort;
@@ -64,6 +64,16 @@ final class CohortEntry {
         this.userCohorts = new CompositeDataTreeCohort(cohortRegistry, transactionID, schema, COMMIT_STEP_TIMEOUT);
     }
 
+    static CohortEntry createOpen(TransactionIdentifier transactionID, ReadWriteShardDataTreeTransaction transaction,
+            DataTreeCohortActorRegistry cohortRegistry, SchemaContext schema, short clientVersion) {
+        return new CohortEntry(transactionID, transaction, cohortRegistry, schema, clientVersion);
+    }
+
+    static CohortEntry createReady(TransactionIdentifier transactionID, ShardDataTreeCohort cohort,
+            DataTreeCohortActorRegistry cohortRegistry, SchemaContext schema, short clientVersion) {
+        return new CohortEntry(transactionID, cohort, cohortRegistry, schema, clientVersion);
+    }
+
     void updateLastAccessTime() {
         lastAccessTimer.reset();
         lastAccessTimer.start();