summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-24 11:56:59 (EDT)
committerEike Stepper2007-07-24 11:56:59 (EDT)
commitcdbef9075e416eab04432f0c237f16be8d398ac0 (patch)
treef3ed920f84bd0929037774fbe7d569160e2d1d29
parentf16da00a6d3a018358e72227702d79c201b036f9 (diff)
downloadcdo-cdbef9075e416eab04432f0c237f16be8d398ac0.zip
cdo-cdbef9075e416eab04432f0c237f16be8d398ac0.tar.gz
cdo-cdbef9075e416eab04432f0c237f16be8d398ac0.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java31
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java25
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java13
8 files changed, 92 insertions, 23 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index 76bcdce..2cdab1c 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -11,7 +11,9 @@
package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
@@ -26,6 +28,8 @@ public class Repository extends Lifecycle implements IRepository
{
private static final long INITIAL_OID_VALUE = 2;
+ private static final long INITIAL_META_ID_VALUE = 1;
+
private String name;
private IStore store;
@@ -42,6 +46,8 @@ public class Repository extends Lifecycle implements IRepository
private long nextOIDValue = INITIAL_OID_VALUE;
+ private long nextMetaIDValue = INITIAL_META_ID_VALUE;
+
public Repository(String name, IStore store)
{
this.name = name;
@@ -88,6 +94,14 @@ public class Repository extends Lifecycle implements IRepository
return revisionManager;
}
+ public CDOIDRange getMetaIDRange(long count)
+ {
+ long lowerBound = nextMetaIDValue;
+ nextMetaIDValue += count;
+ nextMetaIDValue += count;
+ return CDOIDRangeImpl.create(lowerBound, nextMetaIDValue - 2);
+ }
+
public CDOID getNextCDOID()
{
CDOID id = CDOIDImpl.create(nextOIDValue);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
index 46c7864..c74910f 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
+import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.util.ImplementationError;
/**
@@ -32,6 +33,19 @@ public class RepositoryPackageManager extends CDOPackageManagerImpl
}
@Override
+ public void addPackage(CDOPackageImpl cdoPackage)
+ {
+ CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
+ if (metaIDRange != null && metaIDRange.isTemporary())
+ {
+ CDOIDRange newRange = repository.getMetaIDRange(metaIDRange.getCount());
+ cdoPackage.setMetaIDRange(newRange);
+ }
+
+ super.addPackage(cdoPackage);
+ }
+
+ @Override
protected void resolve(CDOPackageImpl cdoPackage)
{
// TODO Implement method RepositoryPackageManager.resolve()
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
index 48a69fc..0918e9d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
@@ -19,7 +20,6 @@ import org.eclipse.emf.cdo.internal.server.RevisionManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -40,7 +40,7 @@ public class CommitTransactionIndication extends CDOServerIndication
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CommitTransactionIndication.class);
- private CDOPackage[] newPackages;
+ private CDOPackageImpl[] newPackages;
private CDORevisionImpl[] newResources;
@@ -69,13 +69,13 @@ public class CommitTransactionIndication extends CDOServerIndication
// throw new IOException(ex.getMessage());
// }
- newPackages = readNewPackages(in);
+ addNewPackages(in);
newResources = readNewResources(in);
newObjects = readNewObjects(in);
dirtyObjects = readDirtyObjects(in);
}
- private CDOPackage[] readNewPackages(ExtendedDataInputStream in) throws IOException
+ private void addNewPackages(ExtendedDataInputStream in) throws IOException
{
int size = in.readInt();
if (PROTOCOL.isEnabled())
@@ -83,15 +83,16 @@ public class CommitTransactionIndication extends CDOServerIndication
PROTOCOL.format("Reading {0} new packages", size);
}
- RepositoryPackageManager packageManager = getPackageManager();
- CDOPackageImpl[] packages = new CDOPackageImpl[size];
- for (int i = 0; i < size; i++)
+ if (size != 0)
{
- packages[i] = new CDOPackageImpl(packageManager, in);
- packageManager.addPackage(packages[i]);
+ RepositoryPackageManager packageManager = getPackageManager();
+ newPackages = new CDOPackageImpl[size];
+ for (int i = 0; i < size; i++)
+ {
+ newPackages[i] = new CDOPackageImpl(packageManager, in);
+ packageManager.addPackage(newPackages[i]);
+ }
}
-
- return packages;
}
private CDORevisionImpl[] readNewResources(ExtendedDataInputStream in) throws IOException
@@ -156,6 +157,14 @@ public class CommitTransactionIndication extends CDOServerIndication
}
});
+ if (newPackages != null)
+ {
+ for (CDOPackageImpl newPackage : newPackages)
+ {
+ CDOIDRangeImpl.write(out, newPackage.getMetaIDRange());
+ }
+ }
+
writeIDMappings(out);
if (dirtyObjects.length > 0)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 7b0ad62..c662d9f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -276,7 +276,7 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
}
/**
- * TODO synchronize on nextTemporaryID
+ * TODO synchronize
*/
private void registerMetaInstance(InternalEObject metaInstance)
{
@@ -297,6 +297,18 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
}
}
+ public void remapMetaInstance(CDOID oldID, CDOID newID)
+ {
+ InternalEObject metaInstance = idToMetaInstanceMap.remove(oldID);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Remapping meta instance: {0} --> {1} <-> {2}", oldID, newID, metaInstance);
+ }
+
+ idToMetaInstanceMap.put(newID, metaInstance);
+ metaInstanceToIDMap.put(metaInstance, newID);
+ }
+
public void notifyInvalidation(long timeStamp, Set<CDOID> dirtyOIDs, CDOViewImpl excludedView)
{
dirtyOIDs = Collections.unmodifiableSet(dirtyOIDs);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index d102ffd..6897780 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -258,7 +258,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, CommitTransactionResult data)
{
CDOViewImpl view = (CDOViewImpl)object.cdoView();
- Map<CDOID, CDOID> idMappings = data.getIdMappings();
+ Map<CDOID, CDOID> idMappings = data.getIDMappings();
// Adjust object
CDOID id = object.cdoID();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index ad75ae3..93fbfef 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -145,7 +145,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
dirty = false;
nextTemporaryID = INITIAL_TEMPORARY_ID;
- Map<CDOID, CDOID> idMappings = result.getIdMappings();
+ Map<CDOID, CDOID> idMappings = result.getIDMappings();
fireEvent(new CommittedEvent(idMappings));
}
catch (RuntimeException ex)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index bb99745..ac19e8b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -12,9 +12,11 @@ package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.net4j.IChannel;
@@ -28,10 +30,8 @@ import org.eclipse.emf.internal.cdo.bundle.OM;
import java.io.IOException;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
/**
* @author Eike Stepper
@@ -120,16 +120,31 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
protected CommitTransactionResult confirming(ExtendedDataInputStream in) throws IOException
{
long timeStamp = in.readLong();
+ CommitTransactionResult result = new CommitTransactionResult(timeStamp);
+
+ List<CDOPackageImpl> newPackages = transaction.getNewPackages();
+ for (CDOPackageImpl newPackage : newPackages)
+ {
+ CDOIDRange oldRange = newPackage.getMetaIDRange();
+ CDOIDRange newRange = CDOIDRangeImpl.read(in);
+ newPackage.setMetaIDRange(newRange);
+ for (long i = 0; i < oldRange.getCount(); i++)
+ {
+ CDOID oldID = oldRange.get(i);
+ CDOID newID = newRange.get(i);
+ transaction.getSession().remapMetaInstance(oldID, newID);
+ result.addIDMapping(oldID, newID);
+ }
+ }
- Map<CDOID, CDOID> idMappings = new HashMap();
int size = in.readInt();
for (int i = 0; i < size; i++)
{
CDOID oldID = CDOIDImpl.read(in);
CDOID newID = CDOIDImpl.read(in);
- idMappings.put(oldID, newID);
+ result.addIDMapping(oldID, newID);
}
- return new CommitTransactionResult(timeStamp, idMappings);
+ return result;
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java
index e6f8513..d30fbdd 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.protocol.CDOID;
+import java.util.HashMap;
import java.util.Map;
/**
@@ -21,12 +22,11 @@ public final class CommitTransactionResult
{
private long timeStamp;
- private Map<CDOID, CDOID> idMappings;
+ private Map<CDOID, CDOID> idMappings = new HashMap();
- public CommitTransactionResult(long timeStamp, Map<CDOID, CDOID> idMappings)
+ public CommitTransactionResult(long timeStamp)
{
this.timeStamp = timeStamp;
- this.idMappings = idMappings;
}
public long getTimeStamp()
@@ -34,8 +34,13 @@ public final class CommitTransactionResult
return timeStamp;
}
- public Map<CDOID, CDOID> getIdMappings()
+ public Map<CDOID, CDOID> getIDMappings()
{
return idMappings;
}
+
+ void addIDMapping(CDOID oldID, CDOID newID)
+ {
+ idMappings.put(oldID, newID);
+ }
}