summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-01-20 00:20:57 (EST)
committerCaspar De Groot2010-01-20 00:20:57 (EST)
commitc20274851df3b5e7d9e54c006dc42652edbaa570 (patch)
tree7dde561e77619ab14883339732851b98aeeb9b78
parentc20107069e6011350eb52cd4dc43f56a208a2259 (diff)
downloadcdo-c20274851df3b5e7d9e54c006dc42652edbaa570.zip
cdo-c20274851df3b5e7d9e54c006dc42652edbaa570.tar.gz
cdo-c20274851df3b5e7d9e54c006dc42652edbaa570.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.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AbstractSyncRevisionsIndication.java51
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SyncRevisionsIndication.java8
4 files changed, 69 insertions, 39 deletions
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java
index 8eee5e3..f5b71c3 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.id.CDOIDAndVersionAndBranch;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.io.CDODataInput;
import org.eclipse.emf.cdo.common.io.CDODataOutput;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -32,6 +33,7 @@ import java.io.IOException;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -76,10 +78,18 @@ public abstract class AbstractSyncRevisionsRequest extends CDOClientRequest<Coll
protected Collection<CDORefreshContext> confirming(CDODataInput in) throws IOException
{
InternalCDORevisionManager revisionManager = getSession().getRevisionManager();
- Map<CDOBranchPoint, CDORefreshContext> refreshContexts = new TreeMap<CDOBranchPoint, CDORefreshContext>();
+ Comparator<CDOBranchPoint> comparator = new Comparator<CDOBranchPoint>()
+ {
+ public int compare(CDOBranchPoint bp1, CDOBranchPoint bp2)
+ {
+ long diff = bp1.getTimeStamp() - bp2.getTimeStamp();
+ return diff == 0 ? 0 : diff > 0 ? 1 : -1;
+ }
+ };
+ Map<CDOBranchPoint, CDORefreshContext> refreshContexts = new TreeMap<CDOBranchPoint, CDORefreshContext>(comparator);
- int size = in.readInt();
- for (int i = 0; i < size; i++)
+ int dirtyCount = in.readInt();
+ for (int i = 0; i < dirtyCount; i++)
{
CDORevision revision = in.readCDORevision();
long oldRevised = in.readLong();
@@ -92,20 +102,20 @@ public abstract class AbstractSyncRevisionsRequest extends CDOClientRequest<Coll
Messages.getString("SyncRevisionsRequest.2"), revision.getID())); //$NON-NLS-1$
}
- Set<CDOIDAndVersion> dirtyObjects = getRefreshContext(refreshContexts, branchPoint).getDirtyObjects();
- // $$$ (CD)
- // dirtyObjects.add(CDOIDUtil.createIDAndVersion(idAndVersion.getID(), idAndVersion.getVersion()));
+ CDORefreshContext refreshContext = getRefreshContext(refreshContexts, branchPoint);
+ Set<CDOIDAndVersion> dirtyObjects = refreshContext.getDirtyObjects();
+ dirtyObjects.add(CDOIDUtil.createIDAndVersion(idAndVersionAndBranch.getID(), idAndVersionAndBranch.getVersion()));
revisionManager.addRevision(revision);
}
if (TRACER.isEnabled())
{
- TRACER.trace("Synchronization received " + size + " dirty objects"); //$NON-NLS-1$ //$NON-NLS-2$
+ TRACER.trace("Synchronization received " + dirtyCount + " dirty objects"); //$NON-NLS-1$ //$NON-NLS-2$
}
- size = in.readInt();
- for (int i = 0; i < size; i++)
+ int detachedCount = in.readInt();
+ for (int i = 0; i < detachedCount; i++)
{
CDOID id = in.readCDOID();
CDOBranchPoint branchPoint = in.readCDOBranchPoint();
@@ -114,6 +124,12 @@ public abstract class AbstractSyncRevisionsRequest extends CDOClientRequest<Coll
detachedObjects.add(id);
}
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Synchronization received " + detachedCount + " detached objects"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Replace the collections with unmodifiable ones
for (CDORefreshContext refreshContext : refreshContexts.values())
{
Set<CDOIDAndVersion> dirtyObjects = refreshContext.getDirtyObjects();
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AbstractSyncRevisionsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AbstractSyncRevisionsIndication.java
index 9d510e9..b83af45 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AbstractSyncRevisionsIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AbstractSyncRevisionsIndication.java
@@ -11,11 +11,16 @@
*/
package org.eclipse.emf.cdo.server.internal.net4j.protocol;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDAndVersionAndBranch;
import org.eclipse.emf.cdo.common.io.CDODataInput;
import org.eclipse.emf.cdo.common.io.CDODataOutput;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.net4j.util.collection.Pair;
@@ -34,7 +39,7 @@ public abstract class AbstractSyncRevisionsIndication extends CDOReadIndication
protected List<Pair<InternalCDORevision, Long>> dirtyObjects = new ArrayList<Pair<InternalCDORevision, Long>>();
- protected List<Pair<CDOID, Long>> detachedObjects = new ArrayList<Pair<CDOID, Long>>();
+ protected List<Pair<CDOID, CDOBranchPoint>> detachedObjects = new ArrayList<Pair<CDOID, CDOBranchPoint>>();
protected int referenceChunk = CDORevision.UNCHUNKED;
@@ -50,9 +55,7 @@ public abstract class AbstractSyncRevisionsIndication extends CDOReadIndication
int size = in.readInt();
for (int i = 0; i < size; i++)
{
- CDOID id = in.readCDOID();
- int version = in.readInt();
- process(id, version);
+ process(in.readCDOIDAndVersionAndBranch());
}
}
@@ -72,29 +75,37 @@ public abstract class AbstractSyncRevisionsIndication extends CDOReadIndication
}
out.writeInt(detachedObjects.size());
- for (Pair<CDOID, Long> idAndRevised : detachedObjects)
+ for (Pair<CDOID, CDOBranchPoint> idAndRevised : detachedObjects)
{
out.writeCDOID(idAndRevised.getElement1());
- out.writeLong(idAndRevised.getElement2());
+ out.writeCDOBranchPoint(idAndRevised.getElement2());
}
}
- protected abstract void process(CDOID id, int version);
+ protected abstract void process(CDOIDAndVersionAndBranch idAndVersionAndBranch);
- protected void udpateObjectList(CDOID id, int version)
+ protected void updateObjectList(CDOIDAndVersionAndBranch idAndVersionAndBranch)
{
+ CDOID id = idAndVersionAndBranch.getID();
+ int version = idAndVersionAndBranch.getVersion();
+ int branchID = idAndVersionAndBranch.getBranchID();
+ CDOBranch branch = getRepository().getBranchManager().getBranch(branchID);
+ CDOBranchPoint branchPoint = CDOBranchUtil.createBranchPoint(branch, CDORevision.UNSPECIFIED_DATE);
+
try
{
- // XXX Fix for branching!!
- InternalCDORevision revision = (InternalCDORevision)getRepository().getRevisionManager().getRevision(id, null,
- referenceChunk, CDORevision.DEPTH_NONE, true);
+ // $$$ Fix for branching!!
+ InternalCDORevision revision = (InternalCDORevision)getRepository().getRevisionManager().getRevision(id,
+ branchPoint, referenceChunk, CDORevision.DEPTH_NONE, true);
if (revision == null)
{
- detachedObjects.add(new Pair<CDOID, Long>(id, getTimestamp(id, version)));
+ long revisedTimestamp = getRevisedTimestamp(id, version, branch);
+ CDOBranchPoint revisedBranchPoint = CDOBranchUtil.createBranchPoint(branch, revisedTimestamp);
+ detachedObjects.add(new Pair<CDOID, CDOBranchPoint>(id, revisedBranchPoint));
}
else if (revision.getVersion() > version || version == CDORevision.UNSPECIFIED_VERSION)
{
- dirtyObjects.add(new Pair<InternalCDORevision, Long>(revision, getTimestamp(id, version)));
+ dirtyObjects.add(new Pair<InternalCDORevision, Long>(revision, getRevisedTimestamp(id, version, branch)));
}
else if (revision.getVersion() < version)
{
@@ -104,15 +115,19 @@ public abstract class AbstractSyncRevisionsIndication extends CDOReadIndication
}
catch (IllegalArgumentException revisionIsNullException)
{
- detachedObjects.add(new Pair<CDOID, Long>(id, getTimestamp(id, version)));
+ // $$$ Factor (these 3 lines copied from 102-104)
+ long revisedTimestamp = getRevisedTimestamp(id, version, branch);
+ CDOBranchPoint revisedBranchPoint = CDOBranchUtil.createBranchPoint(branch, revisedTimestamp);
+ detachedObjects.add(new Pair<CDOID, CDOBranchPoint>(id, revisedBranchPoint));
}
}
- protected long getTimestamp(CDOID id, int version)
+ protected long getRevisedTimestamp(CDOID id, int version, CDOBranch branch)
{
- // XXX Fix for branching!!
- CDORevision revision = getRepository().getRevisionManager().getRevisionByVersion(id, null, CDORevision.DEPTH_NONE,
- false);
+ // $$$ Fix for branching!!
+ CDOBranchVersion branchVersion = CDOBranchUtil.createBranchVersion(branch, version);
+ CDORevision revision = getRepository().getRevisionManager().getRevisionByVersion(id, branchVersion,
+ CDORevision.DEPTH_NONE, false);
if (revision != null)
{
return revision.getRevised() + 1;
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java
index 00261b3..03890c0 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java
@@ -12,8 +12,7 @@
package org.eclipse.emf.cdo.server.internal.net4j.protocol;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.id.CDOIDAndVersionAndBranch;
import org.eclipse.emf.cdo.common.io.CDODataInput;
import org.eclipse.emf.cdo.common.io.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
@@ -35,7 +34,7 @@ public class LockObjectsIndication extends AbstractSyncRevisionsIndication
private List<CDOID> ids = new ArrayList<CDOID>();
- private List<CDOIDAndVersion> idAndVersions = new ArrayList<CDOIDAndVersion>();
+ private List<CDOIDAndVersionAndBranch> idAndVersionAndBranches = new ArrayList<CDOIDAndVersionAndBranch>();
private IView view;
@@ -67,9 +66,9 @@ public class LockObjectsIndication extends AbstractSyncRevisionsIndication
@Override
protected void responding(CDODataOutput out) throws IOException
{
- for (CDOIDAndVersion idAndVersion : idAndVersions)
+ for (CDOIDAndVersionAndBranch idAndVersionAndBranch : idAndVersionAndBranches)
{
- udpateObjectList(idAndVersion.getID(), idAndVersion.getVersion());
+ updateObjectList(idAndVersionAndBranch);
}
if (!detachedObjects.isEmpty())
@@ -82,9 +81,9 @@ public class LockObjectsIndication extends AbstractSyncRevisionsIndication
}
@Override
- protected void process(CDOID id, int version)
+ protected void process(CDOIDAndVersionAndBranch idAndVersionAndBranch)
{
- ids.add(id);
- idAndVersions.add(CDOIDUtil.createIDAndVersion(id, version));
+ ids.add(idAndVersionAndBranch.getID());
+ idAndVersionAndBranches.add(idAndVersionAndBranch);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SyncRevisionsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SyncRevisionsIndication.java
index 5ceb839..4fd8033 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SyncRevisionsIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SyncRevisionsIndication.java
@@ -11,7 +11,7 @@
*/
package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDAndVersionAndBranch;
import org.eclipse.emf.cdo.common.io.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.server.IStoreAccessor;
@@ -53,11 +53,11 @@ public class SyncRevisionsIndication extends AbstractSyncRevisionsIndication
}
@Override
- protected void process(CDOID id, int version)
+ protected void process(CDOIDAndVersionAndBranch idAndVersionAndBranch)
{
- if (version > 0)
+ if (idAndVersionAndBranch.getVersion() > 0) // $$$ What's this check for?
{
- udpateObjectList(id, version);
+ updateObjectList(idAndVersionAndBranch);
}
}
}