summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-25 07:26:31 (EDT)
committerEike Stepper2007-08-25 07:26:31 (EDT)
commit9ee85f2b973b0d6bf18f0946df207e0783ccfe6b (patch)
treec08a277697fb9cd31ef8fd03ac007c93231c96f5
parente60607f76ca99bcea2f2c7b0f5152de334f5b2ea (diff)
downloadcdo-9ee85f2b973b0d6bf18f0946df207e0783ccfe6b.zip
cdo-9ee85f2b973b0d6bf18f0946df207e0783ccfe6b.tar.gz
cdo-9ee85f2b973b0d6bf18f0946df207e0783ccfe6b.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ObjectTypeMap.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java25
2 files changed, 87 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ObjectTypeMap.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ObjectTypeMap.java
new file mode 100644
index 0000000..34f5424
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ObjectTypeMap.java
@@ -0,0 +1,62 @@
+package org.eclipse.emf.cdo.internal.server;
+
+import org.eclipse.net4j.util.io.ExtendedIOUtil;
+import org.eclipse.net4j.util.io.SortedFileMap;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ObjectTypeMap extends SortedFileMap<Integer, String>
+{
+ public ObjectTypeMap(File file)
+ {
+ super(file, "rw");
+ }
+
+ @Override
+ public int getKeySize()
+ {
+ return 4;
+ }
+
+ @Override
+ protected Integer readKey(DataInput in) throws IOException
+ {
+ return in.readInt();
+ }
+
+ @Override
+ protected void writeKey(DataOutput out, Integer key) throws IOException
+ {
+ out.writeInt(key);
+ }
+
+ @Override
+ public int getValueSize()
+ {
+ return 20;
+ }
+
+ @Override
+ protected String readValue(DataInput in) throws IOException
+ {
+ return ExtendedIOUtil.readString(in);
+ }
+
+ @Override
+ protected void writeValue(DataOutput out, String value) throws IOException
+ {
+ byte[] bytes = value.getBytes();
+ if (bytes.length + 4 > getValueSize())
+ {
+ throw new IllegalArgumentException("Value size of " + getValueSize() + " exceeded: " + value);
+ }
+
+ ExtendedIOUtil.writeByteArray(out, bytes);
+ }
+}
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 39fc7c5..e03d0c1 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
@@ -13,6 +13,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.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.CDOIDRange;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
@@ -23,8 +24,10 @@ import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import java.io.File;
import java.text.MessageFormat;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -61,6 +64,10 @@ public class Repository extends Container implements IRepository
private ConcurrentMap<CDOID, CDOClassRef> objectTypes = new ConcurrentHashMap();
+ private ObjectTypeMap objectTypeMap;
+
+ private ObjectTypeMap metaObjectTypeMap;
+
public Repository(String name, IStore store)
{
if (StringUtil.isEmpty(name))
@@ -170,11 +177,26 @@ public class Repository extends Container implements IRepository
return MessageFormat.format("Repository[{0}, {1}]", name, uuid);
}
+ protected void initTypeMaps()
+ {
+ if (!store.hasEfficientTypeLookup())
+ {
+ File stateFolder = new File(OM.BUNDLE.getStateLocation());
+ File repositoryFolder = new File(stateFolder, uuid);
+ IOUtil.mkdirs(repositoryFolder);
+
+ objectTypeMap = new ObjectTypeMap(new File(repositoryFolder, "object.types"));
+ metaObjectTypeMap = new ObjectTypeMap(new File(repositoryFolder, "metaobject.types"));
+ }
+ }
+
@Override
protected void doActivate() throws Exception
{
super.doActivate();
LifecycleUtil.activate(store);
+ initTypeMaps();
+
packageManager.activate();
sessionManager.activate();
resourceManager.activate();
@@ -188,6 +210,9 @@ public class Repository extends Container implements IRepository
resourceManager.deactivate();
sessionManager.deactivate();
packageManager.deactivate();
+
+ IOUtil.close(metaObjectTypeMap);
+ IOUtil.close(objectTypeMap);
LifecycleUtil.deactivate(store);
super.doDeactivate();
}