summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-10 05:48:46 (EDT)
committerEike Stepper2007-09-10 05:48:46 (EDT)
commit2f2e597d55716836623029b36fe44c67a609b955 (patch)
tree59c2ac9e776fb569effa313418d68f942f6d5a67
parentbcf4877d65661917e4f14876ba0fe4fa5153c213 (diff)
downloadcdo-2f2e597d55716836623029b36fe44c67a609b955.zip
cdo-2f2e597d55716836623029b36fe44c67a609b955.tar.gz
cdo-2f2e597d55716836623029b36fe44c67a609b955.tar.bz2
[202768] Optimize CDOIDTyped
https://bugs.eclipse.org/bugs/show_bug.cgi?id=202768
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java1
-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/QueryObjectTypesIndication.java72
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java78
5 files changed, 168 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
index 5024f49..5cd000e 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
@@ -176,7 +176,6 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
{
if (knownTypes.contains(id))
{
- // TODO On client-side add a check if the id is really known!
return id;
}
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 6107638..0bef49a 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
@@ -74,6 +74,9 @@ public class CDOServerProtocol extends SignalProtocol
case CDOProtocolConstants.SIGNAL_LOAD_CHUNK:
return new LoadChunkIndication();
+ case CDOProtocolConstants.SIGNAL_QUERY_OBJECT_TYPES:
+ return new QueryObjectTypesIndication();
+
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/QueryObjectTypesIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java
new file mode 100644
index 0000000..600784b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * 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.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.CDOClass;
+
+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 QueryObjectTypesIndication extends CDOReadIndication
+{
+ private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, QueryObjectTypesIndication.class);
+
+ private CDOID[] ids;
+
+ public QueryObjectTypesIndication()
+ {
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return CDOProtocolConstants.SIGNAL_QUERY_OBJECT_TYPES;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws IOException
+ {
+ int size = in.readInt();
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Reading {0} IDs", size);
+
+ ids = new CDOID[size];
+ for (int i = 0; i < ids.length; i++)
+ {
+ ids[i] = CDOIDImpl.read(in);
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Read ID: {0}", ids[i]);
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws IOException
+ {
+ RevisionManager revisionManager = getRevisionManager();
+ for (CDOID id : ids)
+ {
+ CDOClass type = revisionManager.getObjectType(id);
+ CDOClassRefImpl classRef = (CDOClassRefImpl)type.createClassRef();
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Wrinting type: {0}", classRef);
+ classRef.write(out, null);
+ }
+ }
+}
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 6955fd6..94e1888 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
@@ -16,12 +16,13 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.protocol.util.TransportException;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.net4j.IChannel;
@@ -50,6 +51,7 @@ import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.OpenSessionRequest;
import org.eclipse.emf.internal.cdo.protocol.OpenSessionResult;
+import org.eclipse.emf.internal.cdo.protocol.QueryObjectTypesRequest;
import org.eclipse.emf.internal.cdo.protocol.ViewsChangedNotification;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
import org.eclipse.emf.internal.cdo.util.ProxyResolverURIResourceMap;
@@ -443,10 +445,18 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
public CDOClassImpl requestObjectType(CDOID id)
{
- CDOClassRefImpl typeRef = null; // FIXME
- CDOClassImpl type = typeRef.resolve(packageManager);
- registerObjectType(id, type);
- return type;
+ try
+ {
+ QueryObjectTypesRequest request = new QueryObjectTypesRequest(channel, Collections.singletonList(id));
+ CDOClassRef[] typeRefs = getFailOverStrategy().send(request);
+ CDOClassImpl type = (CDOClassImpl)typeRefs[0].resolve(packageManager);
+ registerObjectType(id, type);
+ return type;
+ }
+ catch (Exception ex)
+ {
+ throw new TransportException(ex);
+ }
}
public void registerObjectType(CDOID id, CDOClassImpl type)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java
new file mode 100644
index 0000000..17c8639
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * 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.CDOClassRef;
+
+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;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class QueryObjectTypesRequest extends CDOClientRequest<CDOClassRef[]>
+{
+ private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, QueryObjectTypesRequest.class);
+
+ /**
+ * TODO Consider single id
+ */
+ private List<CDOID> ids;
+
+ public QueryObjectTypesRequest(IChannel channel, List<CDOID> ids)
+ {
+ super(channel);
+ this.ids = ids;
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return CDOProtocolConstants.SIGNAL_QUERY_OBJECT_TYPES;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws IOException
+ {
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing {0} IDs", ids.size());
+ out.writeInt(ids.size());
+
+ for (CDOID id : ids)
+ {
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing ID: {0}", id);
+ CDOIDImpl.write(out, id);
+ }
+ }
+
+ @Override
+ protected CDOClassRef[] confirming(ExtendedDataInputStream in) throws IOException
+ {
+ CDOClassRef[] types = new CDOClassRef[ids.size()];
+ for (int i = 0; i < types.length; i++)
+ {
+ types[i] = new CDOClassRefImpl(in, null);
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Read type: {0}", types[i]);
+ }
+
+ return types;
+ }
+}