summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-02-01 05:40:03 (EST)
committerCaspar De Groot2010-02-01 05:40:03 (EST)
commitd5eb7601c00636b8272551750ae23e9a7de65a90 (patch)
tree9523f8bf44733f10bda36a7233d485a288087104
parent307a02c191e206f9fa0208501c53f4064cfc9947 (diff)
downloadcdo-d5eb7601c00636b8272551750ae23e9a7de65a90.zip
cdo-d5eb7601c00636b8272551750ae23e9a7de65a90.tar.gz
cdo-d5eb7601c00636b8272551750ae23e9a7de65a90.tar.bz2
[270716] Provide support for branching
https://bugs.eclipse.org/bugs/show_bug.cgi?id=270716
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java23
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java122
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java10
5 files changed, 98 insertions, 67 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index 622c4a7..ebd0e0f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -147,10 +147,11 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
private Set<InternalCDOView> views = new HashSet<InternalCDOView>();
/**
- * Fixes a threading problem between a committing thread and the Net4j thread that delivers incoming commit
- * notifications. TODO This is a workaround, see Bug 294700
+ * Fixes threading problems between a committing thread and the Net4j thread that delivers incoming commit
+ * notifications. The same applies to lock requests and invalidations
*/
- private Object commitLock = new Object();
+ @ExcludeFromDump
+ private Object invalidationLock = new Object();
@ExcludeFromDump
private QueueRunner invalidationRunner;
@@ -585,7 +586,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
private void handleCommitNotification(CDOBranchPoint branchPoint, final Collection<CDOPackageUnit> newPackageUnits,
Set<CDOIDAndVersion> dirtyOIDs, final Collection<CDOID> detachedObjects,
- final Collection<CDORevisionDelta> deltas, InternalCDOView excludedView, final boolean passiveUpdate,
+ final Collection<CDORevisionDelta> deltas, InternalCDOView excludedView, final boolean reviseAndInvalidate,
final boolean async)
{
final CDOBranch branch = branchPoint.getBranch();
@@ -593,9 +594,9 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
try
{
- synchronized (commitLock)
+ synchronized (invalidationLock)
{
- if (passiveUpdate)
+ if (reviseAndInvalidate)
{
reviseRevisions(branchPoint, dirtyOIDs, detachedObjects, excludedView);
}
@@ -616,14 +617,14 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
try
{
Set<CDOObject> conflicts = null;
- if (passiveUpdate)
+ if (reviseAndInvalidate)
{
- conflicts = view.handleInvalidation(timeStamp, finalDirtyOIDs, finalDetachedObjects);
+ conflicts = view.handleInvalidation(timeStamp, finalDirtyOIDs, finalDetachedObjects, async);
}
if (!skipChangeSubscription)
{
- view.handleChangeSubscription(deltas, detachedObjects);
+ view.handleChangeSubscription(deltas, detachedObjects, async);
}
if (conflicts != null)
@@ -723,9 +724,9 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
}
- public Object getCommitLock()
+ public Object getInvalidationLock()
{
- return commitLock;
+ return invalidationLock;
}
private QueueRunner getInvalidationRunner()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index 32f5696..8c5e805 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -656,7 +656,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
public CDOCommit commit(IProgressMonitor progressMonitor) throws TransactionException
{
checkActive();
- synchronized (getSession().getCommitLock())
+ synchronized (getSession().getInvalidationLock())
{
getLock().lock();
@@ -1586,15 +1586,15 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
*/
@Override
public Set<CDOObject> handleInvalidationWithoutNotification(Set<CDOIDAndVersion> dirtyOIDs,
- Collection<CDOID> detachedOIDs, Set<InternalCDOObject> dirtyObjects, Set<InternalCDOObject> detachedObjects)
+ Collection<CDOID> detachedOIDs, Set<InternalCDOObject> dirtyObjects, Set<InternalCDOObject> detachedObjects,
+ boolean async)
{
// Bugzilla 298561: This override removes references to remotely
// detached objects that are present in any DIRTY or NEW objects
-
removeCrossReferences(getDirtyObjects().values(), detachedOIDs);
removeCrossReferences(getNewObjects().values(), detachedOIDs);
- return super.handleInvalidationWithoutNotification(dirtyOIDs, detachedOIDs, dirtyObjects, detachedObjects);
+ return super.handleInvalidationWithoutNotification(dirtyOIDs, detachedOIDs, dirtyObjects, detachedObjects, async);
}
private void removeCrossReferences(Collection<CDOObject> objects, Collection<CDOID> referencedOIDs)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
index ed5d0b8..4750980 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
@@ -401,33 +401,32 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
checkActive();
Map<CDOID, CDOIDAndVersion> uniqueObjects = new HashMap<CDOID, CDOIDAndVersion>();
- // synchronized (session.getCommitLock())
- // {
- // getLock().lock();
- //
- // try
- // {
-
- getCDOIDAndVersion(uniqueObjects, objects);
- for (CDOObject object : objects)
+ synchronized (session.getInvalidationLock())
{
- CDOIDAndVersion idAndVersion = uniqueObjects.get(object.cdoID());
- if (idAndVersion == null)
+ getLock().lock();
+
+ try
{
- uniqueObjects
- .put(object.cdoID(), CDOIDUtil.createIDAndVersion(object.cdoID(), CDORevision.UNSPECIFIED_VERSION));
- }
- }
- CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
- sessionProtocol.lockObjects(this, uniqueObjects, timeout, lockType);
+ getCDOIDAndVersion(uniqueObjects, objects);
+ for (CDOObject object : objects)
+ {
+ CDOIDAndVersion idAndVersion = uniqueObjects.get(object.cdoID());
+ if (idAndVersion == null)
+ {
+ uniqueObjects.put(object.cdoID(), CDOIDUtil.createIDAndVersion(object.cdoID(),
+ CDORevision.UNSPECIFIED_VERSION));
+ }
+ }
- // }
- // finally
- // {
- // getLock().unlock();
- // }
- // }
+ CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
+ sessionProtocol.lockObjects(this, uniqueObjects, timeout, lockType);
+ }
+ finally
+ {
+ getLock().unlock();
+ }
+ }
}
/**
@@ -1319,7 +1318,7 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
* @since 2.0
*/
public Set<CDOObject> handleInvalidation(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs,
- Collection<CDOID> detachedOIDs)
+ Collection<CDOID> detachedOIDs, boolean async)
{
Set<CDOObject> conflicts = null;
Set<InternalCDOObject> dirtyObjects = new HashSet<InternalCDOObject>();
@@ -1328,7 +1327,7 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
try
{
- conflicts = handleInvalidationWithoutNotification(dirtyOIDs, detachedOIDs, dirtyObjects, detachedObjects);
+ conflicts = handleInvalidationWithoutNotification(dirtyOIDs, detachedOIDs, dirtyObjects, detachedObjects, async);
}
finally
{
@@ -1362,7 +1361,8 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
}
public Set<CDOObject> handleInvalidationWithoutNotification(Set<CDOIDAndVersion> dirtyOIDs,
- Collection<CDOID> detachedOIDs, Set<InternalCDOObject> dirtyObjects, Set<InternalCDOObject> detachedObjects)
+ Collection<CDOID> detachedOIDs, Set<InternalCDOObject> dirtyObjects, Set<InternalCDOObject> detachedObjects,
+ boolean async)
{
Set<CDOObject> conflicts = null;
for (CDOIDAndVersion dirtyOID : dirtyOIDs)
@@ -1376,16 +1376,19 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
if (dirtyObject != null)
{
- CDOStateMachine.INSTANCE.invalidate(dirtyObject, dirtyOID.getVersion());
- dirtyObjects.add(dirtyObject);
- if (dirtyObject.cdoConflict())
+ if (!async || !isLocked(dirtyObject))
{
- if (conflicts == null)
+ CDOStateMachine.INSTANCE.invalidate(dirtyObject, dirtyOID.getVersion());
+ dirtyObjects.add(dirtyObject);
+ if (dirtyObject.cdoConflict())
{
- conflicts = new HashSet<CDOObject>();
- }
+ if (conflicts == null)
+ {
+ conflicts = new HashSet<CDOObject>();
+ }
- conflicts.add(dirtyObject);
+ conflicts.add(dirtyObject);
+ }
}
}
}
@@ -1395,16 +1398,19 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
InternalCDOObject detachedObject = removeObject(id);
if (detachedObject != null)
{
- CDOStateMachine.INSTANCE.detachRemote(detachedObject);
- detachedObjects.add(detachedObject);
- if (detachedObject.cdoConflict())
+ if (!async || !isLocked(detachedObject))
{
- if (conflicts == null)
+ CDOStateMachine.INSTANCE.detachRemote(detachedObject);
+ detachedObjects.add(detachedObject);
+ if (detachedObject.cdoConflict())
{
- conflicts = new HashSet<CDOObject>();
- }
+ if (conflicts == null)
+ {
+ conflicts = new HashSet<CDOObject>();
+ }
- conflicts.add(detachedObject);
+ conflicts.add(detachedObject);
+ }
}
}
}
@@ -1436,7 +1442,8 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
/**
* @since 2.0
*/
- public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects)
+ public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects,
+ boolean async)
{
boolean policiesPresent = options().hasChangeSubscriptionPolicies();
if (!policiesPresent)
@@ -1452,10 +1459,13 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
InternalCDOObject object = changeSubscriptionManager.getSubcribeObject(delta.getID());
if (object != null && object.eNotificationRequired())
{
- NotificationImpl notification = builder.buildNotification(object, delta);
- if (notification != null)
+ if (!async || !isLocked(object))
{
- notification.dispatch();
+ NotificationImpl notification = builder.buildNotification(object, delta);
+ if (notification != null)
+ {
+ notification.dispatch();
+ }
}
}
}
@@ -1468,9 +1478,12 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
InternalCDOObject object = changeSubscriptionManager.getSubcribeObject(id);
if (object != null && object.eNotificationRequired())
{
- NotificationImpl notification = new CDODeltaNotificationImpl(object, CDONotification.DETACH_OBJECT,
- Notification.NO_FEATURE_ID, null, null);
- notification.dispatch();
+ if (!async || !isLocked(object))
+ {
+ NotificationImpl notification = new CDODeltaNotificationImpl(object, CDONotification.DETACH_OBJECT,
+ Notification.NO_FEATURE_ID, null, null);
+ notification.dispatch();
+ }
}
}
@@ -1478,6 +1491,21 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
}
}
+ private boolean isLocked(InternalCDOObject object)
+ {
+ if (object.cdoWriteLock().isLocked())
+ {
+ return true;
+ }
+
+ if (object.cdoReadLock().isLocked())
+ {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* @since 2.0
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
index 09e16c9..8c43525 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
@@ -108,7 +108,7 @@ public interface InternalCDOSession extends CDOSession, PackageProcessor, Packag
/**
* @since 3.0
*/
- public Object getCommitLock();
+ public Object getInvalidationLock();
/**
* @since 3.0
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java
index 36b84df..01b6568 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java
@@ -69,14 +69,16 @@ public interface InternalCDOView extends CDOView, CDOIDProvider, ILifecycle
* Returns the conflicting objects.
*/
public Set<CDOObject> handleInvalidation(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs,
- Collection<CDOID> detachedOIDs);
+ Collection<CDOID> detachedOIDs, boolean async);
public Set<CDOObject> handleInvalidationWithoutNotification(Set<CDOIDAndVersion> dirtyOIDs,
- Collection<CDOID> detachedOIDs, Set<InternalCDOObject> dirtyObjects, Set<InternalCDOObject> detachedObjects);
+ Collection<CDOID> detachedOIDs, Set<InternalCDOObject> dirtyObjects, Set<InternalCDOObject> detachedObjects,
+ boolean async);
- public void getCDOIDAndVersion(Map<CDOID, CDOIDAndVersion> uniqueObjects, Collection<? extends CDOObject> cdoObjects);
+ public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects,
+ boolean async);
- public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects);
+ public void getCDOIDAndVersion(Map<CDOID, CDOIDAndVersion> uniqueObjects, Collection<? extends CDOObject> objects);
/**
* @since 3.0