diff options
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java')
-rw-r--r-- | plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java index 942cf62b9d2..c59beb7e924 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java @@ -22,6 +22,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; import org.eclipse.osee.framework.core.data.ApplicabilityId; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactReadable; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; @@ -80,6 +84,7 @@ public class TxDataManager { private final TupleDataFactory tupleFactory; private final BranchCategoryDataFactory categoryFactory; private final TxDataLoader loader; + private final ConcurrentMap<Long, Lock> hotBranches = new ConcurrentHashMap<>(); public TxDataManager(ExternalArtifactManager proxyManager, ArtifactFactory artifactFactory, RelationManager relationManager, TupleDataFactory tupleFactory, BranchCategoryDataFactory categoryFactory, TxDataLoader loader) { this.proxyManager = proxyManager; @@ -112,6 +117,10 @@ public class TxDataManager { } public void startTx(TxData txData) { + Long branchId = txData.getBranchId(); + hotBranches.putIfAbsent(branchId, new ReentrantLock()); + Lock lock = hotBranches.get(branchId); + lock.lock(); Conditions.checkExpressionFailOnTrue(txData.isCommitInProgress(), "Commit is already in progress"); txData.setCommitInProgress(true); txData.setTxState(TxState.COMMIT_STARTED); @@ -119,6 +128,8 @@ public class TxDataManager { public void endTx(TxData txData) { txData.setCommitInProgress(false); + Lock lock = hotBranches.get(txData.getBranchId()); + lock.unlock(); } public Iterable<Artifact> getForWrite(TxData txData, Iterable<? extends ArtifactId> ids) { |