summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-17 12:32:22 (EDT)
committerEike Stepper2007-09-17 12:32:22 (EDT)
commit983dc7a07b6f52a44932337a4ad204a0e6f2ec0b (patch)
tree12e351db4443dbf1b1ef942269a2a548b4afa861
parent228b4ccbfdb7b87b83f151ec6ce0035488fc9372 (diff)
downloadcdo-983dc7a07b6f52a44932337a4ad204a0e6f2ec0b.zip
cdo-983dc7a07b6f52a44932337a4ad204a0e6f2ec0b.tar.gz
cdo-983dc7a07b6f52a44932337a4ad204a0e6f2ec0b.tar.bz2
[203518] Affecting ID problem when we commit transaction.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=203518
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java37
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java3
7 files changed, 63 insertions, 41 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 49c2e71..9dcf506 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -200,7 +200,7 @@ public class DBStore extends Store implements IDBStore
repairAfterCrash(repository, connection);
}
- repository.setNextOIDValue(nextCDOID);
+ setNextOIDValue(nextCDOID);
repository.setNextMetaIDValue(nextMetaID);
StringBuilder builder = new StringBuilder();
@@ -247,7 +247,7 @@ public class DBStore extends Store implements IDBStore
builder.append(", ");
builder.append(CDODBSchema.REPOSITORY_NEXT_CDOID);
builder.append("=");
- builder.append(repository.getNextOIDValue());
+ builder.append(getNextOIDValue());
builder.append(", ");
builder.append(CDODBSchema.REPOSITORY_NEXT_METAID);
builder.append("=");
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index bac65af..d4788c5 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOTypeImpl;
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.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
@@ -397,6 +398,11 @@ public class DBStoreAccessor implements IDBStoreAccessor
mapping.writeRevision(this, revision);
}
+ public CDOID primeNewObject(CDOClass cdoClass)
+ {
+ return store.getNextCDOID();
+ }
+
public CloseableIterator<CDOID> readObjectIDs(boolean withTypes)
{
if (TRACER.isEnabled())
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
index d02b9fa..e1149c1 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.server;
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.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
@@ -151,4 +152,9 @@ public class NOOPStoreAccessor implements IStoreWriter
public void writeRevision(CDORevisionImpl revision)
{
}
+
+ public CDOID primeNewObject(CDOClass cdoClass)
+ {
+ return store.getNextCDOID();
+ }
}
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 dfa8020..29e29ee 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
@@ -10,9 +10,7 @@
**************************************************************************/
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.IRepositoryElement;
@@ -40,8 +38,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
public static final String PROP_REMEMBERING_KNOWN_TYPES = "rememberingKnownTypes";
- private static final long INITIAL_OID_VALUE = 2;
-
private static final long INITIAL_META_ID_VALUE = 1;
private String name;
@@ -70,8 +66,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
private IRepositoryElement[] elements;
- private long nextOIDValue = INITIAL_OID_VALUE;
-
private long nextMetaIDValue = INITIAL_META_ID_VALUE;
public Repository()
@@ -211,24 +205,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
return nextMetaIDValue;
}
- public CDOID getNextCDOID()
- {
- CDOID id = CDOIDImpl.create(nextOIDValue);
- ++nextOIDValue;
- ++nextOIDValue;
- return id;
- }
-
- public long getNextOIDValue()
- {
- return nextOIDValue;
- }
-
- public void setNextOIDValue(long nextOIDValue)
- {
- this.nextOIDValue = nextOIDValue;
- }
-
@Override
public String toString()
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
index b4dffb4..6a05e2b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
+import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
@@ -20,10 +22,14 @@ import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
*/
public abstract class Store extends Lifecycle implements IStore
{
+ private static final long INITIAL_OID_VALUE = 2;
+
private String type;
private IRepository repository;
+ private long nextOIDValue = INITIAL_OID_VALUE;
+
public Store(String type)
{
this.type = type;
@@ -43,4 +49,22 @@ public abstract class Store extends Lifecycle implements IStore
{
this.repository = repository;
}
+
+ public CDOID getNextCDOID()
+ {
+ CDOID id = CDOIDImpl.create(nextOIDValue);
+ ++nextOIDValue;
+ ++nextOIDValue;
+ return id;
+ }
+
+ public long getNextOIDValue()
+ {
+ return nextOIDValue;
+ }
+
+ public void setNextOIDValue(long nextOIDValue)
+ {
+ this.nextOIDValue = nextOIDValue;
+ }
}
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 fa777f1..67698fe 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
@@ -33,6 +33,7 @@ import org.eclipse.emf.cdo.server.IView;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.internal.util.transaction.Transaction;
+import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -102,10 +103,10 @@ public class CommitTransactionIndication extends CDOServerIndication
try
{
StoreUtil.setReader(storeWriter);
- newPackages = readNewPackages(in);
- newResources = readNewResources(in);
- newObjects = readNewObjects(in);
- dirtyObjects = readDirtyObjects(in);
+ newPackages = readNewPackages(in, storeWriter);
+ newResources = readNewResources(in, storeWriter);
+ newObjects = readNewObjects(in, storeWriter);
+ dirtyObjects = readDirtyObjects(in, storeWriter);
ITransaction<IStoreWriter> storeTransaction = new Transaction<IStoreWriter>(storeWriter);
addPackages(storeTransaction, newPackages);
@@ -137,7 +138,7 @@ public class CommitTransactionIndication extends CDOServerIndication
}
}
- private CDOPackageImpl[] readNewPackages(ExtendedDataInputStream in) throws IOException
+ private CDOPackageImpl[] readNewPackages(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
{
int size = in.readInt();
if (PROTOCOL.isEnabled())
@@ -175,7 +176,7 @@ public class CommitTransactionIndication extends CDOServerIndication
return newPackages;
}
- private CDORevisionImpl[] readNewResources(ExtendedDataInputStream in) throws IOException
+ private CDORevisionImpl[] readNewResources(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
{
int size = in.readInt();
if (PROTOCOL.isEnabled())
@@ -183,10 +184,10 @@ public class CommitTransactionIndication extends CDOServerIndication
PROTOCOL.format("Reading {0} new resources", size);
}
- return readRevisions(in, size);
+ return readRevisions(in, storeWriter, size);
}
- private CDORevisionImpl[] readNewObjects(ExtendedDataInputStream in) throws IOException
+ private CDORevisionImpl[] readNewObjects(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
{
int size = in.readInt();
if (PROTOCOL.isEnabled())
@@ -194,10 +195,10 @@ public class CommitTransactionIndication extends CDOServerIndication
PROTOCOL.format("Reading {0} new objects", size);
}
- return readRevisions(in, size);
+ return readRevisions(in, storeWriter, size);
}
- private CDORevisionImpl[] readDirtyObjects(ExtendedDataInputStream in) throws IOException
+ private CDORevisionImpl[] readDirtyObjects(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
{
int size = in.readInt();
if (PROTOCOL.isEnabled())
@@ -205,17 +206,18 @@ public class CommitTransactionIndication extends CDOServerIndication
PROTOCOL.format("Reading {0} dirty objects", size);
}
- return readRevisions(in, size);
+ return readRevisions(in, storeWriter, size);
}
- private CDORevisionImpl[] readRevisions(ExtendedDataInputStream in, int size) throws IOException
+ private CDORevisionImpl[] readRevisions(ExtendedDataInputStream in, IStoreWriter storeWriter, int size)
+ throws IOException
{
RevisionManager revisionManager = sessionPackageManager.getRepository().getRevisionManager();
CDORevisionImpl[] revisions = new CDORevisionImpl[size];
for (int i = 0; i < size; i++)
{
revisions[i] = new CDORevisionImpl(in, revisionManager, transactionPackageManager);
- mapTemporaryID(revisions[i]);
+ mapTemporaryID(revisions[i], storeWriter);
}
return revisions;
@@ -237,12 +239,17 @@ public class CommitTransactionIndication extends CDOServerIndication
}
}
- private void mapTemporaryID(CDORevisionImpl revision)
+ private void mapTemporaryID(CDORevisionImpl revision, IStoreWriter storeWriter)
{
CDOID oldID = revision.getID();
if (oldID.isTemporary())
{
- CDOID newID = getRepository().getNextCDOID();
+ CDOID newID = storeWriter.primeNewObject(revision.getCDOClass());
+ if (newID == null || newID.isNull() || newID.isMeta() || newID.isTemporary())
+ {
+ throw new ImplementationError("Store writer returned bad CDOID " + newID);
+ }
+
if (TRACER.isEnabled())
{
TRACER.format("Mapping ID: {0} --> {1}", oldID, newID);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java
index a8cfb41..a269159 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
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.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
@@ -42,4 +43,6 @@ public interface IStoreWriter extends IStoreReader
public void writePackages(CDOPackageImpl... cdoPackages);
public void writeRevision(CDORevisionImpl revision);
+
+ public CDOID primeNewObject(CDOClass cdoClass);
}