summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-01 13:03:13 (EDT)
committerEike Stepper2007-09-01 13:03:13 (EDT)
commit3f7dd7d7468616808a0a5bf26995cc2763dace7f (patch)
treee2fd40bda34edc8e32674a82ab0e47ef0418bc83
parentdad2faac6bc7c7f8096787b2ad852e085eeb8e04 (diff)
downloadcdo-3f7dd7d7468616808a0a5bf26995cc2763dace7f.zip
cdo-3f7dd7d7468616808a0a5bf26995cc2763dace7f.tar.gz
cdo-3f7dd7d7468616808a0a5bf26995cc2763dace7f.tar.bz2
[201265] Handling large Collection by having them in chunk
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201265
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java71
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java82
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java64
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java82
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java8
13 files changed, 372 insertions, 9 deletions
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 881258d..2fdd059 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
@@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.protocol.model.CDOType;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.server.IPackageManager;
import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IRevisionManager;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
@@ -417,8 +418,9 @@ public class DBStoreAccessor implements IDBStoreAccessor
TRACER.format("Selecting revision: {0}", id);
}
+ IRevisionManager revisionManager = store.getRepository().getRevisionManager();
CDOClassImpl cdoClass = getObjectType(id);
- CDORevisionImpl revision = new CDORevisionImpl(cdoClass, id);
+ CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id);
IMapping mapping = ClassServerInfo.getMapping(cdoClass);
mapping.readRevision(this, revision);
@@ -432,8 +434,9 @@ public class DBStoreAccessor implements IDBStoreAccessor
TRACER.format("Selecting revision: {0}, {1,date} {1,time}", id, timeStamp);
}
+ IRevisionManager revisionManager = store.getRepository().getRevisionManager();
CDOClassImpl cdoClass = getObjectType(id);
- CDORevisionImpl revision = new CDORevisionImpl(cdoClass, id);
+ CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id);
IMapping mapping = ClassServerInfo.getMapping(cdoClass);
mapping.readRevision(this, revision, timeStamp);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
index 9c2cfdf..8b68c91 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
@@ -13,7 +13,10 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOPathFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl.MoveableList;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.revision.CDOReferenceProxy;
import org.eclipse.emf.cdo.server.IRevisionManager;
import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.emf.cdo.server.IStoreWriter;
@@ -46,6 +49,11 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
storeTransaction.execute(new AddRevisionOperation(revision));
}
+ public CDOID resolveReferenceProxy(CDOReferenceProxy referenceProxy)
+ {
+ throw new UnsupportedOperationException("Reference proxies not supported on server side");
+ }
+
@Override
protected CDORevisionImpl verifyRevision(CDORevisionImpl revision)
{
@@ -109,4 +117,20 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
{
}
}
+
+ public CDOID[] getReferenceChunk(CDOID id, CDOFeature feature, int fromIndex, int toIndex)
+ {
+ int size = toIndex - fromIndex + 1;
+ CDOID[] ids = new CDOID[size];
+
+ CDORevisionImpl revision = getRevision(id, CDORevisionImpl.COMPLETE_REFERENCES);
+ MoveableList list = revision.getList(feature);
+
+ for (int i = 0; i < size; i++)
+ {
+ ids[i] = (CDOID)list.get(fromIndex + i);
+ }
+
+ return ids;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
index e7a968c..e681846 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
@@ -65,6 +65,9 @@ public class CDOServerProtocol extends SignalProtocol
case CDOProtocolConstants.SIGNAL_LOAD_REVISION:
return new LoadRevisionIndication();
+ case CDOProtocolConstants.SIGNAL_LOAD_CHUNK:
+ return new LoadChunkIndication();
+
case CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION:
return new CommitTransactionIndication();
}
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 2fc4840..a2e55ad 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
@@ -205,10 +205,11 @@ public class CommitTransactionIndication extends CDOServerIndication
private CDORevisionImpl[] readRevisions(ExtendedDataInputStream in, 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, transactionPackageManager);
+ revisions[i] = new CDORevisionImpl(in, revisionManager, transactionPackageManager);
mapTemporaryID(revisions[i]);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
new file mode 100644
index 0000000..1daddb8
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.server.protocol;
+
+import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
+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.CDOClass;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class LoadChunkIndication extends CDOReadIndication
+{
+ private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, LoadChunkIndication.class);
+
+ private CDOID[] ids;
+
+ public LoadChunkIndication()
+ {
+ super(CDOProtocolConstants.SIGNAL_LOAD_CHUNK);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws IOException
+ {
+ CDOID id = CDOIDImpl.read(in);
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Read ID: {0}", id);
+
+ CDOClassRef classRef = new CDOClassRefImpl(in, null);
+ int featureID = in.readInt();
+ CDOClass cdoClass = classRef.resolve(getPackageManager());
+ CDOFeature feature = cdoClass.lookupFeature(featureID);
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Read feature: {0}", feature);
+
+ int fromIndex = in.readInt();
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Read fromIndex: {0}", fromIndex);
+
+ int toIndex = in.readInt();
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Read toIndex: {0}", toIndex);
+
+ ids = getRevisionManager().getReferenceChunk(id, feature, fromIndex, toIndex);
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws IOException
+ {
+ for (CDOID id : ids)
+ {
+ CDOIDImpl.write(out, id);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java
new file mode 100644
index 0000000..1be8eab
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java
@@ -0,0 +1,82 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import java.util.Iterator;
+
+/**
+ * @author Eike Stepper
+ */
+public class ChunkingTest extends AbstractCDOTest
+{
+ public void testNativeObjects() throws Exception
+ {
+ {
+ msg("Opening session");
+ CDOSession session = openModel1Session();
+
+ msg("Attaching transaction");
+ CDOTransaction transaction = session.openTransaction(new ResourceSetImpl());
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource("/test1");
+
+ msg("Creating customer");
+ Customer customer = Model1Factory.eINSTANCE.createCustomer();
+ customer.setName("customer");
+ resource.getContents().add(customer);
+
+ for (int i = 0; i < 100; i++)
+ {
+ msg("Creating salesOrder" + i);
+ SalesOrder salesOrder = Model1Factory.eINSTANCE.createSalesOrder();
+ salesOrder.setId(i);
+ salesOrder.setCustomer(customer);
+ resource.getContents().add(salesOrder);
+ }
+
+ msg("Committing");
+ transaction.commit();
+ }
+
+ // ************************************************************* //
+
+ msg("Opening session");
+ CDOSession session = openModel1Session();
+ session.setReferenceChunkSize(10);
+
+ msg("Attaching transaction");
+ CDOTransaction transaction = session.openTransaction(new ResourceSetImpl());
+
+ msg("Loading resource");
+ CDOResource resource = transaction.getResource("/test1");
+
+ Customer customer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> salesOrders = customer.getSalesOrders();
+ int i = 0;
+ for (Iterator<SalesOrder> it = salesOrders.iterator(); it.hasNext();)
+ {
+ System.out.println(i++);
+ SalesOrder salesOrder = it.next();
+ System.out.println(salesOrder);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
index a1f5e63..83786dd 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
@@ -20,9 +20,9 @@ import java.lang.reflect.Method;
*/
public class TDD
{
- private static final AbstractOMTest test = new PackageRegistryTest();
+ private static final AbstractOMTest test = new ChunkingTest();
- private static final String METHOD_NAME = "testDynamicPackage";
+ private static final String METHOD_NAME = "testNativeObjects";
public static void main(String[] args) throws Throwable
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
index 12643d6..4233f63 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
@@ -26,6 +26,10 @@ public interface CDOSession extends IContainer<CDOView>
{
public int getSessionID();
+ public int getReferenceChunkSize();
+
+ public void setReferenceChunkSize(int referenceChunkSize);
+
public IFailOverStrategy getFailOverStrategy();
public IChannel getChannel();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
index d311bc8..ddc5bbb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
@@ -13,11 +13,16 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDORevisionManager;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl.MoveableList;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.revision.CDOReferenceProxy;
import org.eclipse.emf.cdo.protocol.util.TransportException;
+import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.signal.IFailOverStrategy;
+import org.eclipse.emf.internal.cdo.protocol.LoadChunkRequest;
import org.eclipse.emf.internal.cdo.protocol.LoadRevisionRequest;
/**
@@ -37,13 +42,67 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C
return session;
}
+ public CDOID resolveReferenceProxy(CDOReferenceProxy referenceProxy)
+ {
+ CDORevisionImpl revision = (CDORevisionImpl)referenceProxy.getRevision();
+ CDOFeature feature = referenceProxy.getFeature();
+ int index = referenceProxy.getIndex();
+
+ int chunkSize = session.getReferenceChunkSize();
+ MoveableList list = revision.getList(feature);
+
+ int minIndex = Math.max(0, index - chunkSize / 2);
+ int fromIndex = index;
+ while (fromIndex > minIndex && list.get(fromIndex) instanceof CDOReferenceProxy)
+ {
+ --fromIndex;
+ }
+
+ int maxIndex = Math.min(list.size() - 1, index + chunkSize / 2);
+ int toIndex = index;
+ while (toIndex < maxIndex && list.get(toIndex) instanceof CDOReferenceProxy)
+ {
+ ++toIndex;
+ }
+
+ try
+ {
+ CDOID result = null;
+ IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
+ IChannel channel = session.getChannel();
+ LoadChunkRequest request = new LoadChunkRequest(channel, revision.getID(), feature, fromIndex, toIndex);
+ CDOID[] ids = failOverStrategy.send(request);
+ for (int i = 0; i < ids.length; i++)
+ {
+ CDOID id = ids[i];
+ int j = fromIndex + i;
+ list.set(j, id);
+ if (j == index)
+ {
+ result = id;
+ }
+ }
+
+ return result;
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new TransportException(ex);
+ }
+ }
+
@Override
protected CDORevisionImpl loadRevision(CDOID id, int referenceChunk)
{
try
{
IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- LoadRevisionRequest request = new LoadRevisionRequest(session.getChannel(), id, referenceChunk);
+ IChannel channel = session.getChannel();
+ LoadRevisionRequest request = new LoadRevisionRequest(channel, id, referenceChunk);
return failOverStrategy.send(request);
}
catch (RuntimeException ex)
@@ -62,7 +121,8 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C
try
{
IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- LoadRevisionRequest request = new LoadRevisionRequest(session.getChannel(), id, referenceChunk, timeStamp);
+ IChannel channel = session.getChannel();
+ LoadRevisionRequest request = new LoadRevisionRequest(channel, id, referenceChunk, timeStamp);
return failOverStrategy.send(request);
}
catch (RuntimeException ex)
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 a644143..ae85af6 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
@@ -204,6 +204,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, ResourceAndView data)
{
CDOTransactionImpl transaction = data.view.toTransaction();
+ CDORevisionManagerImpl revisionManager = transaction.getSession().getRevisionManager();
// Prepare object
CDOID id = transaction.getNextTemporaryID();
@@ -213,7 +214,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
object.cdoInternalSetState(CDOState.PREPARED_ATTACH);
// Create new revision
- CDORevisionImpl revision = new CDORevisionImpl((CDOClassImpl)object.cdoClass(), id);
+ CDORevisionImpl revision = new CDORevisionImpl(revisionManager, (CDOClassImpl)object.cdoClass(), id);
revision.setVersion(1);
revision.setResourceID(data.resource.cdoID());
object.cdoInternalSetRevision(revision);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
index 3069d8a..f75287d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.revision.CDOReferenceProxy;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -105,6 +106,11 @@ public final class CDOStore implements EStore
Object result = revision.get(cdoFeature, index);
if (cdoFeature.isReference())
{
+ if (result instanceof CDOReferenceProxy)
+ {
+ result = ((CDOReferenceProxy)result).resolve();
+ }
+
result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result);
}
@@ -232,6 +238,11 @@ public final class CDOStore implements EStore
{
for (int i = 0; i < result.length; i++)
{
+ if (result[i] instanceof CDOReferenceProxy)
+ {
+ result[i] = ((CDOReferenceProxy)result[i]).resolve();
+ }
+
result[i] = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result[i]);
}
}
@@ -268,6 +279,11 @@ public final class CDOStore implements EStore
Object result = revision.set(cdoFeature, index, value);
if (cdoFeature.isReference())
{
+ if (result instanceof CDOReferenceProxy)
+ {
+ result = ((CDOReferenceProxy)result).resolve();
+ }
+
result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result);
}
@@ -323,6 +339,11 @@ public final class CDOStore implements EStore
Object result = revision.remove(cdoFeature, index);
if (cdoFeature.isReference())
{
+ if (result instanceof CDOReferenceProxy)
+ {
+ result = ((CDOReferenceProxy)result).resolve();
+ }
+
result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result);
}
@@ -355,6 +376,11 @@ public final class CDOStore implements EStore
Object result = revision.move(cdoFeature, target, source);
if (cdoFeature.isReference())
{
+ if (result instanceof CDOReferenceProxy)
+ {
+ result = ((CDOReferenceProxy)result).resolve();
+ }
+
result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java
new file mode 100644
index 0000000..b7ebccf
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java
@@ -0,0 +1,82 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.internal.cdo.protocol;
+
+import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+
+import org.eclipse.net4j.IChannel;
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import org.eclipse.emf.internal.cdo.bundle.OM;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class LoadChunkRequest extends CDOClientRequest<CDOID[]>
+{
+ private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, LoadChunkRequest.class);
+
+ private CDOID id;
+
+ private CDOFeature feature;
+
+ private int fromIndex;
+
+ private int toIndex;
+
+ public LoadChunkRequest(IChannel channel, CDOID id, CDOFeature feature, int fromIndex, int toIndex)
+ {
+ super(channel, CDOProtocolConstants.SIGNAL_LOAD_CHUNK);
+ this.id = id;
+ this.feature = feature;
+ this.fromIndex = fromIndex;
+ this.toIndex = toIndex;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws IOException
+ {
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing ID: {0}", id);
+ CDOIDImpl.write(out, id);
+
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing feature: {0}", feature);
+ CDOClassRefImpl classRef = (CDOClassRefImpl)feature.getContainingClass().createClassRef();
+ classRef.write(out, null);
+ out.writeInt(feature.getFeatureID());
+
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing fromIndex: {0}", fromIndex);
+ out.writeInt(fromIndex);
+
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing toIndex: {0}", toIndex);
+ out.writeInt(toIndex);
+ }
+
+ @Override
+ protected CDOID[] confirming(ExtendedDataInputStream in) throws IOException
+ {
+ int size = toIndex - fromIndex + 1;
+ CDOID[] ids = new CDOID[size];
+ for (int i = 0; i < ids.length; i++)
+ {
+ ids[i] = CDOIDImpl.read(in);
+ }
+
+ return ids;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
index d0c71f6..0ff9d29 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
@@ -20,6 +20,9 @@ import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl;
+import org.eclipse.emf.internal.cdo.CDOSessionImpl;
+import org.eclipse.emf.internal.cdo.CDOSessionPackageManager;
import org.eclipse.emf.internal.cdo.bundle.OM;
import java.io.IOException;
@@ -99,6 +102,9 @@ public class LoadRevisionRequest extends CDOClientRequest<CDORevisionImpl>
@Override
protected CDORevisionImpl confirming(ExtendedDataInputStream in) throws IOException
{
- return new CDORevisionImpl(in, getSession().getPackageManager());
+ CDOSessionImpl session = getSession();
+ CDORevisionManagerImpl revisionManager = session.getRevisionManager();
+ CDOSessionPackageManager packageManager = session.getPackageManager();
+ return new CDORevisionImpl(in, revisionManager, packageManager);
}
}