diff options
author | Ibrahim Sallam | 2011-06-05 10:07:51 +0000 |
---|---|---|
committer | Ibrahim Sallam | 2011-06-05 10:07:51 +0000 |
commit | 370c42cb035bba5292c846429f5bfdea4c50e87f (patch) | |
tree | e2584e0be577d7d3915668a5ea72a04979d4d16d /plugins/org.eclipse.emf.cdo.server.objectivity | |
parent | c4ff05f58cefb655614f118424a02228094a6398 (diff) | |
download | cdo-370c42cb035bba5292c846429f5bfdea4c50e87f.tar.gz cdo-370c42cb035bba5292c846429f5bfdea4c50e87f.tar.xz cdo-370c42cb035bba5292c846429f5bfdea4c50e87f.zip |
Various changes and modifications for CDO 4.0, and changes to the internal structure to enhance performance.drops/I20110514-0431
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.objectivity')
39 files changed, 3040 insertions, 1098 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF index f7e4003433..e761f036b6 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF @@ -19,10 +19,10 @@ Export-Package: org.eclipse.emf.cdo.server.internal.objectivity;version="4.0.0"; org.eclipse.emf.cdo.server.internal.objectivity.schema;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity", org.eclipse.emf.cdo.server.internal.objectivity.utils;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity", org.eclipse.emf.cdo.server.objectivity;version="4.0.0" -Import-Package: com.objy.as;version="[3.0.0,4.0.0)", - com.objy.as.app;version="[3.0.0,4.0.0)", - com.objy.db;version="[3.0.0,4.0.0)", - com.objy.db.app;version="[3.0.0,4.0.0)", - com.objy.db.iapp;version="[3.0.0,4.0.0)", - com.objy.db.util;version="[3.0.0,4.0.0)", - com.objy.pm;version="[3.0.0,4.0.0)" +Import-Package: com.objy.as;version="[4.0.0,5.0.0)", + com.objy.as.app;version="[4.0.0,5.0.0)", + com.objy.db;version="[4.0.0,5.0.0)", + com.objy.db.app;version="[4.0.0,5.0.0)", + com.objy.db.iapp;version="[4.0.0,5.0.0)", + com.objy.db.util;version="[4.0.0,5.0.0)", + com.objy.pm;version="[4.0.0,5.0.0)" diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/rootfiles/cdo-server.xml b/plugins/org.eclipse.emf.cdo.server.objectivity/rootfiles/cdo-server.xml index 972509c147..2dc3e06fa3 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/rootfiles/cdo-server.xml +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/rootfiles/cdo-server.xml @@ -22,15 +22,21 @@ Objectivity store FD configuration, by passing _DEFAULT_ the internal default values will be user, for example, lockserverHost="_DEFAULT_" will use the local host. + For logging, the options are: + LogNone: no logging. + LogAll : Log session and transaction info. + LogSession : log only session info. --> <store type="objectivity"> <fdConfig name="test" - lockserverHost = "_DEFAULT_" + lockServerHost = "_DEFAULT_" fdDirPath = "c:\data" fdFileHost = "_DEFAULT_" fdNumber = "5555" dbDirPath = "_DEFAULT_" + logDirPath = "_DEFAULT_" + logOption = "LogNone" pageSize = "_DEFAULT_" SessionMinCacheSize = "600" SessionMaxCacheSize = "1000"> diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java index fba6ed700e..b9dbd79fbb 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java @@ -27,6 +27,9 @@ import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPropertyMapHandler import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema; import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope; import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyStoreInfo; import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb; import org.eclipse.emf.cdo.server.objectivity.IObjectivityStore; @@ -39,6 +42,7 @@ import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; import org.eclipse.net4j.util.om.trace.ContextTracer; import com.objy.db.app.Connection; +import com.objy.db.app.oo; import java.util.Map; import java.util.Set; @@ -47,7 +51,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; public class ObjectivityStore extends Store implements IObjectivityStore { - public static final String TYPE = "objectivity"; //$NON-NLS-1$ + public static final String TYPE = "objectivity"; // $NON-NLS, DurableLocking-1$ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjectivityStore.class); @@ -107,7 +111,7 @@ public class ObjectivityStore extends Store implements IObjectivityStore // Initialize schema as needed, and also any other config information // connection to the FD. - objyConnection.connect(storeConfig.getFdName()); + objyConnection.connect(storeConfig); Connection.current().setUserClassLoader(this.getClass().getClassLoader()); objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyStoreInfo"); //$NON-NLS-1$ @@ -115,9 +119,14 @@ public class ObjectivityStore extends Store implements IObjectivityStore objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageUnit"); //$NON-NLS-1$ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyCommitInfo"); //$NON-NLS-1$ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProperty"); //$NON-NLS-1$ + objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranch"); //$NON-NLS-1$ + objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager"); //$NON-NLS-1$ + objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockArea"); //$NON-NLS-1$ + objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager"); //$NON-NLS-1$ - ObjySession objySession = objyConnection.getWriteSessionFromPool("Main"); //$NON-NLS-1$ + ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName()); //$NON-NLS-1$ objySession.setRecoveryAutomatic(true); + objySession.setOpenMode(oo.openReadWrite); // we are initializing stuff, we need the read/write. objySession.begin(); ObjySchema.createBaseSchema(); @@ -160,6 +169,12 @@ public class ObjectivityStore extends Store implements IObjectivityStore objyPropertyMapHandler = new ObjyPropertyMapHandler(repositoryName); objyPackageHandler = new ObjyPackageHandler(repositoryName); + // more initializations. + ObjyLockAreaManager objyLockAreaManager = objySession.getLockAreaManager(repositoryName); + ObjyBranchManager objyBranchManager = objySession.getBranchManager(repositoryName); + ObjyResourceList objyResources = objySession.getResourceList(repositoryName); + + long t3 = System.currentTimeMillis(); objySession.commit(); storeInitialized = true; @@ -171,7 +186,7 @@ public class ObjectivityStore extends Store implements IObjectivityStore } finally { - objyConnection.returnSessionToPool(objySession); + objySession.returnSessionToPool(); } } @@ -201,13 +216,15 @@ public class ObjectivityStore extends Store implements IObjectivityStore @Override protected StoreAccessorPool getReaderPool(ISession session, boolean forReleasing) { - return readerPool; + // return readerPool; + return null; } @Override protected StoreAccessorPool getWriterPool(IView view, boolean forReleasing) { - return writerPool; + // return writerPool; + return null; } public boolean isLocal(CDOID id) @@ -268,12 +285,6 @@ public class ObjectivityStore extends Store implements IObjectivityStore { super.doActivate(); - // lazy initialization of the store. - if (!storeInitialized) - { - initStore(); - } - nActivate++; if (TRACER_DEBUG.isEnabled()) @@ -281,31 +292,41 @@ public class ObjectivityStore extends Store implements IObjectivityStore TRACER_DEBUG.trace("doActivate - count: " + nActivate); } - ObjySession objySession = objyConnection.getWriteSessionFromPool("Main"); - objySession.setRecoveryAutomatic(true); - objySession.begin(); - - try - { - if (!objySession.getFD().hasDB(getRepository().getName())) - { - // Create the repo DB. - ObjyScope.insureScopeExist(objySession, getRepository().getName(), ObjyDb.DEFAULT_CONT_NAME); - // ...do other initialisation of the repository here. - // Note that in the current implementation we don't delete DBs by default, only delete - // the containers (see ObjectivityStoreConfig.resetFD()) so any initialization done here - // might not be repeated. - } - - objySession.commit(); - } - catch (RuntimeException ex) + // lazy initialization of the store. + if (!storeInitialized) { - objySession.abort(); + // long tStart = System.currentTimeMillis(); + initStore(); + // System.out.println("... ObjyStore initStore() time: " + (System.currentTimeMillis() - tStart)); } - finally + else { - objyConnection.returnSessionToPool(objySession); + ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName()); + objySession.setRecoveryAutomatic(true); + objySession.begin(); + + try + { + if (!objySession.getFD().hasDB(getRepository().getName())) + { + // Create the repo DB. + ObjyScope.insureScopeExist(objySession, getRepository().getName(), ObjyDb.DEFAULT_CONT_NAME); + // ...do other initialisation of the repository here. + // Note that in the current implementation we don't delete DBs by default, only delete + // the containers (see ObjectivityStoreConfig.resetFD()) so any initialization done here + // might not be repeated. + } + + objySession.commit(); + } + catch (RuntimeException ex) + { + objySession.abort(); + } + finally + { + objySession.returnSessionToPool(); + } } } @@ -320,10 +341,14 @@ public class ObjectivityStore extends Store implements IObjectivityStore finally { ObjyConnection.INSTANCE.disconnect(); + // objyConnection.disconnect(); } - // readerPool.dispose(); - // writerPool.dispose(); + readerPool.dispose(); + writerPool.dispose(); + readerPool = null; + writerPool = null; + super.doDeactivate(); } @@ -338,7 +363,7 @@ public class ObjectivityStore extends Store implements IObjectivityStore throw new UnsupportedOperationException(); } - ObjySession objySession = objyConnection.getReadSessionFromPool("Main"); + ObjySession objySession = objyConnection.getReadSessionFromPool("Main_" + getRepository().getName()); objySession.begin(); Map<String, String> properties = objyPropertyMapHandler.getPropertyValues(names); objySession.commit(); @@ -347,7 +372,7 @@ public class ObjectivityStore extends Store implements IObjectivityStore public void setPersistentProperties(Map<String, String> properties) { - ObjySession objySession = objyConnection.getWriteSessionFromPool("Main"); + ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName()); objySession.begin(); objyPropertyMapHandler.setPropertyValues(properties); objySession.commit(); @@ -355,7 +380,7 @@ public class ObjectivityStore extends Store implements IObjectivityStore public void removePersistentProperties(Set<String> names) { - ObjySession objySession = objyConnection.getWriteSessionFromPool("Main"); + ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName()); objySession.begin(); objyPropertyMapHandler.removePropertyValues(names); objySession.commit(); @@ -373,7 +398,8 @@ public class ObjectivityStore extends Store implements IObjectivityStore public ObjyPlacementManager getGlobalPlacementManager() { - return ObjyConnection.INSTANCE.getDefaultPlacementManager(); + // return ObjyConnection.INSTANCE.getDefaultPlacementManager(); + return objyConnection.getDefaultPlacementManager(); } } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java index 2d63e0f4fc..1e73dcfc79 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java @@ -18,14 +18,19 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDExternal; import org.eclipse.emf.cdo.common.lob.CDOLobHandler; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea.Handler; import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionCacheAdder; import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; import org.eclipse.emf.cdo.server.IQueryHandler; import org.eclipse.emf.cdo.server.ISession; +import org.eclipse.emf.cdo.server.IStoreAccessor.DurableLocking; import org.eclipse.emf.cdo.server.ITransaction; import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM; import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManagerLocal; @@ -38,6 +43,7 @@ import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranch; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyCommitInfo; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList; import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil; import org.eclipse.emf.cdo.server.internal.objectivity.utils.SmartLock; @@ -59,14 +65,18 @@ import org.eclipse.emf.cdo.spi.server.StoreAccessor; import org.eclipse.net4j.util.ObjectUtil; import org.eclipse.net4j.util.collection.Pair; +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.om.monitor.OMMonitor.Async; import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.ResourceSet; +import com.objy.db.LockNotGrantedException; import com.objy.db.app.oo; import com.objy.db.app.ooId; import com.objy.db.app.ooObj; @@ -77,9 +87,11 @@ import java.io.OutputStream; import java.io.Reader; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.SortedSet; @@ -87,12 +99,10 @@ import java.util.SortedSet; * @author Simon McDuff * @author Ibrahim Sallam */ -public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectivityStoreAccessor +public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectivityStoreAccessor, DurableLocking { private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjectivityStoreAccessor.class); - private static final ContextTracer TRACER_ERROR = new ContextTracer(OM.ERROR, ObjectivityStoreAccessor.class); - private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjectivityStoreAccessor.class); protected ObjySession objySession = null; @@ -105,6 +115,12 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv boolean zipped = true; // TODO - might make this configurable... + private HashMap<CDOID, ObjyObject> newObjyObjectsMap = new HashMap<CDOID, ObjyObject>(); + + private long readRevisionTime = 0; + + private int readRevisionCount = 0; + protected ObjectivityStoreAccessor(ObjectivityStore store, ISession cdoSession) { super(store, cdoSession); @@ -155,6 +171,9 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { ensureSessionBegin(); + // System.out.println(">>>>IS:<<< detachObjects() " + this + " - objy session: " + objySession.toString()); + // objySession.addToLog("IS:>>>", "detachObjects - begin"); + try { monitor.begin(detachedObjects.length); @@ -165,10 +184,11 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv ooId containerID = OBJYCDOIDUtil.getContainerId(id); containerToLocks.add(containerID); } - lockContainers(containerToLocks); + objySession.lockContainers(containerToLocks); InternalCDORevisionManager revisionManager = getStore().getRepository().getRevisionManager(); + long tStart = System.currentTimeMillis(); for (CDOID id : detachedObjects) { @@ -179,11 +199,20 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv detachObject(id, version, branch, timeStamp); } + // objySession.addToLog("IS:>>>", "detachObjects - end"); + long tDiff = System.currentTimeMillis() - tStart; + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace("detach objects: " + detachedObjects.length + " - time: " + tDiff); + } + } finally { monitor.done(); } + + // System.out.println(">>>>IS:<<< detachObjects() DONE " + this + " - objy session: " + objySession.toString()); } /*** @@ -194,20 +223,30 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv */ private void detachObject(CDOID id, int version, CDOBranch branch, long timeStamp) { - ensureSessionBegin(); + // ensureSessionBegin(); ObjyObject objyObject = getObject(id); if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.trace("Detaching id " + objyObject.ooId().getStoreString()); + TRACER_DEBUG.trace("Detaching id " + id + " - OID: " + objyObject.ooId().getStoreString() + " verions: " + + version + " in Branch: " + branch.getID() + " and timeStamp: " + timeStamp); } - if (getStore().isRequiredToSupportAudits() || getStore().isRequiredToSupportBranches()) + if (getStore().isRequiredToSupportAudits()) { - // pick the proper version. - ObjyObject objyRevision = objyObject.getRevisionByVersion(version); - objyRevision.setRevisedTime(timeStamp - 1); + if (version > CDOBranchVersion.FIRST_VERSION) + { + // pick the proper version of that branch to revise it. Otherwise, the detached version will + // be in a different branch. + ObjyObject objyRevision = objyObject.getRevisionByVersion(version, branch.getID(), + objySession.getObjectManager()); + if (objyRevision.getVersion() < 0) + { + TRACER_DEBUG.trace("... OBJ is already detached..."); + } + objyRevision.setRevisedTime(timeStamp - 1); + } objyObject.detach(version, branch, timeStamp); } else @@ -234,43 +273,92 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv // getObjySession(); } - private void getObjySession() + public ObjySession getObjySession() { - // ISession cdoSession = getSession(); - // System.out.println(">>>>IS:<<< context's session: " + (cdoSession == null ? "null" : cdoSession.toString())); + int currSessionID = sessionID; - if (objySession != null) + if (!isReader()) { - return; + // The only reason we do this is because there was a switching of context in the middle + // of a transaction, and we want to ensure that we continue with the proper session that + // is holding the data. + ITransaction cdoTrx = getTransaction(); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG + .trace("getObjySession() - context's transaction: " + (cdoTrx == null ? "null" : cdoTrx.toString())); + } + if (cdoTrx != null) + { + sessionID = cdoTrx.getSession().getSessionID(); + } + } + + if (objySession != null && currSessionID == sessionID) + { + return objySession; } // get a session name. String sessionName = "Session_" + sessionID; - if (isRead && objySession == null) + if (objySession != null) { - objySession = getStore().getConnection().getReadSessionFromPool(sessionName); - // System.out.println(">>>>IS:<<<< Getting from Read Pool [name: " + sessionName + " - session:" + objySession + - // "]"); + objySession.returnSessionToPool(); } - else if (objySession == null) + if (isReader()) { - objySession = getStore().getConnection().getWriteSessionFromPool(sessionName); - // System.out.println(">>>>IS:<<<< Getting from Write Pool [name: " + sessionName + " - session:" + objySession + - // "]"); + objySession = getStore().getConnection().getReadSessionFromPool(sessionName + "_" + getRepositoryName()); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace(" getObjySession from read pool, session: " + objySession.toString() + " - isOpen: " + + objySession.isOpen() + " - sessionName:" + objySession.getName()); + } } + else + { + objySession = getStore().getConnection().getWriteSessionFromPool(sessionName + "_" + getRepositoryName()); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace(" getObjySession from write pool, session: " + objySession.toString() + " - isOpen: " + + objySession.isOpen() + " - sessionName:" + objySession.getName()); + } + } + if (!objySession.isOpen()) { objySession.setMrowMode(oo.MROW); objySession.setWaitOption(45000); objySession.setAllowUnregisterableTypes(true); + if (isRead) + { + objySession.setOpenMode(oo.openReadOnly); + } + else + { + objySession.setOpenMode(oo.openReadWrite); + } objySession.begin(); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace(" calling session.begin() for " + objySession.toString() + " - isRead: " + isRead); + } } + else + { + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace(" session " + objySession.toString() + " already open."); + } + } + + return objySession; } private void returnObjySession() { - // System.out.println(">>>>IS:<<<< Returning to pool, session: " + objySession); + // System.out.println(">>>>IS:<<<< Returning to pool, session: " + objySession + " - name: " + + // objySession.getName()); ensureSessionJoin(); // testDetachWithoutRevision_CheckMainBranch() is crashing because objySession is null. // TBD: verify this case!!! @@ -281,10 +369,10 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv if (objySession.isOpen()) { + // System.out.println(">>>>IS:<<<< commiting session: " + objySession + " - name: " + objySession.getName()); objySession.commit(); // IS: we might need to abort instead. } - // objySession.returnSessionToPool(); - getStore().getConnection().returnSessionToPool(objySession); + objySession.returnSessionToPool(); objySession = null; } @@ -306,7 +394,8 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv protected void doUnpassivate() throws Exception { // System.out.println(">>>>IS:<<<< StoreAccessor.doUnpassivate() " + this); - getObjySession(); + // IS: don't call this now, in case we don't have a context. + // getObjySession(); } // @Override @@ -348,6 +437,8 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv protected void writeRevisionDeltas(InternalCDORevisionDelta[] revisionDeltas, CDOBranch branch, long created, OMMonitor monitor) { + // System.out.println(">>>>IS:<<< writeRevisionDeltas() " + this + " - objy session: " + objySession.toString()); + long start = System.nanoTime(); ensureSessionBegin(); try @@ -360,7 +451,7 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv ooId containerID = OBJYCDOIDUtil.getContainerId(delta.getID()); containerToLocks.add(containerID); } - lockContainers(containerToLocks); + objySession.lockContainers(containerToLocks); for (InternalCDORevisionDelta revisionDelta : revisionDeltas) { @@ -371,6 +462,11 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { monitor.done(); } + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace(" writeRevisionDeltas: " + revisionDeltas.length + " - time: " + (System.nanoTime() - start) + / 1000000.0); + } } /** @@ -380,21 +476,34 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv * @param created * @param branch */ - private void writeRevisionDelta(InternalCDORevisionDelta delta, CDOBranch branch, long created) + private void writeRevisionDelta2(InternalCDORevisionDelta delta, CDOBranch branch, long created) { - ensureSessionBegin(); + // ensureSessionBegin(); int deltaVersion = delta.getVersion(); + int newVersion = CDOBranchVersion.FIRST_VERSION; ObjyObject objyObject = getObject(delta.getID()); - ObjyObject objyRevision = objyObject.getRevisionByVersion(deltaVersion); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.format("writingRevisionDelta getting Object: {0}, v:{1} - BranchId:{2}", objyObject.ooId() + .getStoreString(), deltaVersion, delta.getBranch().getID()); + } + ObjyObject objyOriginalRevision = objyObject.getRevisionByVersion(deltaVersion, delta.getBranch().getID(), + objySession.getObjectManager()); + + if (branch.getID() == delta.getBranch().getID()) + { + // Same branch, increase version + newVersion = deltaVersion + 1; + } if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.format("Writing revision delta: {0}, v:{1} - OID:{2}, v: {3}", delta, deltaVersion, objyObject - .ooId().getStoreString(), objyRevision.getVersion()); + TRACER_DEBUG.format("Writing revision delta: {0}, v:{1} - OID:{2}, v:{3} - BranchId:{4}", delta, deltaVersion, + objyObject.ooId().getStoreString(), objyOriginalRevision.getVersion(), objyOriginalRevision.getBranchId()); TRACER_DEBUG.format("... delta branch ID: {0} - revision branch ID: {1}", branch.getID(), - objyRevision.getBranchId()); + objyOriginalRevision.getBranchId()); } // System.out.println(">>>IS: Delta Writing: " + delta.getID() + " - oid: " + objyObject.ooId().getStoreString()); // System.out.println("\t - old version : " + delta.getVersion()); @@ -405,48 +514,176 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv // System.out.println("\t - delta : " + delta.toString()); // for debugging... - if (objyRevision.getVersion() != deltaVersion) + if (objyOriginalRevision.getVersion() != deltaVersion) { throw new RuntimeException("ObjecitivityStoreAccessor : Dirty write"); } - ObjyObject newObjyRevision = null; + ObjyObject objyNewRevision = null; if (getStore().isRequiredToSupportAudits()) { // newObjyRevision = objySession.getObjectManager().copyRevision(this, objyRevision); - objyRevision.setRevisedTime(branch.getPoint(created).getTimeStamp() - 1); // objyRevision.setRevisedBranchId(branch.getID(); + // InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager() + // .getRevisionByVersion(delta.getID(), delta, 0, true); InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager() - .getRevisionByVersion(delta.getID(), delta, 0, true); + .getRevisionByVersion(delta.getID(), delta.getBranch().getVersion(deltaVersion), 0, true); + + // 100917-IS: KISS - InternalCDORevision newRevision = originalRevision.copy(); + + // 100917-IS: KISS - newRevision.setVersion(deltaVersion + 1); + // 100917-IS: KISS - newRevision.setBranchPoint(delta.getBranch().getPoint(created)); + // 100917-IS: KISS - newObjyRevision = objySession.getObjectManager().newObject(newRevision.getEClass(), + // objyRevision.ooId()); + // 100917-IS: KISS - objyNewRevision.update(this, newRevision); - InternalCDORevision newRevision = originalRevision.copy(); + // create a new object, fill it with the original revision data, then + // modify the creation and the branch ID accordingly. + objyNewRevision = objySession.getObjectManager().newObject(originalRevision.getEClass(), + objyOriginalRevision.ooId()); + objyNewRevision.update(this, originalRevision); + objyNewRevision.setBranchId(delta.getBranch().getID()); + // the following are done at the end. + // objyNewRevision.setVersion(deltaVersion + 1); + // objyNewRevision.setCreationTime(created); - newRevision.setVersion(deltaVersion + 1); - newRevision.setBranchPoint(delta.getBranch().getPoint(created)); - newObjyRevision = objySession.getObjectManager().newObject(newRevision.getEClass(), objyRevision.ooId()); - newObjyRevision.update(this, newRevision); - objyObject.addToRevisions(newObjyRevision); + objyObject.addToRevisions(objyNewRevision); if (getStore().isRequiredToSupportBranches() /* && branch.getID() != CDOBranch.MAIN_BRANCH_ID */) { // add the newObjyRevision to the proper branch. ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(branch.getID()); - ooObj anObj = ooObj.create_ooObj(newObjyRevision.ooId()); + ooObj anObj = ooObj.create_ooObj(objyNewRevision.ooId()); objyBranch.addRevision(anObj); } + if (newVersion > CDORevision.FIRST_VERSION) + { + // revise the original revision last, otherwise we can end up with the revised date in the new revision. + objyOriginalRevision.setRevisedTime(branch.getPoint(created).getTimeStamp() - 1); + } } else { - newObjyRevision = objyRevision; + objyNewRevision = objyOriginalRevision; } - ObjectivityFeatureDeltaWriter visitor = new ObjectivityFeatureDeltaWriter(newObjyRevision); + ObjectivityFeatureDeltaWriter visitor = new ObjectivityFeatureDeltaWriter(objyNewRevision); delta.accept(visitor); - newObjyRevision.setCreationTime(branch.getPoint(created).getTimeStamp()); - newObjyRevision.setVersion(deltaVersion + 1); // TODO - verify with Eike if this is true!!! + objyNewRevision.setCreationTime(branch.getPoint(created).getTimeStamp()); + objyNewRevision.setVersion(newVersion); // TODO - verify with Eike if this is true!!! + } + + /** + * Called for each revision delta. + * + * @param delta + * @param created + * @param branch + */ + private void writeRevisionDelta(InternalCDORevisionDelta delta, CDOBranch branch, long created) + { + // ensureSessionBegin(); + + int deltaVersion = delta.getVersion(); + int newVersion = CDOBranchVersion.FIRST_VERSION; + + ObjyObject objyObject = getObject(delta.getID()); + TRACER_DEBUG.format("writingRevisionDelta getting Object: {0}, v:{1} - BranchId:{2}", objyObject.ooId() + .getStoreString(), deltaVersion, delta.getBranch().getID()); + ObjyObject objyOriginalRevision = objyObject.getRevisionByVersion(deltaVersion, delta.getBranch().getID(), + objySession.getObjectManager()); + + if (branch.getID() == delta.getBranch().getID()) + { + // Same branch, increase version + newVersion = deltaVersion + 1; + } + + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.format("Writing revision delta: {0}, v:{1} - OID:{2}, v:{3} - BranchId:{4}", delta, deltaVersion, + objyObject.ooId().getStoreString(), objyOriginalRevision.getVersion(), objyOriginalRevision.getBranchId()); + TRACER_DEBUG.format("... delta branch ID: {0} - revision branch ID: {1}", branch.getID(), + objyOriginalRevision.getBranchId()); + } + // System.out.println(">>>IS: Delta Writing: " + delta.getID() + " - oid: " + objyObject.ooId().getStoreString()); + // System.out.println("\t - old version : " + delta.getVersion()); + // System.out.println("\t - created : " + created); + // System.out.println("\t - delta.branch: " + delta.getBranch().toString()); + // System.out.println("\t - branch : " + branch.toString()); + // System.out.println("\t - branch TS : " + branch.getPoint(created).getTimeStamp()); + // System.out.println("\t - delta : " + delta.toString()); + // for debugging... + + if (objyOriginalRevision.getVersion() != deltaVersion) + { + throw new RuntimeException("ObjecitivityStoreAccessor : Dirty write"); + } + + ObjyObject objyNewRevision = null; + + if (getStore().isRequiredToSupportAudits()) + { + + ObjyObject objyObjectCopy = objySession.getObjectManager().copyRevision(this, objyOriginalRevision); + TRACER_DEBUG.format(" created new object:{0} by copying object:{1} - v:{2} - newBranch:{3}", objyObjectCopy + .ooId().getStoreString(), objyOriginalRevision.ooId().getStoreString(), objyOriginalRevision.getVersion(), + branch.getID()); + + // // newObjyRevision = objySession.getObjectManager().copyRevision(this, objyRevision); + // // objyRevision.setRevisedBranchId(branch.getID(); + // InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager() + // .getRevisionByVersion(delta.getID(), delta, CDORevision.UNCHUNKED, true); + // + // // 100917-IS: KISS - InternalCDORevision newRevision = originalRevision.copy(); + // + // // 100917-IS: KISS - newRevision.setVersion(deltaVersion + 1); + // // 100917-IS: KISS - newRevision.setBranchPoint(delta.getBranch().getPoint(created)); + // // 100917-IS: KISS - objyNewRevision = objySession.getObjectManager().newObject(newRevision.getEClass(), + // // objyOriginalRevision.ooId()); + // // 100917-IS: KISS - objyNewRevision.update(this, newRevision); + // + // // create a new object, fill it with the original revision data, then + // // modify the creation and the branch ID accordingly. + // objyNewRevision = objySession.getObjectManager().newObject(originalRevision.getEClass(), + // objyOriginalRevision.ooId()); + // objyNewRevision.update(this, originalRevision); + objyNewRevision = objyObjectCopy; + objyNewRevision.setBranchId(branch.getID()); + // the following are done at the end. + // objyNewRevision.setVersion(deltaVersion + 1); + // objyNewRevision.setCreationTime(created); + + objyObject.addToRevisions(objyNewRevision); + + if (getStore().isRequiredToSupportBranches() /* && branch.getID() != CDOBranch.MAIN_BRANCH_ID */) + { + // add the newObjyRevision to the proper branch. + ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(branch.getID()); + ooObj anObj = ooObj.create_ooObj(objyNewRevision.ooId()); + objyBranch.addRevision(anObj); + } + // revise the original revision last, otherwise we can end up with the revised date in the new revision. + // IS: it seems that in CDO 4.0 we don't need to do that anymore!! + if (newVersion > CDORevision.FIRST_VERSION) + { + objyOriginalRevision.setRevisedTime(branch.getPoint(created).getTimeStamp() - 1); + } + } + else + { + objyNewRevision = objyOriginalRevision; + } + + ObjectivityFeatureDeltaWriter visitor = new ObjectivityFeatureDeltaWriter(objyNewRevision); + + delta.accept(visitor); + + objyNewRevision.setCreationTime(branch.getPoint(created).getTimeStamp()); + objyNewRevision.setVersion(newVersion); // TODO - verify with Eike if this is true!!! } @Override @@ -461,9 +698,15 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv @Override protected void writeRevisions(InternalCDORevision[] revisions, CDOBranch branch, OMMonitor monitor) { - long start = System.currentTimeMillis(); + if (TRACER_DEBUG.isEnabled()) + { + ObjyObjectManager.getObjectTime = 0; + ObjyObjectManager.updateObjectTime = 0; + ObjyObjectManager.resourceCheckAndUpdateTime = 0; + } + long start = System.nanoTime(); ensureSessionBegin(); - + // objySession.addToLog("IS:>>>", "writeRevisions - begin"); try { monitor.begin(revisions.length); @@ -476,19 +719,31 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv } // containersToLock.add(objySession.getBranchManager(getRepositoryName()).getContainer().getOid()); // lockContainers(containersToLock); - + // long tStart = System.currentTimeMillis(); for (InternalCDORevision revision : revisions) { writeRevision(revision, monitor.fork()); } + // long tDiff = System.currentTimeMillis() - tStart; + // System.out.println(">>> IS: writing revisions: " + revisions.length + " - time: " + tDiff); } finally { + newObjyObjectsMap.clear(); monitor.done(); } + // objySession.addToLog("IS:>>>", "writeRevisions - end"); if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.trace("\t writeRevisions time: " + (System.currentTimeMillis() - start)); + TRACER_DEBUG + .trace(" writeRevisions: " + revisions.length + " - time: " + (System.nanoTime() - start) / 1000000.0); + // TRACER_DEBUG.trace(" getObjectTime: " + ObjyObjectManager.getObjectTime / 1000000.0); + // TRACER_DEBUG.trace(" updateObjectTime: " + ObjyObjectManager.updateObjectTime / 1000000.0); + // TRACER_DEBUG.trace(" resourceCheckAndUpdateTime: " + ObjyObjectManager.resourceCheckAndUpdateTime / + // 1000000.0); + // ObjyObjectManager.getObjectTime = 0; + // ObjyObjectManager.updateObjectTime = 0; + // ObjyObjectManager.resourceCheckAndUpdateTime = 0; } } @@ -501,153 +756,207 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv return objySession.getObjectManager().getObject(id); } - private void lockContainers(Set<ooId> containerToLocks) - { - // Locks all containers for modified objects - if (!containerToLocks.isEmpty()) - { - ooId idsToLock[] = containerToLocks.toArray(new ooId[containerToLocks.size()]); - while (true) - { - try - { - objySession.openContainers(idsToLock, oo.openReadWrite); - break; - } - catch (Exception e) - { - TRACER_INFO.trace("Locking problem try again : " + e.getMessage()); - // this.ensureNewBeginSession(); - if (!objySession.isOpen()) - { - TRACER_INFO.trace("Objy session is not open"); - // System.exit(-1); // TODO - this is temporary for debugging... - } - } - } - } - } - /***** * Use this code for heart beat. Async async = null; try { monitor.begin(getListMappings().size() + 1); async = * monitor.forkAsync(); reviseObject(accessor, id, timeStamp); } finally { async.stop(); monitor.done(); } [10:07:02 * AM] Eike Stepper: that one takes care that the heartbeat goes on [10:07:13 AM] Eike Stepper: for indefinite time */ - private void writeRevision(InternalCDORevision revision, OMMonitor fork) + private void writeRevision(InternalCDORevision revision, OMMonitor monitor) { - // EClass eClass = revision.getEClass(); - ObjyObject objyObject = getObject(revision.getID()); + Async async = null; - if (TRACER_DEBUG.isEnabled()) + try { - TRACER_DEBUG.format("Writing revision: {0} - OID: {1}", revision, objyObject.ooId().getStoreString()); //$NON-NLS-1$ - } + monitor.begin(1000); // IS: experimental. + async = monitor.forkAsync(); + + // EClass eClass = revision.getEClass(); + long __start = System.nanoTime(); + // ObjyObject objyObject = getObject(revision.getID()); + ObjyObject objyObject = newObjyObjectsMap.get(revision.getID()); + if (objyObject == null) + { + objyObject = getObject(revision.getID()); // we shouldn't need to come here. + } + ObjyObjectManager.getObjectTime += System.nanoTime() - __start; - // System.out.println(">>>IS: Writing: " + revision.getID() + " - oid: " + objyObject.ooId().getStoreString()); - // System.out.println("\t - version : " + revision.getVersion()); - // System.out.println("\t - timestamp : " + revision.getTimeStamp()); - // System.out.println("\t - revised : " + revision.getRevised()); - // System.out.println("\t - resourceId : " + revision.getResourceID()); - // System.out.println("\t - containerId: " + revision.getContainerID()); - // System.out.println("\t - branch : " + revision.getBranch().toString()); - // System.out.println("\t - revision : " + revision.toString()); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.format("Writing revision: {0} - OID: {1}", revision, objyObject.ooId().getStoreString()); //$NON-NLS-1$ + } - ObjyObject newObjyRevision = objyObject; + // System.out.println(">>>IS: Writing: " + revision.getID() + " - oid: " + objyObject.ooId().getStoreString()); + // System.out.println("\t - version : " + revision.getVersion()); + // System.out.println("\t - timestamp : " + revision.getTimeStamp()); + // System.out.println("\t - revised : " + revision.getRevised()); + // System.out.println("\t - resourceId : " + revision.getResourceID()); + // System.out.println("\t - containerId: " + revision.getContainerID()); + // System.out.println("\t - branch : " + revision.getBranch().toString()); + // System.out.println("\t - revision : " + revision.toString()); - if (revision.getVersion() > CDOBranchVersion.FIRST_VERSION) // we're updating other versions... - { - ObjyObject oldObjyRevision = objyObject.getRevisionByVersion(revision.getVersion() - 1); + ObjyObject newObjyRevision = objyObject; - if (oldObjyRevision == null) - { - new IllegalStateException("Revision with version: " + (revision.getVersion() - 1) + " is not in the store."); //$NON-NLS-1$ - } - if (getStore().isRequiredToSupportAudits()) + if (revision.getVersion() > CDOBranchVersion.FIRST_VERSION) // we're updating other versions... { - // if we allow versioning, then create a new one here. - // IS: I'm not sure if we'll be called here we always go to the writeRevisionDelta call. - newObjyRevision = objySession.getObjectManager().newObject(revision.getEClass(), oldObjyRevision.ooId()); - objyObject.addToRevisions(newObjyRevision); + // TRACER_DEBUG.format("...Updating other revisions using writeRevision()..."); + ObjyObject oldObjyRevision = objyObject.getRevisionByVersion(revision.getVersion() - 1, revision.getBranch() + .getID(), objySession.getObjectManager()); + if (oldObjyRevision == null) + { + new IllegalStateException("Revision with version: " + (revision.getVersion() - 1) + " is not in the store."); //$NON-NLS-1$ + } + if (getStore().isRequiredToSupportAudits()) + { + // if we allow versioning, then create a new one here. + // IS: I'm not sure if we'll be called here we always go to the writeRevisionDelta call. + newObjyRevision = objySession.getObjectManager().newObject(revision.getEClass(), oldObjyRevision.ooId()); + objyObject.addToRevisions(newObjyRevision); + + } + else + { + newObjyRevision = oldObjyRevision; + } } - else + + if (getStore().isRequiredToSupportBranches()) { - newObjyRevision = oldObjyRevision; + // add the newObjyRevision to the proper branch. + ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch( + revision.getBranch().getID()); + ooObj anObj = ooObj.create_ooObj(newObjyRevision.ooId()); + try + { + objyBranch.addRevision(anObj); + } + catch (LockNotGrantedException ex) + { + ex.printStackTrace(); + } } - } - if (getStore().isRequiredToSupportBranches()) - { - // add the newObjyRevision to the proper branch. - ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(revision.getBranch().getID()); - ooObj anObj = ooObj.create_ooObj(newObjyRevision.ooId()); - objyBranch.addRevision(anObj); - } + __start = System.nanoTime(); + newObjyRevision.update(this, revision); + ObjyObjectManager.updateObjectTime += System.nanoTime() - __start; - newObjyRevision.update(this, revision); - - // if it's a resource, collect it. - if (revision.isResourceNode()) - { - // Add resource to the list - ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName()); - - // before we update the data into the object we need to check - // if it's a resource and we're trying to add a duplicate. - // TODO - do we need to check for Folder and resouce, or is the isResourceNode() - // check is enough?!!! - if (revision.isResourceFolder() || revision.isResource()) + // if it's a resource, collect it. + if (revision.isResourceNode()) { - // this call will throw exception if we have a duplicate resource we trying to add. - resourceList.checkDuplicateResources(this, revision); + __start = System.nanoTime(); + // TODO - this is temp solution to lock the common resource list + // Add resource to the list + ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName()); + ooObj anObj = (ooObj)objySession.getFD().objectFrom(resourceList.ooId()); + SmartLock.lock(anObj.getContainer()); + + // before we update the data into the object we need to check + // if it's a resource and we're trying to add a duplicate. + // TODO - do we need to check for Folder and resouce, or is the isResourceNode() + // check is enough?!!! + if (revision.isResourceFolder() || revision.isResource()) + { + // this call will throw exception if we have a duplicate resource we trying to add. + resourceList.checkDuplicateResources(this, revision); + } + SmartLock.lock(newObjyRevision); + try + { + resourceList.add(newObjyRevision); + } + catch (LockNotGrantedException ex) + { + ex.printStackTrace(); + } + ObjyObjectManager.resourceCheckAndUpdateTime += System.nanoTime() - __start; } - SmartLock.lock(newObjyRevision); - resourceList.add(newObjyRevision); + } + finally + { + async.stop(); + monitor.done(); } } @Override protected void doCommit(OMMonitor monitor) { - // ISession cdoSession = getSession(); - // System.out.println(">>>>IS:<<< doCommit() " + this + " - context's session: " - // + (cdoSession == null ? "null" : cdoSession.toString())); + // System.out.println(">>>>IS:<<< doCommit() " + this + " - objy session: " + objySession.toString()); long start = System.currentTimeMillis(); + Async async = null; + monitor.begin(); + try { - // The commit request might come from a different thread. - ensureSessionJoin(); - - if (TRACER_DEBUG.isEnabled()) - { - TRACER_DEBUG.trace("Committing ..." + objySession + " nc:" + objySession.nestCount()); - } - if (objySession.isOpen() == true) - { - objySession.commit(); - } - else + try { - TRACER_DEBUG.trace("Error: calling objySession.commit() without having an open trx."); - } + async = monitor.forkAsync(); + // The commit request might come from a different thread. + ensureSessionJoin(); - if (TRACER_DEBUG.isEnabled()) + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace("Committing ..." + objySession + " nc:" + objySession.nestCount()); + } + if (objySession.isOpen() == true) + { + objySession.commit(); + } + else + { + TRACER_DEBUG.trace("Error: calling objySession.commit() without having an open trx."); + } + + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace("Committed"); + } + } + finally { - TRACER_DEBUG.trace("Committed"); + if (async != null) + { + async.stop(); + } } } catch (RuntimeException exception) { - TRACER_ERROR.trace(exception.getMessage(), exception); + TRACER_INFO.trace(exception.getMessage(), exception); exception.printStackTrace(); throw exception; } + finally + { + monitor.done(); + } + + // 100920 - IS: for debugging if (TRACER_DEBUG.isEnabled()) { + // TRACER_DEBUG.trace("doCommit() - new objects created: " + ObjyObjectManager.newObjCount + " - Internal: " + // + ObjyObjectManager.newInternalObjCount); + // ObjyObjectManager.newObjCount = 0; + // ObjyObjectManager.newInternalObjCount = 0; + TRACER_DEBUG.trace(" readRvisions: " + readRevisionCount + " - time: " + readRevisionTime / 1000000.0); + TRACER_DEBUG.trace(" fetchCount: " + ObjyObject.fetchCount + " - updateCount: " + ObjyObject.updateCount); TRACER_DEBUG.trace("\t commit time: " + (System.currentTimeMillis() - start)); + readRevisionTime = 0; + readRevisionCount = 0; + ObjyObject.fetchCount = 0; + ObjyObject.updateCount = 0; } + // System.out.println("IS:>>> ObjyObject.ctor(): count " + ObjyObject.count + " - totalTime: " + ObjyObject.tDiff); + // for (ooId oid : ObjyObject.oids) + // { + // System.out.println("<" + oid.getStoreString() + "> "); + // } + // System.out.println(); + // ObjyObject.count = 0; + // ObjyObject.tDiff = 0; + // ObjyObject.oids.clear(); } public IObjectivityStoreChunkReader createChunkReader(InternalCDORevision revision, EStructuralFeature feature) @@ -697,8 +1006,12 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv String pathPrefix = context.getName(); boolean exactMatch = context.exactMatch(); - // System.out.println(">>>>IS:<<<< queryResources() for : " + (pathPrefix == null ? "NULL" : pathPrefix) - // + " - exactMatch: " + exactMatch); + + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.format("queryResources() for : " + (pathPrefix == null ? "NULL" : pathPrefix) + " - exactMatch: " + + exactMatch); + } ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName()); int size = resourceList.size(); if (size == 0) // nothing yet. @@ -719,11 +1032,28 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv // get the proper revision of the resource (might need to refactor this code, see readRevision()) if (getStore().isRequiredToSupportBranches()) { - resourceRevision = resource.getRevision(context.getTimeStamp(), context.getBranch().getID()); + try + { + resourceRevision = resource.getRevision(context.getTimeStamp(), context.getBranch().getID(), + objySession.getObjectManager()); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } + } else if (getStore().isRequiredToSupportAudits()) { - resourceRevision = resource.getRevision(context.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID); + try + { + resourceRevision = resource.getRevision(context.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID, + objySession.getObjectManager()); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } } if (resourceRevision == null || resourceRevision.getVersion() < 0) @@ -732,24 +1062,17 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv } String resourceName = ObjyResourceList.getResourceName(resourceRevision); - if (exactMatch && pathPrefix != null && pathPrefix.equals(resourceName)) + CDOID resourceID = OBJYCDOIDUtil.getCDOID(resource.ooId()); + if (exactMatch && pathPrefix != null && pathPrefix.equals(resourceName) || pathPrefix == null + && resourceName == null) { - CDOID resourceID = OBJYCDOIDUtil.getCDOID(resource.ooId()); if (!context.addResource(resourceID)) { - // System.out.println(" >>IS:<<<< queryResources() got: " + - // resource.ooId().getStoreString() + " - version: " + resource.getVersion()); - // No more results allowed - break; // don't continue - } - } - else if (pathPrefix == null && resourceName == null) - { - CDOID resourceID = OBJYCDOIDUtil.getCDOID(resource.ooId()); - if (!context.addResource(resourceID)) - { - // System.out.println(" >>IS:<<<< queryResources() got: " + - // resource.ooId().getStoreString() + " - version: " + resource.getVersion()); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.format(" queryResources(1.1) got: " + resource.ooId().getStoreString() + " - version: " + + resource.getVersion()); + } // No more results allowed break; // don't continue } @@ -758,8 +1081,12 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { if (resourceName.startsWith(pathPrefix)) { - CDOID resourceID = OBJYCDOIDUtil.getCDOID(resource.ooId()); context.addResource(resourceID); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.format(" queryResources(1.2) got: " + resource.ooId().getStoreString() + " - version: " + + resource.getVersion()); + } } } /*** @@ -775,8 +1102,91 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv public void queryXRefs(QueryXRefsContext context) { - // TODO: implement ObjectivityStoreAccessor.queryXRefs(context) - throw new UnsupportedOperationException(); + ensureSessionBegin(); + + Set<CDOID> targetIDs = context.getTargetObjects().keySet(); + Map<EClass, List<EReference>> sourceCandidates = context.getSourceCandidates(); + + // get the context branch. + CDOBranch branch = context.getBranch(); + ObjyBranchManager branchManager = objySession.getBranchManager(getRepositoryName()); + ObjyBranch objyBranch = branchManager.getBranch(branch.getID()); + + // iterate over all revision in a branch. + ObjyObject objyObject = null; + SortedSet<?> revisions = objyBranch.getRevisions(); + for (Object anObj : revisions) + { + // the ooObj we get from revisions is the correct one for that branch. + objyObject = objySession.getObjectManager().getObject(((ooObj)anObj).getOid()); + + // InternalCDORevision revision = getRevision(list, context); + // if (revision == null || revision instanceof SyntheticCDORevision) + // { + // continue; + // } + // + EClass eClass = ObjySchema.getEClass(getStore(), objyObject.objyClass()); + CDOID sourceID = objyObject.getRevisionId(); + + List<EReference> eReferences = sourceCandidates.get(eClass); + if (eReferences != null) + { + for (EReference eReference : eReferences) + { + if (eReference.isMany()) + { + @SuppressWarnings("unchecked") + List<Object> results = objyObject.fetchList(this, eReference, 0, CDORevision.UNCHUNKED); + if (results != null) + { + try + { + int index = 0; + for (Object id : results) + { + if (!queryXRefs(context, targetIDs, (CDOID)id, sourceID, eReference, index++)) + { + return; + } + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } + else + { + Object value = objyObject.get(eReference); + CDOID id = (CDOID)value; + if (!queryXRefs(context, targetIDs, id, sourceID, eReference, 0)) + { + return; + } + } + } + } + } + } + + private boolean queryXRefs(QueryXRefsContext context, Set<CDOID> targetIDs, CDOID targetID, CDOID sourceID, + EReference sourceReference, int index) + { + for (CDOID id : targetIDs) + { + if (id.equals(targetID)) + { + if (!context.addXRef(targetID, sourceID, sourceReference, index)) + { + // No more results allowed + return false; + } + } + } + + return true; } /** @@ -800,16 +1210,27 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv } /** - * - */ + * + */ public InternalCDORevision readRevision(CDOID id, CDOBranchPoint branchPoint, int listChunk, CDORevisionCacheAdder cache) { + long __start = System.nanoTime(); ensureSessionBegin(); if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.format("Reading revision for: {0}", id); //$NON-NLS-1$ + TRACER_DEBUG.format("RR - Read rev for: {0}, TS:{1}", id, branchPoint.getTimeStamp()); //$NON-NLS-1$ + } + + // we shouldn't be doing this!!! + if (id instanceof CDOIDExternal) + { + // 100917 - IS: This must be a bug in CDO, it's throwing a CDOIDExternal at us + // we'll return null. + // TRACER_DEBUG.format("objy can't read revision for CDOID: {0}, it's external.", id.toString()); + TRACER_DEBUG.trace("objy can't read revision for external CDOID: " + id.toString()); + return null; } // we might have a proxy object!!!! @@ -820,10 +1241,14 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.format("objyObject is NULL"); //$NON-NLS-1$ + TRACER_DEBUG.format("RR - objyObject is NULL 4 ID:" + id); //$NON-NLS-1$ } return null; } + // else + // { + // TRACER_DEBUG.format("RR - objyObject is ID:" + id + ", :" + objyObject.ooId().getStoreString()); //$NON-NLS-1$ + // } InternalCDORevision revision = createRevision(objyObject, id); revision.setBranchPoint(branchPoint); @@ -832,18 +1257,47 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv if (getStore().isRequiredToSupportBranches()) { - objyRevision = objyObject.getRevision(branchPoint.getTimeStamp(), branchPoint.getBranch().getID()); + try + { + objyRevision = objyObject.getRevision(branchPoint.getTimeStamp(), branchPoint.getBranch().getID(), + objySession.getObjectManager()); + if (objyRevision == null) + { + TRACER_DEBUG + .format( + "RR - branches ID:{0}, OB:{1}, BPB:{2}, BPTS:{3}", id, objyObject.getBranchId(), branchPoint.getBranch().getID(), branchPoint.getTimeStamp()); //$NON-NLS-1$ + } + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } } else if (getStore().isRequiredToSupportAudits()) { - objyRevision = objyObject.getRevision(branchPoint.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID); + try + { + objyRevision = objyObject.getRevision(branchPoint.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID, + objySession.getObjectManager()); + if (objyRevision == null) + { + TRACER_DEBUG + .format( + "RR - audit ID:{0}, OB:{1}, BPB:{2}, BPTS:{3}", id, objyObject.getBranchId(), branchPoint.getBranch().getID(), branchPoint.getTimeStamp()); //$NON-NLS-1$ + } + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } + } if (objyRevision == null) { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.format("objyRevision is NULL"); //$NON-NLS-1$ + TRACER_DEBUG.format("RR - objyRevision is NULL 4 ID:" + id); //$NON-NLS-1$ } return null; } @@ -853,7 +1307,8 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.format("...revision for: {0} - OID: {1} is detached.", id, objyObject.ooId().getStoreString()); //$NON-NLS-1$ + TRACER_DEBUG + .format("RR - ...revision for: {0} - OID: {1} is detached.", id, objyObject.ooId().getStoreString()); //$NON-NLS-1$ } EClass eClass = ObjySchema.getEClass(getStore(), objyObject.objyClass()); return new DetachedCDORevision(eClass, id, branchPoint.getBranch(), -objyRevision.getVersion(), @@ -865,11 +1320,20 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.format("Fetching revision details for: {0} - OID: {1}", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$ + TRACER_DEBUG + .format("RR - Fetching revision details for: {0} - OID:{1}", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$ } boolean ok = objyRevision.fetch(this, revision, listChunk); + if (!ok) + { + TRACER_DEBUG.format("RR - Fetch rev failed 4: {0}, :{1}", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$ + } + + readRevisionTime += System.nanoTime() - __start; + readRevisionCount++; + return ok ? revision : null; } @@ -879,8 +1343,14 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv public InternalCDORevision readRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int listChunk, CDORevisionCacheAdder cache) { + long __start = System.nanoTime(); ensureSessionBegin(); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.format("RRBV - Read rev 4: {0}, ver: {1}", id, branchVersion.getVersion()); //$NON-NLS-1$ + } + // we might have a proxy object!!!! ObjyObject objyObject = getObject(id); @@ -888,13 +1358,18 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.format("objyObject is NULL"); //$NON-NLS-1$ + TRACER_DEBUG.format("RRBV - objyObject is NULL for ID: " + id); //$NON-NLS-1$ } return null; } + // { + // TRACER_DEBUG.format("RRBV - objyObject 4 ID: " + id + ", :" + objyObject.ooId().getStoreString()); //$NON-NLS-1$ + // } + ObjyObject objyRevision = null; - objyRevision = objyObject.getRevisionByVersion(branchVersion.getVersion()); + objyRevision = objyObject.getRevisionByVersion(branchVersion.getVersion(), branchVersion.getBranch().getID(), + objySession.getObjectManager()); // if (getStore().isRequiredToSupportAudits()) // { // objyRevision = objyObject.getRevisionByVersion(branchVersion.getVersion()); @@ -921,7 +1396,7 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.format("objyRevision is NULL"); //$NON-NLS-1$ + TRACER_DEBUG.format("RRBV - objyRevision is NULL for ID: ", id); //$NON-NLS-1$ } return null; } @@ -945,16 +1420,15 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv id + " - version requested was " + branchVersion + "."); //$NON-NLS-1$ //$NON-NLS-2$ } - return ok ? revision : null; - } + // if (!ok) + // { + // TRACER_DEBUG.format("RRBV - Fetch rev failed 4: {0}, :", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$ + // } - /*** - * TODO - I haven't seen this being implemented in other stores. Find out what it suppose to mean? Could it be that we - * need to refresh all the objects we have in the session, i.e. the weak list in ObjyObjectManager for that session!! - */ - public void refreshRevisions() - { - // TODO Auto-generated method stub + readRevisionTime += System.nanoTime() - __start; + readRevisionCount++; + + return ok ? revision : null; } public void writePackageUnits(InternalCDOPackageUnit[] packageUnits, OMMonitor monitor) @@ -1003,7 +1477,7 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv @Override public void addIDMappings(InternalCommitContext commitContext, OMMonitor monitor) { - long start = System.currentTimeMillis(); + long __start = System.nanoTime(); ensureSessionBegin(); if (commitContext.getNewObjects().length > 0) { @@ -1011,21 +1485,43 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { TRACER_DEBUG.trace("creating " + commitContext.getNewObjects().length + " new objects and assigning new IDs"); } - InternalCDORevision[] newObjects = commitContext.getNewObjects(); - monitor.begin(newObjects.length); + try + { + monitor.begin(newObjects.length); - ObjyPlacementManagerLocal placementManager = new ObjyPlacementManagerLocal(getStore(), objySession, commitContext); + ObjyPlacementManagerLocal placementManager = new ObjyPlacementManagerLocal(getStore(), objySession, + commitContext, newObjyObjectsMap); - // iterate over the list and skip the ones we already have created. - for (InternalCDORevision revision : newObjects) + // iterate over the list and skip the ones we already have created. + for (InternalCDORevision revision : newObjects) + { + try + { + placementManager.processRevision(revision); + } + catch (com.objy.db.ObjyRuntimeException ex) + { + System.out.println(">>>>IS: Exception<<<< Session: " + objySession + " open status: " + + objySession.isOpen()); + ex.printStackTrace(); + } + monitor.worked(); + } + } + finally { - placementManager.processRevision(revision); + monitor.done(); } } if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.trace("addIDMappings time: " + (System.currentTimeMillis() - start)); + TRACER_DEBUG.trace(" addIDMappings for " + commitContext.getNewObjects().length + " - time: " + + (System.nanoTime() - __start) / 1000000.0); + TRACER_DEBUG.trace(" createObjects : " + ObjyObject.createObjectCount + " - time: " + + ObjyObject.createObjectTime / 1000000.0); + ObjyObject.createObjectTime = 0; + ObjyObject.createObjectCount = 0; } } @@ -1039,16 +1535,35 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv /*************************** * Local Utility functions. ***************************/ + public void ensureActiveSession() + { + ensureSessionBegin(); + } + protected void ensureSessionBegin() { getObjySession(); - objySession.join(); + if (!objySession.isJoined()) + { + objySession.join(); + } if (!objySession.isOpen()) { + if (isRead) + { + objySession.setOpenMode(oo.openReadOnly); + } + else + { + objySession.setOpenMode(oo.openReadWrite); + } objySession.begin(); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace(" ensureBeginSession() called begin() on session: " + objySession + " [name: " + + objySession.getName() + " - open: " + objySession.isOpen() + "]"); + } } - // System.out.println(">>>>IS:<<<< ensureBeginSession() - session: " + objySession + - // " [open: "+ objySession.isOpen() + "]"); } private void ensureSessionJoin() @@ -1057,7 +1572,7 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv assert objySession != null; // testSwitchViewTarget() is crashing because objySession is null. // TBD: verify this case!!! - if (objySession != null) + if (objySession != null && !objySession.isJoined()) { objySession.join(); } @@ -1106,8 +1621,15 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv ensureSessionBegin(); // we need to write the following... // ...branch.getID(), timeStamp, userID, comment. - ObjyCommitInfoHandler commitInfoHandler = getStore().getCommitInfoHandler(); - commitInfoHandler.writeCommitInfo(branch.getID(), timeStamp, previousTimeStamp, userID, comment); + try + { + ObjyCommitInfoHandler commitInfoHandler = getStore().getCommitInfoHandler(); + commitInfoHandler.writeCommitInfo(branch.getID(), timeStamp, previousTimeStamp, userID, comment); + } + catch (com.objy.db.ObjyRuntimeException ex) + { + ex.printStackTrace(); + } } public IQueryHandler getQueryHandler(org.eclipse.emf.cdo.common.util.CDOQueryInfo info) @@ -1123,7 +1645,22 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo) { ensureSessionBegin(); - return objySession.getBranchManager(getRepositoryName()).createBranch(branchID, branchInfo); + // IS: this is a hack to overcome the issue in cdo core where the Accessor is requested for + // read but it's trying to create stuff. + if (isRead) + { + TRACER_DEBUG.trace("-->> createBranch() - Hack... Hack... changing read to update."); + // upgrade the session to update. + objySession.commit(); + objySession.setOpenMode(oo.openReadWrite); + objySession.begin(); + } + Pair<Integer, Long> retValue = objySession.getBranchManager(getRepositoryName()).createBranch(branchID, branchInfo); + // return the session to read. + objySession.commit(); + objySession.setOpenMode(oo.openReadOnly); + objySession.begin(); + return retValue; } public BranchInfo loadBranch(int branchID) @@ -1213,9 +1750,11 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv { int size = revisions.size(); monitor.begin(size); - + Async async = null; try { + async = monitor.forkAsync(); + Iterator<?> objItr = revisions.iterator(); while (objItr.hasNext()) { @@ -1233,7 +1772,9 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv } finally { + async.stop(); monitor.done(); + } } @@ -1268,4 +1809,107 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv // TODO: implement ObjectivityStoreAccessor.writeClob(id, size, reader) throw new UnsupportedOperationException(); } + + public void rawExport(CDODataOutput out, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime) + throws IOException + { + // TODO: implement ObjectivityStoreAccessor.rawExport(); + throw new UnsupportedOperationException(); + } + + public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime, + OMMonitor monitor) throws IOException + { + // TODO: implement ObjectivityStoreAccessor.rawImport + throw new UnsupportedOperationException(); + } + + public void rawStore(InternalCDOPackageUnit[] packageUnits, OMMonitor monitor) + { + // TODO: implement ObjectivityStoreAccessor.rawStore + throw new UnsupportedOperationException(); + } + + public void rawStore(InternalCDORevision revision, OMMonitor monitor) + { + // TODO: implement ObjectivityStoreAccessor.rawStore + throw new UnsupportedOperationException(); + } + + public void rawStore(byte[] id, long size, InputStream inputStream) throws IOException + { + // TODO: implement ObjectivityStoreAccessor.rawStore + throw new UnsupportedOperationException(); + } + + public void rawStore(byte[] id, long size, Reader reader) throws IOException + { + // TODO: implement ObjectivityStoreAccessor.rawStore + throw new UnsupportedOperationException(); + } + + public void rawStore(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID, String comment, + OMMonitor monitor) + { + // TODO: implement ObjectivityStoreAccessor.rawStore + throw new UnsupportedOperationException(); + } + + public void rawDelete(CDOID id, int version, CDOBranch branch, EClass eClass, OMMonitor monitor) + { + // TODO: implement ObjectivityStoreAccessor.rawDelete + throw new UnsupportedOperationException(); + } + + public void rawCommit(double commitWork, OMMonitor monitor) + { + // TODO: implement ObjectivityStoreAccessor.rawCommit + throw new UnsupportedOperationException(); + } + + public LockArea createLockArea(String userID, CDOBranchPoint branchPoint, boolean readOnly, + Map<CDOID, LockGrade> locks) + { + // TODO: implement ObjectivityStoreAccessor.createLockArea + throw new UnsupportedOperationException(); + } + + public LockArea getLockArea(String durableLockingID) throws LockAreaNotFoundException + { + // TODO: implement ObjectivityStoreAccessor.getLockArea + throw new UnsupportedOperationException(); + } + + public void getLockAreas(String userIDPrefix, Handler handler) + { + ensureSessionBegin(); + + InternalCDOBranchManager branchManager = getStore().getRepository().getBranchManager(); + ObjyLockAreaManager objyLockAreaManager = objySession.getLockAreaManager(getRepositoryName()); + objyLockAreaManager.getLockAreas(branchManager, userIDPrefix, handler); + } + + public void deleteLockArea(String durableLockingID) + { + // TODO: implement ObjectivityStoreAccessor.deleteLockArea + throw new UnsupportedOperationException(); + } + + public void lock(String durableLockingID, LockType type, Collection<? extends Object> objectsToLock) + { + // TODO: implement ObjectivityStoreAccessor.lock + throw new UnsupportedOperationException(); + } + + public void unlock(String durableLockingID, LockType type, Collection<? extends Object> objectsToUnlock) + { + // TODO: implement ObjectivityStoreAccessor.unlock + throw new UnsupportedOperationException(); + } + + public void unlock(String durableLockingID) + { + // TODO: implement ObjectivityStoreAccessor.unlock + throw new UnsupportedOperationException(); + } } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java index 174055a2dd..bd47138ae0 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java @@ -39,8 +39,10 @@ public class ObjectivityStoreChunkReader extends StoreChunkReader implements IOb public List<Chunk> executeRead() { CDOID id = getRevision().getID(); + getAccessor().ensureActiveSession(); ObjyObject objyObject = getAccessor().getObject(id); - ObjyObject objyRevision = objyObject.getRevisionByVersion(getRevision().getVersion()); + ObjyObject objyRevision = objyObject.getRevisionByVersion(getRevision().getVersion(), getRevision().getBranch() + .getID(), getAccessor().getObjySession().getObjectManager()); List<Chunk> chunks = getChunks(); @@ -50,11 +52,12 @@ public class ObjectivityStoreChunkReader extends StoreChunkReader implements IOb int chunkSize = chunk.size(); // get the data from the feature. - Object[] objects = objyRevision.fetch(getAccessor(), getFeature(), chunkStartIndex, chunkSize); + List<Object> objects = objyRevision.fetchList(getAccessor(), getFeature(), chunkStartIndex, chunkSize); // although we asked for a chunkSize we might get less. - for (int i = 0; i < objects.length; i++) + int i = 0; + for (Object obj : objects) { - chunk.add(i, objects[i]); + chunk.add(i++, obj); } } return chunks; diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java index 75d4b087ba..d781a073a6 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java @@ -16,6 +16,9 @@ import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreConfig; import org.eclipse.net4j.util.lifecycle.Lifecycle; +import com.objy.db.app.Connection; +import com.objy.db.app.oo; + import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -29,6 +32,8 @@ public class ObjectivityStoreConfig extends Lifecycle implements IObjectivitySto private int sessionMaxCacheSize = 0; + private int logOption = oo.LogNone; + public ObjectivityStoreConfig() { // fdManager.deleteFD(); @@ -37,7 +42,6 @@ public class ObjectivityStoreConfig extends Lifecycle implements IObjectivitySto public ObjectivityStoreConfig(Element storeConfig) { - // TODO - implement me!!! // for now we'll just call the default configuration... getFdProperties(storeConfig); fdManager.configure(); @@ -60,7 +64,6 @@ public class ObjectivityStoreConfig extends Lifecycle implements IObjectivitySto @Override public void doDeactivate() { - // System.out.println("ObjectivityStoreConfig.doDeactivate()"); fdManager.deleteFD(); } @@ -71,9 +74,12 @@ public class ObjectivityStoreConfig extends Lifecycle implements IObjectivitySto public void resetFD() { - // System.out.println("ObjectivityStoreConfig.resetFD() - Start."); + if (Connection.current() == null) + { + return; + } + fdManager.removeData(); - // system.out.println("ObjectivityStoreConfig.resetFD() - END."); } private void getFdProperties(Element storeConfig) @@ -88,7 +94,8 @@ public class ObjectivityStoreConfig extends Lifecycle implements IObjectivitySto String fdName = fdConfig.getAttribute("name"); //$NON-NLS-1$ String lockServerHost = fdConfig.getAttribute("lockServerHost"); //$NON-NLS-1$ String fdDirPath = fdConfig.getAttribute("fdDirPath"); //$NON-NLS-1$ - // String dbDirPath = fdConfig.getAttribute("dbDirPath"); //$NON-NLS-1$ + String dbDirPath = fdConfig.getAttribute("dbDirPath"); //$NON-NLS-1$ + String logDirPath = fdConfig.getAttribute("logDirPath");//$NON-NLS-1$ String fdFileHost = fdConfig.getAttribute("fdFileHost"); //$NON-NLS-1$ String fdNumber = fdConfig.getAttribute("fdNumber"); //$NON-NLS-1$ String pageSize = fdConfig.getAttribute("pageSize"); //$NON-NLS-1$ @@ -97,8 +104,20 @@ public class ObjectivityStoreConfig extends Lifecycle implements IObjectivitySto sessionMinCacheSize = getIntegerValue(fdConfig.getAttribute("SessionMinCacheSize"), 0); //$NON-NLS-1$ sessionMaxCacheSize = getIntegerValue(fdConfig.getAttribute("SessionMaxCacheSize"), 0); //$NON-NLS-1$ + // Log options. + String logOptionString = fdConfig.getAttribute("logOption"); + if (logOptionString.equalsIgnoreCase("LogAll")) + { + logOption = oo.LogAll; + } + else if (logOptionString.equalsIgnoreCase("LogSession")) + { + logOption = oo.LogSession; + } + fdManager.setFdName(fdName); fdManager.setFdDirPath(fdDirPath); + fdManager.setlogDirPath(logDirPath); fdManager.setFdNumber(fdNumber); fdManager.setFdFileHost(fdFileHost); fdManager.setLockServerHost(lockServerHost); @@ -125,4 +144,14 @@ public class ObjectivityStoreConfig extends Lifecycle implements IObjectivitySto { return sessionMaxCacheSize; } + + public String getLogPath() + { + return fdManager.getLogPath(); + } + + public int getLogOption() + { + return logOption; + } } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java index 6dfe8d53b2..12cb7d618d 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java @@ -30,7 +30,7 @@ public class ObjyPlacementManagerImpl implements ObjyPlacementManager private String genContName = "Cont"; /** - * TODO - For now we'll have a hard coded values... later we'll pick the pieces from the old design. + * Only used when we can't figure out a near object, so we'll end up putting the object in a default location. */ public ooId getNearObject(ObjyObject parent, EStructuralFeature feature, EClass newClassObject) { diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java index f32a624504..8051048df9 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java @@ -12,13 +12,13 @@ package org.eclipse.emf.cdo.server.internal.objectivity.clustering; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDTemp; +import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStore; import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM; import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject; import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope; import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession; import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil; -import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb; import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.emf.cdo.spi.server.InternalCommitContext; @@ -49,8 +49,6 @@ public class ObjyPlacementManagerLocal private String repositoryName = null; - private ObjyPlacementManager globalPlacementManager = null; - ObjySession objySession = null; InternalCommitContext commitContext = null; @@ -59,12 +57,12 @@ public class ObjyPlacementManagerLocal Map<CDOID, CDOID> idMapper; + Map<CDOID, ObjyObject> newObjyObjectsMap; + public ObjyPlacementManagerLocal(ObjectivityStore objyStore, ObjySession objySession, - InternalCommitContext commitContext) + InternalCommitContext commitContext, Map<CDOID, ObjyObject> newObjyObjectsMap) { repositoryName = objyStore.getRepository().getName(); - globalPlacementManager = objyStore.getGlobalPlacementManager(); - this.objySession = objySession; this.commitContext = commitContext; // first put them in a map for easy lookup and processing.... @@ -75,6 +73,8 @@ public class ObjyPlacementManagerLocal } idMapper = new HashMap<CDOID, CDOID>(); + + this.newObjyObjectsMap = newObjyObjectsMap; } public void processRevision(InternalCDORevision revision) @@ -89,7 +89,14 @@ public class ObjyPlacementManagerLocal // create the object and add it to mapping, this will recursively call // other object creation as needed, based on the default clustering of // having each object is stored with its container. - createObjectAndAddToMapping(revision); + try + { + createObjectAndAddToMapping(revision); + } + catch (com.objy.db.ObjyRuntimeException ex) + { + ex.printStackTrace(); + } } private ObjyObject createObjectAndAddToMapping(InternalCDORevision revision) @@ -106,6 +113,7 @@ public class ObjyPlacementManagerLocal commitContext.addIDMapping(revision.getID(), newID); // keep a track of this mapping. idMapper.put(revision.getID(), newID); + newObjyObjectsMap.put(newID, objyObject); return objyObject; } @@ -118,23 +126,26 @@ public class ObjyPlacementManagerLocal protected ObjyObject createObject(InternalCDORevision revision) { + long startTime = System.nanoTime(); ooId nearObject = null; EClass eClass = revision.getEClass(); if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.trace("Creating new object with " + revision + " " + eClass); + TRACER_DEBUG.trace("Creating new object for revision: " + revision + " - eClass: " + eClass); } if (revision.isResourceNode()) { + String resourceName = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0); // The resourcelist is in the ConfigDB, but each resource is in a resource // container in the repo database, except the first root (ID == resourceID). - if (revision.getID() == revision.getResourceID()) // Check with Eike! + // if (revision.getID() == revision.getResourceID()) // Check with Eike! + if (resourceName == null) // root. { nearObject = objySession.getResourceList(repositoryName).ooId(); } else { - ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.RESOURCELIST_CONT_NAME); + ObjyScope objyScope = new ObjyScope(repositoryName, resourceName /* ObjyDb.RESOURCELIST_CONT_NAME */); nearObject = objyScope.getScopeContOid(); } } @@ -147,7 +158,8 @@ public class ObjyPlacementManagerLocal { // we have to put it somewhere. // call the global placement manager. - nearObject = globalPlacementManager.getNearObject(null, null, revision.getEClass()); + nearObject = objySession.getObjectManager().getGlobalPlacementManager() + .getNearObject(null, null, revision.getEClass()); } ObjyObject objyObject = objySession.getObjectManager().newObject(eClass, nearObject); @@ -170,6 +182,8 @@ public class ObjyPlacementManagerLocal // SmartLock.lock(objyObject); // resourceList.add(objyObject); // } + ObjyObject.createObjectTime += System.nanoTime() - startTime; + ObjyObject.createObjectCount++; return objyObject; } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java index d5631a4fbc..03cd46bf74 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java @@ -16,6 +16,7 @@ import org.eclipse.net4j.util.io.TMPUtil; import org.eclipse.net4j.util.om.trace.ContextTracer; import com.objy.db.app.Session; +import com.objy.db.app.oo; import com.objy.db.app.ooContObj; import com.objy.db.app.ooDBObj; @@ -49,7 +50,7 @@ public class FdManager private String fdDirPath = null; - private String lockserverHost = DEFAULT_VALUE; + private String lockServerHost = DEFAULT_VALUE; private String fdNumber = "12345"; @@ -61,13 +62,21 @@ public class FdManager private boolean initialized = false; - public void initialize(boolean reset) + private String configPath = "configuration"; + + private String logDirPath = null; + + protected void initialize(boolean reset) { if (fdDirPath == null) { File dataFolder = TMPUtil.createTempFolder("Objy", "data"); fdDirPath = dataFolder.getAbsolutePath(); } + if (noDefaultValueSet(logDirPath)) + { + logDirPath = fdDirPath; + } if (fdFilePath == null) { fdFilePath = fdDirPath + File.separator + fdName + ".fdb"; @@ -129,20 +138,23 @@ public class FdManager boolean bRet = false; Process proc = null; - String command = "oonewfd" - // + " -fdfilehost " + getFdFileHost() - + " -fdfilepath " + fdFilePath + " -lockserver " + getLockServerHost() + " -fdnumber " + fdNumber - + " -pagesize " + getPageSize() - // + " -jnldirpath " + jrnlDirPath - // + " -licensefile " + licenseFilePath - // + ((standAlone)?" -standalone ":" ") - + " " + bootFilePath; + StringBuilder command = new StringBuilder(256); + command.append("oonewfd"); + // command.append(" -fdfilehost ").append(getFdFileHost()); + command.append(" -fdfilepath ").append(fdFilePath); + command.append(" -lockserver ").append(getLockServerHost()); + command.append(" -fdnumber ").append(fdNumber); + command.append(" -pagesize ").append(getPageSize()); + // command.append(" -jnldirpath ").append(jrnlDirPath); + // command.append(" -licensefile ").append(licenseFilePath); + // if (standAlone) command.append(" -standalone "); + command.append(' ').append(bootFilePath); TRACER_INFO.trace("Createing FD: '" + bootFilePath + "'."); try { - proc = Runtime.getRuntime().exec(command); + proc = Runtime.getRuntime().exec(command.toString()); if (proc.waitFor() != 0) { dumpStream(proc.getErrorStream()); @@ -359,7 +371,7 @@ public class FdManager public String getFdFileHost() { - if (fdFileHost.equals(DEFAULT_VALUE)) + if (noDefaultValueSet(fdFileHost)) { // get local host try @@ -394,13 +406,13 @@ public class FdManager public String getLockServerHost() { - if (lockserverHost.equals(DEFAULT_VALUE)) + if (noDefaultValueSet(lockServerHost)) { // get local host try { InetAddress address = InetAddress.getLocalHost(); - lockserverHost = address.getHostName(); + lockServerHost = address.getHostName(); } catch (UnknownHostException e) { @@ -409,12 +421,12 @@ public class FdManager } } - return lockserverHost; + return lockServerHost; } public void setLockServerHost(String lockServerHost) { - lockserverHost = lockServerHost; + this.lockServerHost = lockServerHost; } public String getFdNumber() @@ -429,7 +441,7 @@ public class FdManager public String getPageSize() { - if (pageSize.equals(DEFAULT_VALUE)) + if (noDefaultValueSet(pageSize)) { pageSize = "8192"; } @@ -509,6 +521,7 @@ public class FdManager // ObjyConnection.INSTANCE.disconnect(); // fdManager.resetFD(); Session session = new Session(); + session.setIndexMode(oo.EXPLICIT_UPDATE); session.begin(); Iterator<?> itr = session.getFD().containedDBs(); ooDBObj dbObj = null; @@ -541,4 +554,20 @@ public class FdManager session.commit(); session.terminate(); } + + boolean noDefaultValueSet(String value) + { + return value == null || value.isEmpty() || value.equals(DEFAULT_VALUE); + } + + public void setlogDirPath(String logDirPath) + { + this.logDirPath = logDirPath; + } + + public String getLogPath() + { + return logDirPath; + } + } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java index d66a169283..5a7456f44a 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java @@ -10,11 +10,20 @@ */ package org.eclipse.emf.cdo.server.internal.objectivity.db; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListId; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListString; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapArrayList; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy; + import com.objy.as.app.Class_Position; import com.objy.as.app.d_Attribute; import com.objy.as.app.d_Class; +import com.objy.as.app.d_Ref_Type; +import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; /** * Wrapper around the AS class to be able to cache attributes. @@ -35,7 +44,14 @@ public class ObjyClass public ObjyClass(d_Class asClass/* , EClass eClass */) { this.asClass = asClass; - asClassName = asClass.name(); + if (asClass.namespace_name() != null) + { + asClassName = asClass.namespace_name() + ":" + asClass.name(); + } + else + { + asClassName = asClass.name(); + } } public d_Attribute resolve_attribute(String attribute_name) @@ -44,6 +60,16 @@ public class ObjyClass if (attr == null) { attr = asClass.resolve_attribute(attribute_name); + // we might get (attr == null) if the attribute is from a base class. + // so we'll try to get the attribute through the position. + if (attr == null) + { + Class_Position position = resolve_position(attribute_name); + if (position != null) + { + attr = asClass.attribute_at_position(position); + } + } attributeMap.put(attribute_name, attr); } return attr; @@ -70,4 +96,49 @@ public class ObjyClass return asClassName; } + public List<Class_Position> getListOfRefAttributes() + { + List<Class_Position> positions = new ArrayList<Class_Position>(); + + System.out.println(">>> Class: " + asClassName); + + // + @SuppressWarnings("rawtypes") + Iterator itr = asClass.attributes_plus_inherited(); + while (itr.hasNext()) + { + d_Attribute attribute = (d_Attribute)itr.next(); + if (attribute.is_type() && attribute.type_of() instanceof d_Ref_Type) + { + d_Class dClass = attribute.class_type_of(); + if (dClass.name().equals(ObjyFeatureMapArrayList.ClassName)) + { + // we'll need to copy this one. + positions.add(resolve_position(attribute.name())); + System.out.println("\t attr: " + attribute.name()); + } + else if (dClass.name().equals(ObjyArrayListString.ClassName)) + { + // we'll need to copy this one. + positions.add(resolve_position(attribute.name())); + System.out.println("\t attr: " + attribute.name()); + } + else if (dClass.name().equals(ObjyArrayListId.className)) + { + // we'll need to copy this one. + positions.add(resolve_position(attribute.name())); + System.out.println("\t attr: " + attribute.name()); + } + else if (dClass.name().equals(ObjyProxy.className)) + { + // we'll need to copy this one. + positions.add(resolve_position(attribute.name())); + System.out.println("\t attr: " + attribute.name()); + } + } + } + + return positions; + } + } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java index a117e5e43a..920c17a2fd 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java @@ -131,7 +131,10 @@ public class ObjyClassProposed } } - TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " -- DONE"); + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " -- DONE"); + } for (EClass classifier : toBeProcessed) { @@ -221,7 +224,7 @@ public class ObjyClassProposed } } - TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " -- DONE"); + TRACER_DEBUG.trace("evolve ECLASS " + eClass.getName() + " -> " + className + " -- DONE"); for (EClass classifier : toBeEvolve) { diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java index 4159e81ab3..346b497d79 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java @@ -104,7 +104,7 @@ public class ObjyCommitInfoHandler protected ooTreeSetX getTreeSet() { ooTreeSetX treeSet = null; - treeSet = (ooTreeSetX)Session.getCurrent().getFD().objectFrom(commitInfoSetId); + treeSet = (ooTreeSetX)Session.getCurrent().getFD().objectFrom(commitInfoSetId.getString()); return treeSet; } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java index d891005d95..d2928eb237 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java @@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.server.internal.objectivity.db; import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM; import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManager; import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManagerImpl; +import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreConfig; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -65,10 +66,18 @@ public class ObjyConnection private int sessionMaxCacheSize = 1000; + private final int minInactiveSessions = 5; + + private int sessionCount = 0; + + private String logDirPath = null; + + private int logOption = oo.LogNone; + public ObjyConnection() { - readPool = new ConcurrentHashMap<String, ObjySession>(20); - writePool = new ConcurrentHashMap<String, ObjySession>(20); + readPool = new ConcurrentHashMap<String, ObjySession>(5); + writePool = new ConcurrentHashMap<String, ObjySession>(5); } /*** @@ -76,12 +85,25 @@ public class ObjyConnection * * @param fdName */ - synchronized public void connect(String fdName) + synchronized public void connect(IObjectivityStoreConfig storeConfig) + { + /**** + * If + */ + fdName = storeConfig.getFdName(); + logDirPath = storeConfig.getLogPath(); + logOption = storeConfig.getLogOption(); + connect(); + // this.store = store; + } + + synchronized public void connect(String fdName, int logOption) { /**** * If */ this.fdName = fdName; + this.logOption = logOption; connect(); // this.store = store; } @@ -101,19 +123,20 @@ public class ObjyConnection { if (Connection.current() == null) { - int options = oo.LogNone; // oo.LogAll; - Connection.setLoggingOptions(options, true, // boolean logToFiles - true, // boolean appendLogFiles, - "c:\\data", // String logDirPath, - "MainLog.txt"// String mainLogFileName - ); + if (logOption != oo.LogNone) + { + Connection.setLoggingOptions(logOption, true, // boolean logToFiles + true, // boolean appendLogFiles, + logDirPath, // String logDirPath, + "MainLog.txt"// String mainLogFileName + ); + } if (TRACER_DEBUG.isEnabled()) { TRACER_DEBUG.trace(" creating new Connection"); } connection = Connection.open(fdName, oo.openReadWrite); connection.useContextClassLoader(true); - } else { @@ -147,45 +170,51 @@ public class ObjyConnection public ObjySession getWriteSessionFromPool(String sessionName) { - synchronized (syncObject) - { - // return connection.getSessionFromPool(getSessionPoolNameWrite(), sessionName); - ObjySession session = writePool.get(sessionName); - if (session == null) - { - session = new ObjySession(sessionName, writePool, this); - writePool.put(sessionName, session); - } - session.join(); - return session; - } + return getSessionFromPool(sessionName); } public ObjySession getReadSessionFromPool(String sessionName) { + return getSessionFromPool(sessionName); + } + + protected ObjySession getSessionFromPool(String sessionName) + { synchronized (syncObject) { - // return connection.getSessionFromPool(getSessionPoolNameRead(), sessionName); + // return connection.getSessionFromPool(getSessionPoolNameWrite(), sessionName); ObjySession session = readPool.get(sessionName); if (session == null) { - session = new ObjySession(sessionName, writePool, this); - readPool.put(sessionName, session); + if (sessionCount >= minInactiveSessions) + { + // look for an inactive one, rename it and use it. + for (ObjySession objySession : readPool.values()) + { + if (objySession.isAvailable()) + { + objySession.setName(sessionName); + session = objySession; + break; + } + } + } + + // we are forced to create one. + if (session == null) + { + session = new ObjySession(sessionName, readPool, this); + ++sessionCount; + // System.out.println(">>> IS: creating new session: " + sessionName + " - total: " + sessionCount); + readPool.put(sessionName, session); + } } session.join(); + session.setAvailable(false); return session; } } - public void returnSessionToPool(ObjySession session) - { - synchronized (syncObject) - { - // TODO Auto-generated method stub - session.leave(); - } - } - public void disconnect() { if (!isConnected) @@ -213,6 +242,8 @@ public class ObjyConnection // TRACER_DEBUG.trace("ObjyConnection.disconnect() -- cleanup writePool. "); cleanupSessionPool(writePool); + sessionCount = 0; + // TRACER_DEBUG.trace("ObjyConnection.disconnect() -- cleanup any other sessions. "); // for testing we need to find out if there are any open sessions. diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java index 5830678688..77d8857684 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java @@ -11,6 +11,7 @@ package org.eclipse.emf.cdo.server.internal.objectivity.db; import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDExternal; import org.eclipse.emf.cdo.common.model.EMFUtil; @@ -24,7 +25,10 @@ import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ISingleTypeMapper; import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper; import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper; import org.eclipse.emf.cdo.server.internal.objectivity.mapper.SingleReferenceMapper; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListId; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListString; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapArrayList; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapEntry; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy; import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil; @@ -41,12 +45,13 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.util.FeatureMap; import com.objy.as.app.Class_Object; -import com.objy.as.app.Class_Position; import com.objy.as.app.Numeric_Value; import com.objy.as.app.Relationship_Object; import com.objy.as.app.String_Value; import com.objy.as.app.VArray_Object; -import com.objy.db.app.Session; +import com.objy.as.app.d_Attribute; +import com.objy.as.app.d_Class; +import com.objy.as.app.d_Ref_Type; import com.objy.db.app.ooId; import com.objy.db.app.ooObj; @@ -56,6 +61,9 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +/** + * @author Ibrahim Sallam + */ public class ObjyObject { @@ -69,42 +77,117 @@ public class ObjyObject protected Relationship_Object baseRel = null; + protected boolean hasBaseRelationshipChecked = false; + protected Relationship_Object revisionsRel = null; protected Relationship_Object lastRevisionRel = null; protected ooId objectId; + protected ooId revisionId = null; + + protected int version = Integer.MAX_VALUE; + + public static int fetchCount = 0; + + public static int updateCount = 0; + + public static long createObjectTime = 0; + + public static int createObjectCount = 0; + // protected boolean isRoot = false; + // IS: for stats. + // public static int count = 0; + // public static long tDiff = 0; + // good for fast access. - private Map<Class_Position, Object> featureMap = new HashMap<Class_Position, Object>(); + // private Map<Class_Position, Object> featureMap = new HashMap<Class_Position, Object>(); + private Map<String, Object> featureMap = new HashMap<String, Object>(); public ObjyObject(Class_Object classObject) { + // long tStart = System.currentTimeMillis(); + this.classObject = classObject; - objyClass = ObjySchema.getObjyClass(classObject.type_of().name()); + d_Class dClass = classObject.type_of(); + String fullyQualifiedClassName = null; - if (TRACER_DEBUG.isEnabled()) + try { - TRACER_DEBUG.format("...classObject type: {0} - oid: {1}", classObject.type_of().name(), classObject.objectID() - .getStoreString()); + + if (dClass.namespace_name() != null) + { + fullyQualifiedClassName = dClass.namespace_name() + ":" + dClass.name(); + } + else + { + fullyQualifiedClassName = dClass.name(); + } + + objyClass = ObjySchema.getObjyClass(fullyQualifiedClassName); + + // if (dClass.has_base_class(ObjyBase.CLASS_NAME)) + // { + // if (TRACER_DEBUG.isEnabled()) + // { + // TRACER_DEBUG.format("...classObject type: {0} - oid: {1}", classObject.type_of().name(), classObject + // .objectID().getStoreString()); + // } + // getBaseRelationship(classObject); + // if (!baseRel.exists()) + // { + // // we are the base... + // getRevisionsRelationship(classObject); + // getLastRevisionRelationship(classObject); + // } + // else + // { + // baseClassObject = baseRel.get_class_obj(); + // // TODO - we might want to delay getting the list of versions unless we need them. + // // revisionsRel = baseClassObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_REVISIONS)); + // // lastRevisionRel = baseClassObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_LAST_REVISION)); + // } + // } + setObjectId(classObject.objectID()); + version = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_VERSION)).intValue(); } - baseRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_BASE)); - if (!baseRel.exists()) + catch (RuntimeException ex) + { + ex.printStackTrace(); + } + + // count++; + // tDiff += System.currentTimeMillis() - tStart; + } + + private Relationship_Object getLastRevisionRelationship() + { + if (lastRevisionRel == null) { - // we are the base... - revisionsRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_REVISIONS)); lastRevisionRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_LAST_REVISION)); } - else + return lastRevisionRel; + } + + private Relationship_Object getRevisionsRelationship() + { + if (revisionsRel == null) + { + revisionsRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_REVISIONS)); + } + return revisionsRel; + } + + private Relationship_Object getBaseRelationship() + { + if (baseRel == null) { - baseClassObject = baseRel.get_class_obj(); - // TODO - we might want to delay getting the list of versions unless we need them. - // revisionsRel = baseClassObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_REVISIONS)); - // lastRevisionRel = baseClassObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_LAST_REVISION)); + baseRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_BASE)); } - setObjectId(classObject.objectID()); + return baseRel; } public ObjyClass objyClass() @@ -141,8 +224,9 @@ public class ObjyObject checkSession(); } - Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID); - SingleReferenceMapper.INSTANCE.setValue(this, position, containerID); + // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID); + + SingleReferenceMapper.INSTANCE.setValue(this, ObjyBase.ATT_CONTAINERID/* position */, containerID); } public Object getEContainer() @@ -152,8 +236,8 @@ public class ObjyObject checkSession(); } - Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID); - Object value = SingleReferenceMapper.INSTANCE.getValue(this, position); + // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID); + Object value = SingleReferenceMapper.INSTANCE.getValue(this, ObjyBase.ATT_CONTAINERID/* position */); return value; } @@ -165,8 +249,8 @@ public class ObjyObject checkSession(); } - Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID); - ooId childOid = get_ooId(position); + // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID); + ooId childOid = get_ooId(ObjyBase.ATT_CONTAINERID/* position */); return childOid; } @@ -177,8 +261,8 @@ public class ObjyObject checkSession(); } - Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID); - SingleReferenceMapper.INSTANCE.setValue(this, position, resourceID); + // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID); + SingleReferenceMapper.INSTANCE.setValue(this, ObjyBase.ATT_RESOURCEID/* position */, resourceID); } @@ -189,8 +273,8 @@ public class ObjyObject checkSession(); } - Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID); - Object value = SingleReferenceMapper.INSTANCE.getValue(this, position); + // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID); + Object value = SingleReferenceMapper.INSTANCE.getValue(this, ObjyBase.ATT_RESOURCEID/* position */); return value; } @@ -201,8 +285,8 @@ public class ObjyObject { checkSession(); } - Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID); - ooId childOid = get_ooId(position); + // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID); + ooId childOid = get_ooId(ObjyBase.ATT_RESOURCEID/* position */); return childOid; } @@ -212,8 +296,8 @@ public class ObjyObject { checkSession(); } - Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINER_FEATUERID); - set_numeric(position, new Numeric_Value(contFeature)); + // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINER_FEATUERID); + set_numeric(ObjyBase.ATT_CONTAINER_FEATUERID/* position */, new Numeric_Value(contFeature)); } public int getEContainingFeature() @@ -222,22 +306,30 @@ public class ObjyObject { checkSession(); } - Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINER_FEATUERID); - return get_numeric(position).intValue(); + // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINER_FEATUERID); + return get_numeric(ObjyBase.ATT_CONTAINER_FEATUERID/* position */).intValue(); } /** * This is used to cache the composite features, (manyAttributes, manyReference, and featureMap. TBD - verify the need * of this. */ - public Object getFeatureList(Class_Position position) + // public Object getFeatureList(Class_Position position) + // { + // return featureMap.get(position); + // } + public Object getFeatureList(String featureName) { - return featureMap.get(position); + return featureMap.get(featureName); } - public void setFeatureList(Class_Position position, Object object) + // public void setFeatureList(Class_Position position, Object object) + // { + // featureMap.put(position, object); + // } + public void setFeatureList(String featureName, Object object) { - featureMap.put(position, object); + featureMap.put(featureName, object); } public int getVersion() @@ -246,7 +338,10 @@ public class ObjyObject { checkSession(); } - int version = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_VERSION)).intValue(); + if (version == Integer.MAX_VALUE) + { + version = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_VERSION)).intValue(); + } return version; } @@ -257,7 +352,8 @@ public class ObjyObject checkSession(); } classObject.set_numeric(objyClass.resolve_position(ObjyBase.ATT_VERSION), new Numeric_Value(version)); - getVersion(); // TBD, verify the need for this call!!!! + // getVersion(); // TBD, verify the need for this call!!!! + this.version = version; } public long getCreationTime() @@ -281,56 +377,90 @@ public class ObjyObject public long getRevisedTime() { - if (TRACER_DEBUG.isEnabled()) + long revisedTime = 0; + + try { - checkSession(); + if (TRACER_DEBUG.isEnabled()) + { + checkSession(); + } + revisedTime = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_REVISED_TIME)).longValue(); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); } - long revisedTime = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_REVISED_TIME)).longValue(); + return revisedTime; } public void setRevisedTime(long revisedTime) { - if (TRACER_DEBUG.isEnabled()) + try { - checkSession(); + if (TRACER_DEBUG.isEnabled()) + { + checkSession(); + } + classObject.set_numeric(objyClass.resolve_position(ObjyBase.ATT_REVISED_TIME), new Numeric_Value(revisedTime)); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); } - classObject.set_numeric(objyClass.resolve_position(ObjyBase.ATT_REVISED_TIME), new Numeric_Value(revisedTime)); } public void setBranchId(int branchId) { - if (TRACER_DEBUG.isEnabled()) + try { - checkSession(); + if (TRACER_DEBUG.isEnabled()) + { + checkSession(); + } + classObject.set_numeric(objyClass.resolve_position(ObjyBase.ATT_BRANCHID), new Numeric_Value(branchId)); } - classObject.set_numeric(objyClass.resolve_position(ObjyBase.ATT_BRANCHID), new Numeric_Value(branchId)); + catch (RuntimeException ex) + { + ex.printStackTrace(); + } + } public long getBranchId() { - if (TRACER_DEBUG.isEnabled()) + int branchId = 0; + try { - checkSession(); + if (TRACER_DEBUG.isEnabled()) + { + checkSession(); + } + branchId = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_BRANCHID)).intValue(); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); } - int branchId = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_BRANCHID)).intValue(); return branchId; } - public ObjyObject copy(EClass eClass) + public ObjyObject copy(EClass eClass, ObjyObjectManager objyObjectManager) { ObjyObject newObjyObject = null; ooObj obj = ooObj.create_ooObj(objectId); ooObj newObj = (ooObj)obj.copy(obj); // Objy internal copy. // Dependent structures, for example array of refs are not copies, so we // have to iterate and copy (deep copy). - newObjyObject = new ObjyObject(Class_Object.class_object_from_oid(newObj.getOid())); + // newObjyObject = new ObjyObject(Class_Object.class_object_from_oid(newObj.getOid())); + newObjyObject = objyObjectManager.getObject(newObj.getOid()); try { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.trace("=> ObjyObject.copy() - oid:" + ooId().getStoreString() + " version:" + getVersion()); + TRACER_DEBUG.trace("ObjyObject.copy() - oid:" + ooId().getStoreString() + " version:" + getVersion()); } for (EStructuralFeature feature : eClass.getEAllStructuralFeatures()) { @@ -342,6 +472,47 @@ public class ObjyObject if (feature.isMany()) { // copy this feature to the new object. + // copy this feature to the new object. + // get the attribute using feature name. + d_Attribute attribute = objyClass.resolve_attribute(feature.getName()); + // System.out.println("... checking feature: " + feature.getName() + - attributeType: " + // + attribute.type_of().name()); + if (attribute != null && attribute.type_of() instanceof d_Ref_Type) + { + // IS:temptest Class_Position position = objyClass.resolve_position(feature.getName()); + // ooId refOoId = get_ooId(position); + Class_Object cObj = get_class_obj(feature.getName()); + if (cObj != null) + { + // System.out.println("\t\t referenced Class_Object with OID: " +cObj.objectID().getStoreString()); + d_Class refClass = cObj.type_of(); + String refClassName = refClass.name(); + if (refClassName.equals(ObjyFeatureMapArrayList.ClassName)) + { + // we'll need to copy this one. + TRACER_DEBUG.trace("\t TBD - copying ObjyFeatureMapArrayList attr: " + attribute.name()); + } + else if (refClassName.equals(ObjyArrayListString.ClassName)) + { + // we'll need to copy this one. + TRACER_DEBUG.trace("\t TBD - copying ObjyArrayListString attr: " + attribute.name()); + } + else if (refClassName.equals(ObjyArrayListId.className)) + { + // we'll need to copy this one. + // System.out.println("\t copying ObjyArrayListId attr: " + attibute.name()); + ObjyArrayListId arrayListId = new ObjyArrayListId(cObj); + ooObj newArrayListId = arrayListId.copy(newObj); + newObjyObject.set_ooId(feature.getName(), newArrayListId.getOid()); + } + else if (refClassName.equals(ObjyProxy.className)) + { + // we'll need to copy this one. + TRACER_DEBUG.trace("\t TBD - copying ObjyProxy attr: " + attribute.name()); + } + } + } + } } } @@ -361,13 +532,15 @@ public class ObjyObject */ public void update(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision) { + updateCount++; + try { if (TRACER_DEBUG.isEnabled()) { checkSession(); - TRACER_DEBUG.trace("=> ObjyObject.update() - oid:" + ooId().getStoreString() + " - version:" + TRACER_DEBUG.trace("ObjyObject.update() - oid:" + ooId().getStoreString() + " - version:" + revision.getVersion()); } @@ -445,8 +618,14 @@ public class ObjyObject { // TODO - this code need refactoring... Object value = list.get(i); - if (value instanceof CDOIDExternal) + if (null == value) + { + values[i] = value; + continue; + } + else if (value instanceof CDOIDExternal) { + TRACER_DEBUG.trace("... CDOIDExternal inserted, at:" + i + ", content:" + ((CDOIDExternal)value).getURI()); // System.out.println("value is a proxy object - it should be handled by the mapper."); // create an ObjyProxy object to hold the the value. ObjyProxy proxyObject = ObjyProxy.createObject(ooId()); @@ -456,7 +635,7 @@ public class ObjyObject } else if (value instanceof CDOID) { - values[i] = OBJYCDOIDUtil.getooId((CDOID)list.get(i)); + values[i] = OBJYCDOIDUtil.getooId((CDOID)value); } else if (value instanceof FeatureMap.Entry) { @@ -467,6 +646,8 @@ public class ObjyObject ooId oid = null; if (entryValue instanceof CDOIDExternal) { + TRACER_DEBUG.trace("... CDOIDExternal inserted, at:" + i + ", content:" + + ((CDOIDExternal)entryValue).getURI()); // System.out.println("value is a proxy object - it should be handled by the mapper."); // create an ObjyProxy object to hold the the value. ObjyProxy proxyObject = ObjyProxy.createObject(ooId()); @@ -484,24 +665,26 @@ public class ObjyObject TRACER_DEBUG.trace("OBJY: don't know what kind of entryValue is this!!! - " + entryValue); } } - // FeatureMapEntry is a presistent class. ObjyFeatureMapEntry featureMapEntry = new ObjyFeatureMapEntry(entryFeature.getFeatureID(), oid, objectId); // this.cluster(featureMapEntry); values[i] = featureMapEntry; } + else if (value.equals(InternalCDOList.UNINITIALIZED)) + { + TRACER_DEBUG.format("...GOT UNINITIALIZED at {0}, listSize:{1}, feature:{2}, oid:{3}", i, values.length, + feature.getName(), objectId.getStoreString()); + continue; + } else { // different feature then. - // System.out.println("-->> Hmmm feature (" + i + ") -> feature:" + feature.getName() + " - value:" + - // value); values[i] = value; } } ((IManyTypeMapper)mapper).setAll(this, feature, 0, values); - // ((IManyTypeMapper)mapper).addAll(this, feature, values); } else { @@ -520,37 +703,56 @@ public class ObjyObject } } - public ObjyObject getLastRevision() + public ObjyObject getLastRevision(ObjyObjectManager objyObjectManager) { - if (!lastRevisionRel.exists()) + if (!getLastRevisionRelationship().exists()) { return this; } - Class_Object lastRevision = lastRevisionRel.get_class_obj(); - return new ObjyObject(lastRevision); + // Class_Object lastRevision = lastRevisionRel.get_class_obj(); + ooId lastRevisionOid = getLastRevisionRelationship().get_ooId(); + // return new ObjyObject(lastRevision); + return objyObjectManager.getObject(lastRevisionOid); } - public ObjyObject getRevisionByVersion(int version) + public ObjyObject getRevisionByVersion(int version, long branchId, ObjyObjectManager objyObjectManager) { ObjyObject objyRevision = null; - if (Math.abs(getVersion()) == version) + int objectVersion = getVersion(); + long objectBranchId = getBranchId(); + + if (branchId == objectBranchId && Math.abs(objectVersion) == version) { // there is a first time for everything... return this; } - Session.getCurrent().setReturn_Class_Object(true); + + // check last revision first. + objyRevision = getLastRevision(objyObjectManager); + objectVersion = objyRevision.getVersion(); + objectBranchId = objyRevision.getBranchId(); + if (branchId == objectBranchId && Math.abs(objectVersion) == version) + { + return objyRevision; + } + + // Session.getCurrent().setReturn_Class_Object(true); // int numRevisions = (int) revisions.size(); @SuppressWarnings("unchecked") - Iterator<Class_Object> itr = revisionsRel.get_iterator(); + Iterator<ooObj> itr = getRevisionsRelationship().get_iterator(); while (itr.hasNext()) { - objyRevision = new ObjyObject(itr.next()); - if (Math.abs(objyRevision.getVersion()) == version) + // objyRevision = new ObjyObject(itr.next()); + objyRevision = objyObjectManager.getObject(itr.next().getOid()); + objectVersion = objyRevision.getVersion(); + objectBranchId = objyRevision.getBranchId(); + if (branchId == objectBranchId && Math.abs(objectVersion) == version) { return objyRevision; } + objyRevision = null; } return null; @@ -558,10 +760,17 @@ public class ObjyObject public void addToRevisions(ObjyObject objyRevision) { - revisionsRel.add(objyRevision.objectId); - // set it as last rev. - lastRevisionRel.clear(); // Ouch!! performance issue... - lastRevisionRel.form(objyRevision.objectId); + try + { + getRevisionsRelationship().add(objyRevision.objectId); + // set it as last rev. + getLastRevisionRelationship().clear(); // Ouch!! performance issue... + getLastRevisionRelationship().form(objyRevision.objectId); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } } // /** @@ -586,6 +795,7 @@ public class ObjyObject public boolean fetch(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision, int listChunk) { boolean bRet = true; + fetchCount++; if (TRACER_DEBUG.isEnabled()) { checkSession(); @@ -596,7 +806,7 @@ public class ObjyObject { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.trace("=> ObjyObject.fetch() - oid:" + ooId().getStoreString() + " version:" + getVersion()); + TRACER_DEBUG.trace("ObjyObject.fetch() - oid:" + ooId().getStoreString() + " version:" + getVersion()); } // Put the version of the objects; revision.setVersion(getVersion()); @@ -625,7 +835,7 @@ public class ObjyObject { int featureSize = size(feature); int chunkSize = featureSize; - if (listChunk != CDORevision.UNCHUNKED) + if (listChunk != CDORevision.UNCHUNKED && listChunk > 0) { chunkSize = Math.min(chunkSize, listChunk); } @@ -649,46 +859,38 @@ public class ObjyObject if (objects[i] instanceof ooId) { // TODO - this code need refactoring.... - - Class_Object refClassObject = Class_Object.class_object_from_oid((ooId)objects[i]); - - if (refClassObject.type_of().name().equals(ObjyProxy.className)) + CDOID cdoId = null; + ooId objyOid = (ooId)objects[i]; + if (objyOid.isNull()) { - // System.out.println("OBJY: Got proxy: " + refClassObject.objectID().getStoreString()); - ObjyProxy proxyObject = new ObjyProxy(refClassObject); - // cdoList.set(i, - // OBJYCDOIDUtil.createCDIDExternal(proxyObject)); - list.add(OBJYCDOIDUtil.createCDIDExternal(proxyObject)); + cdoId = OBJYCDOIDUtil.getCDOID(objyOid); } else { - CDOID childID = OBJYCDOIDUtil.getCDOID((ooId)objects[i]); - // cdoList.set(i, childID); - list.add(childID); + Class_Object refClassObject = Class_Object.class_object_from_oid((ooId)objects[i]); + + if (refClassObject.type_of().name().equals(ObjyProxy.className)) + { + // System.out.println("OBJY: Got proxy: " + refClassObject.objectID().getStoreString()); + ObjyProxy proxyObject = new ObjyProxy(refClassObject); + // cdoList.set(i, + // OBJYCDOIDUtil.createCDIDExternal(proxyObject)); + cdoId = OBJYCDOIDUtil.createCDIDExternal(proxyObject); + } + else + { + cdoId = OBJYCDOIDUtil.getCDOID(objyOid); + } + refClassObject = null; } - refClassObject = null; + list.add(cdoId); + + continue; } else if (objects[i] instanceof ObjyFeatureMapEntry) { - ObjyFeatureMapEntry mapEntry = (ObjyFeatureMapEntry)objects[i]; - ooId oid = mapEntry.getObject(); - CDOID id = null; - Class_Object refClassObject = Class_Object.class_object_from_oid(oid); - if (refClassObject.type_of().name().equals(ObjyProxy.className)) - { - // System.out.println("OBJY: Got proxy: " + refClassObject.objectID().getStoreString()); - ObjyProxy proxyObject = new ObjyProxy(refClassObject); - id = OBJYCDOIDUtil.createCDIDExternal(proxyObject); - } - else - { - id = OBJYCDOIDUtil.getCDOID(oid); - } - - EStructuralFeature entryFeature = eClass.getEStructuralFeature(mapEntry.getTagId()); - FeatureMap.Entry entry = CDORevisionUtil.createFeatureMapEntry(entryFeature, id); + FeatureMap.Entry entry = getFeatureMapEntry(eClass, (ObjyFeatureMapEntry)objects[i]); list.add(entry); - refClassObject = null; } else { @@ -733,9 +935,11 @@ public class ObjyObject * Fetch data for a specific feature from the store, and return a list of objects. Used by * ObjectivityStoreChunkAccessor */ - public Object[] fetch(ObjectivityStoreAccessor storeAccessor, EStructuralFeature feature, int startIndex, + public List<Object> fetchList(ObjectivityStoreAccessor storeAccessor, EStructuralFeature feature, int startIndex, int chunkSize) { + fetchCount++; + List<Object> results = new ArrayList<Object>(); EClass eClass = feature.getEContainingClass(); @@ -748,65 +952,91 @@ public class ObjyObject { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.trace("=> ObjyObject.fetch() - feature:" + feature.getName() + "from Object: " + TRACER_DEBUG.trace("ObjyObject.fetch() - feature:" + feature.getName() + "from Object: " + ooId().getStoreString() + " version:" + getVersion()); } int featureSize = size(feature); chunkSize = Math.min(featureSize - startIndex, chunkSize); Object[] objects = getAll(feature, startIndex, chunkSize); - // if (size > 0) - { - for (int i = 0; i < chunkSize; i++) - { - if (objects[i] instanceof ooId) - { - // TODO - this code need refactoring.... + convertToCdoList(objects, results, eClass, chunkSize); + } + catch (com.objy.as.asException ex) + { + ex.printStackTrace(); + } - // System.out.println("-->> IS: getting Class_Object from OID: " - // + childObject.getStoreString()); - Class_Object refClassObject = Class_Object.class_object_from_oid((ooId)objects[i]); + return results; + } - if (refClassObject.type_of().name().equals(ObjyProxy.className)) - { - ObjyProxy proxyObject = new ObjyProxy(refClassObject); + /** + * Function thats takes a list of Objy objects and convert them to CDO IDs This function is used by queryXRefs() as + * well. + */ + protected void convertToCdoList(Object[] objects, List<Object> results, EClass eClass, int chunkSize) + { + { + for (int i = 0; i < chunkSize; i++) + { + if (objects[i] instanceof ooId) + { + // TODO - this code need refactoring.... - results.add(OBJYCDOIDUtil.createCDIDExternal(proxyObject)); - } - else - { - results.add(OBJYCDOIDUtil.getCDOID((ooId)objects[i])); - } + // System.out.println("-->> IS: getting Class_Object from OID: " + // + childObject.getStoreString()); + CDOID cdoId = null; + ooId objyOid = (ooId)objects[i]; + if (objyOid.isNull()) + { + cdoId = OBJYCDOIDUtil.getCDOID(objyOid); } - else if (objects[i] instanceof ObjyFeatureMapEntry) + else { - ObjyFeatureMapEntry mapEntry = (ObjyFeatureMapEntry)objects[i]; - ooId oid = mapEntry.getObject(); - CDOID id = null; - Class_Object refClassObject = Class_Object.class_object_from_oid(oid); + Class_Object refClassObject = Class_Object.class_object_from_oid(objyOid); + if (refClassObject.type_of().name().equals(ObjyProxy.className)) { ObjyProxy proxyObject = new ObjyProxy(refClassObject); - id = OBJYCDOIDUtil.createCDIDExternal(proxyObject); + cdoId = OBJYCDOIDUtil.createCDIDExternal(proxyObject); } else { - id = OBJYCDOIDUtil.getCDOID(oid); + cdoId = OBJYCDOIDUtil.getCDOID(objyOid); } - - EStructuralFeature entryFeature = eClass.getEStructuralFeature(mapEntry.getTagId()); - FeatureMap.Entry entry = CDORevisionUtil.createFeatureMapEntry(entryFeature, id); - results.add(entry); + refClassObject = null; } + + results.add(cdoId); + continue; + + } + else if (objects[i] instanceof ObjyFeatureMapEntry) + { + FeatureMap.Entry entry = getFeatureMapEntry(eClass, (ObjyFeatureMapEntry)objects[i]); + results.add(entry); } } } - catch (com.objy.as.asException ex) + } + + private FeatureMap.Entry getFeatureMapEntry(EClass eClass, ObjyFeatureMapEntry mapEntry) + { + ooId oid = mapEntry.getObject(); + CDOID id = null; + Class_Object refClassObject = Class_Object.class_object_from_oid(oid); + if (refClassObject.type_of().name().equals(ObjyProxy.className)) { - ex.printStackTrace(); + ObjyProxy proxyObject = new ObjyProxy(refClassObject); + id = OBJYCDOIDUtil.createCDIDExternal(proxyObject); + } + else + { + id = OBJYCDOIDUtil.getCDOID(oid); } - return results.toArray(); + EStructuralFeature entryFeature = eClass.getEStructuralFeature(mapEntry.getTagId()); + FeatureMap.Entry entry = CDORevisionUtil.createFeatureMapEntry(entryFeature, id); + return entry; } /** @@ -821,18 +1051,25 @@ public class ObjyObject { checkSession(); } + int size = 0; // Class_Position position = objyClass().resolve_position(feature.getName()); + try + { + IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature); - IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature); - - int size = mapper.size(this, feature); + size = mapper.size(this, feature); - if (TRACER_DEBUG.isEnabled()) + if (TRACER_DEBUG.isEnabled()) + { + // TODO - verify the message. + TRACER_DEBUG.trace("Size of object " + ooId().getStoreString() + " - is: " + size + " - feature: " + + feature.getName()); + } + } + catch (RuntimeException ex) { - // TODO - verify the message. - TRACER_DEBUG.trace("Size of object " + ooId().getStoreString() + " - is: " + size + " - feature: " - + feature.getName()); + ex.printStackTrace(); } return size; } @@ -842,6 +1079,10 @@ public class ObjyObject */ public Object get(EStructuralFeature feature) { + if (feature.isMany()) + { + return getAll(feature, 0, CDORevision.UNCHUNKED); + } return get(feature, 0); } @@ -871,15 +1112,21 @@ public class ObjyObject ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); Object value = null; - if (feature.isMany()) + try { - value = ((IManyTypeMapper)mapper).getValue(this, feature, index); + if (feature.isMany()) + { + value = ((IManyTypeMapper)mapper).getValue(this, feature, index); + } + else + { + value = ((ISingleTypeMapper)mapper).getValue(this, feature); + } } - else + catch (RuntimeException ex) { - value = ((ISingleTypeMapper)mapper).getValue(this, feature); + ex.printStackTrace(); } - return value; } @@ -904,9 +1151,17 @@ public class ObjyObject } assert feature.isMany(); + Object[] values = null; - IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature); - Object[] values = mapper.getAll(this, feature, startIndex, chunkSize); + try + { + IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature); + values = mapper.getAll(this, feature, startIndex, chunkSize); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } return values; } @@ -921,15 +1176,22 @@ public class ObjyObject assert feature.isMany(); - IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature); + try + { + IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature); - // -- TODO -- verify the need to this one. - // ensureObjectAttached(feature, value); + // -- TODO -- verify the need to this one. + // ensureObjectAttached(feature, value); - // I believe we do the conversion in the add() - // value = provider.convertToStore(ooObject, value); + // I believe we do the conversion in the add() + // value = provider.convertToStore(ooObject, value); - mapper.add(this, feature, index, value); + mapper.add(this, feature, index, value); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } } /*** @@ -944,10 +1206,16 @@ public class ObjyObject } // Class_Position position = objyClass.resolve_position(feature.getName()); + try + { + ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); - ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); - - ((IManyTypeMapper)mapper).clear(this, feature); + ((IManyTypeMapper)mapper).clear(this, feature); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } } public void move(EStructuralFeature feature, int targetIndex, int sourceIndex) @@ -957,10 +1225,16 @@ public class ObjyObject checkSession(); TRACER_DEBUG.trace("Move element from " + sourceIndex + " to " + targetIndex); } + try + { + ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); - ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); - - ((IManyTypeMapper)mapper).move(this, feature, targetIndex, sourceIndex); + ((IManyTypeMapper)mapper).move(this, feature, targetIndex, sourceIndex); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } } public Object remove(EStructuralFeature feature, int index) @@ -972,19 +1246,27 @@ public class ObjyObject } // Class_Position position = objyClass.resolve_position(feature.getName()); + Object retObject = null; - IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature); + try + { + IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature); + + Object value = mapper.remove(this, feature, index); - Object value = mapper.remove(this, feature, index); + if (feature instanceof EAttribute) + { + return value; + } - if (feature instanceof EAttribute) + retObject = OBJYCDOIDUtil.getCDOID((ooId)value); + } + catch (RuntimeException ex) { - return value; + ex.printStackTrace(); } - Object objectFromResource = OBJYCDOIDUtil.getCDOID((ooId)value); - - return objectFromResource; + return retObject; } @@ -1004,24 +1286,30 @@ public class ObjyObject * ooObject.ooClass().resolve_position(className + "::" + feature.getName()); */ // Class_Position position = objyClass.resolve_position(feature.getName()); + try + { + ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); - ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); - - // --- TODO --- verify the need... - // ensureObjectAttached(this, feature, value); + // --- TODO --- verify the need... + // ensureObjectAttached(this, feature, value); - /*** - * I believe we do the conversion in the setValue if (feature instanceof EReference) { value = - * CDOIDUtil.getooId((CDOID)value); } - ***/ + /*** + * I believe we do the conversion in the setValue if (feature instanceof EReference) { value = + * CDOIDUtil.getooId((CDOID)value); } + ***/ - if (feature.isMany()) - { - ((IManyTypeMapper)mapper).setValue(this, feature, index, value); + if (feature.isMany()) + { + ((IManyTypeMapper)mapper).setValue(this, feature, index, value); + } + else + { + ((ISingleTypeMapper)mapper).setValue(this, feature, value); + } } - else + catch (RuntimeException ex) { - ((ISingleTypeMapper)mapper).setValue(this, feature, value); + ex.printStackTrace(); } return value; @@ -1062,120 +1350,165 @@ public class ObjyObject public void delete(ObjectivityStoreAccessor storeAccessor, ObjyObjectManager objectManager) { EClass eClass = ObjySchema.getEClass(storeAccessor.getStore(), objyClass()); - - for (EStructuralFeature feature : eClass.getEAllStructuralFeatures()) + try { - if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature)) - { - continue; - } - - if (feature.isMany()) + for (EStructuralFeature feature : eClass.getEAllStructuralFeatures()) { - // TODO - verify that we can do this to all referenced list. - // I'm not sure if it's valid when you have many-many - // relationship. - Object[] objects = getAll(feature, 0, -1); + if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature)) + { + continue; + } - for (int i = 0; i < objects.length; i++) + if (feature.isMany()) { - if (objects[i] instanceof ooId) + deleteFeatureObjects(objectManager, feature); + } + else + { + ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); + + if (mapper == null) { - ooId oid = (ooId)objects[i]; - // TODO - this code need refactoring.... - ooObj obj = ooObj.create_ooObj(oid); - if (obj.isDead()) - { - continue; - } + continue; + } + mapper.delete(this, feature); + } + } + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } + } - Class_Object refClassObject = Class_Object.class_object_from_oid(oid); + private void deleteFeatureObjects(ObjyObjectManager objectManager, EStructuralFeature feature) + { + // TODO - verify that we can do this to all referenced list. + // I'm not sure if it's valid when you have many-many relationship. + Object[] objects = getAll(feature, 0, CDORevision.UNCHUNKED); - if (refClassObject.type_of().name().equals(ObjyProxy.className)) - { - obj.delete(); - } - else - { - // if this object is a parent (resourceId or - // containerId) for obj, then we - // need to mark obj version as (-1). - ObjyObject childObjyObject = objectManager.getObject(oid); - ooId containerId = childObjyObject.getEContainerAsOid(); - ooId resourceId = childObjyObject.getEResourceAsOid(); - int childVersion = childObjyObject.getVersion(); - if (containerId.equals(objectId) || resourceId.equals(objectId)) - { - childObjyObject.setVersion(-childVersion); - } + if (objects == null) + { + return; + } - } - } - else if (objects[i] instanceof ObjyFeatureMapEntry) - { - ObjyFeatureMapEntry mapEntry = (ObjyFeatureMapEntry)objects[i]; - ooId oid = mapEntry.getObject(); - ooObj obj = ooObj.create_ooObj(oid); - obj.delete(); - } - else + for (int i = 0; i < objects.length; i++) + { + if (objects[i] instanceof ooId) + { + ooId oid = (ooId)objects[i]; + // TODO - this code need refactoring.... + ooObj obj = ooObj.create_ooObj(oid); + if (obj.isDead()) + { + continue; + } + + Class_Object refClassObject = Class_Object.class_object_from_oid(oid); + + if (refClassObject.type_of().name().equals(ObjyProxy.className)) + { + obj.delete(); + } + else + { + // if this object is a parent (resourceId or + // containerId) for obj, then we + // need to mark obj version as (-1). + ObjyObject childObjyObject = objectManager.getObject(oid); + ooId containerId = childObjyObject.getEContainerAsOid(); + ooId resourceId = childObjyObject.getEResourceAsOid(); + int childVersion = childObjyObject.getVersion(); + if (containerId.equals(objectId) || resourceId.equals(objectId)) { - // different feature then. - if (TRACER_DEBUG.isEnabled()) - { - TRACER_DEBUG.trace("-->> No process to delete() feature (" + i + ") -> feature:" + feature.getName() - + " - value:" + objects[i] + " ... nothing to do here."); - } + childObjyObject.setVersion(-childVersion); } + } } + else if (objects[i] instanceof ObjyFeatureMapEntry) + { + ObjyFeatureMapEntry mapEntry = (ObjyFeatureMapEntry)objects[i]; + ooId oid = mapEntry.getObject(); + ooObj obj = ooObj.create_ooObj(oid); + obj.delete(); + } else { - ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature); - - if (mapper == null) + // different feature then. + if (TRACER_DEBUG.isEnabled()) { - continue; + TRACER_DEBUG.trace("-->> No process to delete() feature (" + i + ") -> feature:" + feature.getName() + + " - value:" + objects[i] + " ... nothing to do here."); } - mapper.delete(this, feature); } } } // Wrapper functions over class object. - public Numeric_Value get_numeric(Class_Position position) + // public Numeric_Value get_numeric(Class_Position position) + // { + // return classObject.get_numeric(position); + // } + public Numeric_Value get_numeric(String attributeName) { - return classObject.get_numeric(position); + return classObject.nget_numeric(attributeName); } - public String_Value get_string(Class_Position position) + // public String_Value get_string(Class_Position position) + // { + // return classObject.get_string(position); + // } + public String_Value get_string(String attributeName) { - return classObject.get_string(position); + return classObject.nget_string(attributeName); } - public void set_numeric(Class_Position position, Numeric_Value value) + // public void set_numeric(Class_Position position, Numeric_Value value) + // { + // classObject.set_numeric(position, value); + // } + public void set_numeric(String attributeName, Numeric_Value value) { - classObject.set_numeric(position, value); + classObject.nset_numeric(attributeName, value); } - public VArray_Object get_varray(Class_Position position) + // public VArray_Object get_varray(Class_Position position) + // { + // return classObject.get_varray(position); + // } + public VArray_Object get_varray(String attributeName) { - return classObject.get_varray(position); + return classObject.nget_varray(attributeName); } - public ooId get_ooId(Class_Position position) + // public ooId get_ooId(Class_Position position) + // { + // return classObject.get_ooId(position); + // } + public ooId get_ooId(String attributeName) { - return classObject.get_ooId(position); + return classObject.nget_ooId(attributeName); } - public Class_Object get_class_obj(Class_Position position) + // public Class_Object get_class_obj(Class_Position position) + // { + // return classObject.get_class_obj(position); + // } + + public Class_Object get_class_obj(String attributeName) { - return classObject.get_class_obj(position); + return classObject.nget_class_obj(attributeName); } - public void set_ooId(Class_Position position, ooId object) + // public void set_ooId(Class_Position position, ooId object) + // { + // classObject.set_ooId(position, object); + // } + + public void set_ooId(String attributeName, ooId object) { - classObject.set_ooId(position, object); + classObject.nset_ooId(attributeName, object); } /** @@ -1183,23 +1516,58 @@ public class ObjyObject */ public CDOID getRevisionId() { - ooId oid = objectId; - - if (baseClassObject != null) + if (revisionId == null) { - oid = baseClassObject.objectID(); + if (hasBaseRelationship()) + { + baseClassObject = getBaseRelationship().get_class_obj(); + revisionId = baseClassObject.objectID(); + } + else + { + revisionId = objectId; + } } - return OBJYCDOIDUtil.getCDOID(oid); + return OBJYCDOIDUtil.getCDOID(revisionId); } + private boolean hasBaseRelationship() + { + if (!hasBaseRelationshipChecked) + { + hasBaseRelationshipChecked = getBaseRelationship().exists(); + } + return hasBaseRelationshipChecked; + } + + // private boolean hasRevisionsRelationship() + // { + // if (!hasRevisionsRelChecked) + // { + // hasRevisionsRelChecked = getRevisionsRelationship().exists(); + // } + // return hasRevisionsRelChecked; + // } + // + // private boolean hasLastRevisionRelationship() + // { + // if (!hasLastRevisionRelChecked) + // { + // hasLastRevisionRelChecked = getLastRevisionRelationship().exists(); + // } + // return hasLastRevisionRelChecked; + // } + /** * Return the revision that satisfies the timeStamp and branchId constrains. + * + * @param objyObjectManager */ - public ObjyObject getRevision(long timeStamp, int branchId) + public ObjyObject getRevision(long timeStamp, int branchId, ObjyObjectManager objyObjectManager) { ObjyObject objyRevision = null; - Session.getCurrent().setReturn_Class_Object(true); + // Session.getCurrent().setReturn_Class_Object(true); // int numRevisions = (int) revisions.size(); // evaluate current first. @@ -1209,16 +1577,24 @@ public class ObjyObject } // if we don't have other revisions. - if (!lastRevisionRel.exists()) + if (!getLastRevisionRelationship().exists()) { return null; } + // check last revision first. + objyRevision = getLastRevision(objyObjectManager); + if (evaluateRevision(timeStamp, branchId, objyRevision)) + { + return objyRevision; + } + @SuppressWarnings("unchecked") - Iterator<Class_Object> itr = revisionsRel.get_iterator(); + Iterator<ooObj> itr = getRevisionsRelationship().get_iterator(); while (itr.hasNext()) { - objyRevision = new ObjyObject(itr.next()); + // objyRevision = new ObjyObject(itr.next()); + objyRevision = objyObjectManager.getObject(itr.next().getOid()); if (evaluateRevision(timeStamp, branchId, objyRevision)) { return objyRevision; @@ -1229,7 +1605,8 @@ public class ObjyObject } /** - * return true if the objyRevision satisfies the constrains. + * return true if the objyRevision satisfies the constrains. This function is only called in case of auditing, and + * branching. */ protected boolean evaluateRevision(long timeStamp, int branchId, ObjyObject objyRevision) { @@ -1237,15 +1614,15 @@ public class ObjyObject if (objyRevision.getBranchId() == branchId) { long revisedTS = objyRevision.getRevisedTime(); - if (timeStamp != 0) + if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE) { long creationTS = objyRevision.getCreationTime(); - if (creationTS <= timeStamp && (revisedTS == 0 || revisedTS >= timeStamp)) + if (creationTS <= timeStamp && (revisedTS == CDOBranchPoint.UNSPECIFIED_DATE || revisedTS >= timeStamp)) { return true; } } - else if (revisedTS == 0) // return the latest version in that branch. + else if (revisedTS == CDOBranchPoint.UNSPECIFIED_DATE) // return the latest version in that branch. { return true; } @@ -1257,14 +1634,27 @@ public class ObjyObject { ObjyClass objyClass = ObjySchema.getObjyClass(ObjyBase.CLASS_NAME); Class_Object detachedClassObject = Class_Object.new_persistent_object(objyClass.getASClass(), objectId, false); - ObjyObject detachedObjyObject = new ObjyObject(detachedClassObject); + if (TRACER_DEBUG.isEnabled()) + { + ObjyObjectManager.newInternalObjCount++; + } + ObjyObject detachedObjyObject = null; - detachedObjyObject.setVersion(-(version + 1)); - detachedObjyObject.setBranchId(branch.getID()); - detachedObjyObject.setCreationTime(timeStamp); + try + { + detachedObjyObject = new ObjyObject(detachedClassObject); - // add it to the revisions. - addToRevisions(detachedObjyObject); + detachedObjyObject.setVersion(-(version + 1)); + detachedObjyObject.setBranchId(branch.getID()); + detachedObjyObject.setCreationTime(timeStamp); + + // add it to the revisions. + addToRevisions(detachedObjyObject); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + } } } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java index c198bdeea7..3580b8d3c0 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java @@ -44,6 +44,16 @@ public class ObjyObjectManager private ObjyPlacementManager globalPlacementManager = null; + public static int newObjCount = 0; + + public static int newInternalObjCount = 0; + + public static long getObjectTime = 0; + + public static long updateObjectTime = 0; + + public static long resourceCheckAndUpdateTime = 0; + public ObjyObjectManager(ObjyPlacementManager placementManager) { globalPlacementManager = placementManager; @@ -73,6 +83,10 @@ public class ObjyObjectManager Class_Object newClassObject = newClassObject(eClass, nearObject); ObjyObject objyObject = new ObjyObject(newClassObject); idToObjyObjectMap.put(OBJYCDOIDUtil.getLong(objyObject.ooId()), objyObject); + if (TRACER_DEBUG.isEnabled()) + { + newObjCount++; + } return objyObject; } @@ -101,6 +115,10 @@ public class ObjyObjectManager // .getStoreString() : null)); Class_Object newClassObject = Class_Object.new_persistent_object(objyClass.getASClass(), nearObject, false); + if (TRACER_DEBUG.isEnabled()) + { + ObjyObjectManager.newInternalObjCount++; + } // if (init != null) // { @@ -252,8 +270,7 @@ public class ObjyObjectManager TRACER_DEBUG.trace("ObjyObjectManager.copyRevision(" + objyObject.ooId().getStoreString() + ")"); } EClass eClass = ObjySchema.getEClass(storeAccessor.getStore(), objyObject.objyClass()); - ObjyObject newObjyRevision = objyObject.copy(eClass); - objyObject.addToRevisions(newObjyRevision); + ObjyObject newObjyRevision = objyObject.copy(eClass, this); return newObjyRevision; } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java index 07ebcec6cf..d4a0b1cca5 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java @@ -81,6 +81,11 @@ public class ObjySchema { d_Class newClass = getTopModule().resolve_class(name); // EClass eClass = getEClass(store, name); + // IS:TEMP + if (newClass == null) + { + TRACER_DEBUG.trace("NULL..... dClass for " + name); + } classObject = new ObjyClass(newClass); mapOfObjyClasses.put(name, classObject); } @@ -229,6 +234,12 @@ public class ObjySchema // System.out.println("OBJY: resolving class '" + className + "' in objy schema."); d_Class dClass = getTopModule().resolve_class(className); + // IS:TEMP + if (dClass == null) + { + TRACER_DEBUG.trace("NULL..... dClass for " + className); + } + ObjyClass objyClass = new ObjyClass(dClass/* , eClass */); return objyClass; } @@ -253,6 +264,11 @@ public class ObjySchema // System.out.println("OBJY: resolving class '" + className + "' in objy schema."); d_Class dClass = getTopModule().resolve_class(className); + // IS:TEMP. + if (dClass == null) + { + TRACER_DEBUG.trace("NULL..... dClass for " + className); + } ObjyClass objyClass = new ObjyClass(dClass/* , eClass */); return objyClass; } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java index 666696a49c..9137f7cff3 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java @@ -29,9 +29,9 @@ public class ObjyScope { private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyScope.class); - private ooContObj contObj; + private ooContObj contObj = null; - private ooDBObj dbObj; + private ooDBObj dbObj = null; private String dbName; @@ -76,13 +76,27 @@ public class ObjyScope { if (TRACER_DEBUG.isEnabled()) { - TRACER_DEBUG.trace(" DB: " + dbName + " - CT: " + contName); + TRACER_DEBUG.trace("ObjyScope - DB: " + dbName + " - CT: " + contName); } this.dbName = dbName; this.contName = contName; init(); } + // optimized version that takes an ooDBObj. + public ObjyScope(ooDBObj dbObj, String contName) + { + dbName = dbObj.getName(); + this.contName = contName; + this.dbObj = dbObj; + + if (TRACER_DEBUG.isEnabled()) + { + TRACER_DEBUG.trace("ObjyScope - DB: " + dbObj.getName() + " - CT: " + contName); + } + init(); + } + public ooId getScopeContOid() { return getContainerObj().getOid(); diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java index 07ce20d1c4..4d9fb61eb9 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java @@ -10,28 +10,40 @@ */ package org.eclipse.emf.cdo.server.internal.objectivity.db; +import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList; import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import com.objy.db.CannotUpgradeLockException; import com.objy.db.app.Session; import com.objy.db.app.oo; +import com.objy.db.app.ooContObj; +import com.objy.db.app.ooId; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -/*** - * Extends the session and keep an object manager instance. - * +/* * @author ibrahim */ public class ObjySession extends Session { + private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjySession.class); + + private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjySession.class); + private ObjyObjectManager objectManger = null; private ObjyResourceList resourceList = null; private ObjyBranchManager branchManager = null; + private ObjyLockAreaManager lockAreaManager = null; + // private ObjectivityStore store = null; protected String sessionName; @@ -44,6 +56,8 @@ public class ObjySession extends Session { super(objyConnection.getMinSessionCacheSize(), objyConnection.getMaxSessionCacheSize()); setThreadPolicy(oo.THREAD_POLICY_UNRESTRICTED); + // setHotMode(false); + setIndexMode(oo.EXPLICIT_UPDATE); sessionName = name; sessionPool = pool; // this.store = store; @@ -64,6 +78,15 @@ public class ObjySession extends Session return branchManager; } + public ObjyLockAreaManager getLockAreaManager(String repositoryName) + { + if (lockAreaManager == null) + { + lockAreaManager = ObjyDb.getOrCreateLockAreaManager(repositoryName); + } + return lockAreaManager; + } + public void setAvailable(boolean value) { available = value; @@ -79,6 +102,11 @@ public class ObjySession extends Session return sessionName; } + public void setName(String name) + { + sessionName = name; + } + public ConcurrentHashMap<String, ObjySession> getPool() { return sessionPool; @@ -94,10 +122,70 @@ public class ObjySession extends Session } @Override + public synchronized void returnSessionToPool() + { + // System.out.println(">>> IS: returning session: " + session.getName()); + // TODO Auto-generated method stub + leave(); + setAvailable(true); + } + + @Override public synchronized void terminate() { - // System.out.println("OBJY>>> Terminating session... " + this.toString()); + // System.out.println("OBJY>>> Terminating session... " + sessionName + " - " + toString()); resourceList = null; super.terminate(); } + + public void lockContainers(Set<ooId> containerToLocks) + { + // Locks all containers for modified objects + if (!containerToLocks.isEmpty()) + { + ooId idsToLock[] = containerToLocks.toArray(new ooId[containerToLocks.size()]); + // 100920 - IS: for debugging... TBR. + // for (ooId id : idsToLock) + // { + // TRACER_INFO.trace("Locking container: " + id.getStoreString()); + // } + + int count = 10; + while (0 != count--) + { + try + { + openContainers(idsToLock, oo.openReadWrite); + break; + } + catch (CannotUpgradeLockException cule) + { + // refresh containers. + for (ooId contId : idsToLock) + { + ooContObj contObj = (ooContObj)getFD().objectFrom(contId); + contObj.refresh(oo.WRITE); + } + } + catch (Exception e) + { + TRACER_INFO.trace("Locking problem try again : " + e.getMessage()); + // this.ensureNewBeginSession(); + if (!isOpen()) + { + TRACER_INFO.trace("Objy session is not open"); + // System.exit(-1); // TODO - this is temporary for debugging... + } + try + { + wait(500); + } + catch (InterruptedException ex) + { + } + } + } + } + } + } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java index 1f835a6b8c..0507ff03b7 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java @@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject; import org.eclipse.emf.ecore.EStructuralFeature; -import com.objy.as.app.Class_Position; import com.objy.as.app.Numeric_Value; import com.objy.as.app.Proposed_Class; import com.objy.as.app.String_Value; @@ -34,14 +33,18 @@ public class BigDecimalTypeMapper extends StringTypeMapper @Override public Object getValue(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); - boolean isNull = objyObject.get_numeric(nullPosition).booleanValue(); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); + + boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue(); Object value = null; if (!isNull) { - Class_Position position = getAttributePosition(objyObject, feature); - String_Value stringValue = objyObject.get_string(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + + String_Value stringValue = objyObject.get_string(attributeName/* position */); value = new BigDecimal(stringValue.toString()); } // else if (feature.isUnsettable()) @@ -55,20 +58,22 @@ public class BigDecimalTypeMapper extends StringTypeMapper @Override public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue) { - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); boolean isNull = newValue == null || newValue == CDORevisionData.NIL; Numeric_Value isNullValue = isNull ? numericTrue : numericFalse; if (!isNull) { - Class_Position position = getAttributePosition(objyObject, feature); - String_Value stringValue = objyObject.get_string(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + String_Value stringValue = objyObject.get_string(attributeName/* position */); stringValue.update(); String strValue = ((BigDecimal)newValue).toString(); - stringValue.set((strValue == null ? "" : strValue)); + stringValue.set(strValue == null ? "" : strValue); } - objyObject.set_numeric(nullPosition, isNullValue); + objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue); } @Override diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java index 3c6cf3dae2..a2f91bce9b 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java @@ -34,14 +34,18 @@ public class BigIntegerTypeMapper extends StringTypeMapper @Override public Object getValue(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); - boolean isNull = objyObject.get_numeric(nullPosition).booleanValue(); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); + + boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue(); Object value = null; if (!isNull) { - Class_Position position = getAttributePosition(objyObject, feature); - String_Value stringValue = objyObject.get_string(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + + String_Value stringValue = objyObject.get_string(attributeName/* position */); value = new BigInteger(stringValue.toString()); } // else if (feature.isUnsettable()) @@ -55,7 +59,8 @@ public class BigIntegerTypeMapper extends StringTypeMapper @Override public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue) { - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); boolean isNull = newValue == null || newValue == CDORevisionData.NIL; Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse; @@ -63,12 +68,14 @@ public class BigIntegerTypeMapper extends StringTypeMapper if (!isNull) { Class_Position position = getAttributePosition(objyObject, feature); - String_Value stringValue = objyObject.get_string(position); + String attributeName = getAttributeName(feature); + + String_Value stringValue = objyObject.get_string(attributeName/* position */); stringValue.update(); String strValue = newValue.toString(); stringValue.set(strValue); } - objyObject.set_numeric(nullPosition, isNullValue); + objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue); } @Override diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java index af0e5fbbf7..fd8c9d9d42 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java @@ -45,11 +45,14 @@ public class ByteArrayTypeMapper extends BasicTypeMapper implements ISingleTypeM public Object getValue(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); - VArray_Object vArray = objyObject.get_varray(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); - boolean isNull = objyObject.get_numeric(nullPosition).booleanValue(); + VArray_Object vArray = objyObject.get_varray(attributeName/* position */); + + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); + boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue(); if (isNull) { @@ -68,13 +71,17 @@ public class ByteArrayTypeMapper extends BasicTypeMapper implements ISingleTypeM public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue) { - Class_Position position = getAttributePosition(objyObject, feature); - VArray_Object vArray = objyObject.get_varray(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + + VArray_Object vArray = objyObject.get_varray(attributeName/* position */); + + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse; - objyObject.set_numeric(nullPosition, isNullValue); + objyObject.set_numeric(nullAttributeName /* nullPosition */, isNullValue); // System.out.println("OID: " + objyObject.ooId().getStoreString() + " - START work"); if (newValue == null) diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java index f040bf5a3e..3e51805a0b 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java @@ -14,7 +14,6 @@ import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject; import org.eclipse.emf.ecore.EStructuralFeature; -import com.objy.as.app.Class_Position; import com.objy.as.app.Numeric_Value; import com.objy.as.app.Proposed_Class; import com.objy.as.app.String_Value; @@ -30,10 +29,13 @@ public class CustomDataTypeMapper extends StringTypeMapper @Override public Object getValue(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); - String_Value stringValue = objyObject.get_string(position); - boolean isNull = objyObject.get_numeric(nullPosition).booleanValue(); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); + + String_Value stringValue = objyObject.get_string(attributeName/* position */); + boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue(); // EDataType dataType = (EDataType)feature.getEType(); // EFactory factory = dataType.getEPackage().getEFactoryInstance(); @@ -55,10 +57,12 @@ public class CustomDataTypeMapper extends StringTypeMapper @Override public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue) { - Class_Position position = getAttributePosition(objyObject, feature); - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); - String_Value stringValue = objyObject.get_string(position); + String_Value stringValue = objyObject.get_string(attributeName/* position */); stringValue.update(); // EDataType dataType = (EDataType)feature.getEType(); @@ -67,8 +71,8 @@ public class CustomDataTypeMapper extends StringTypeMapper // Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse; // String strValue = newValue == null ? null : valueAsString; - stringValue.set((newValue == null ? "" : newValue.toString())); - objyObject.set_numeric(nullPosition, isNullValue); + stringValue.set(newValue == null ? "" : newValue.toString()); + objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue); } @Override diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java index 1ccf91a8be..bf876a4588 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java @@ -69,12 +69,13 @@ public class FeatureMapTypeMapper extends BasicTypeMapper implements IManyTypeMa public ObjyFeatureMapArrayList getList(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); - ObjyFeatureMapArrayList list = (ObjyFeatureMapArrayList)objyObject.getFeatureList(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + ObjyFeatureMapArrayList list = (ObjyFeatureMapArrayList)objyObject.getFeatureList(attributeName/* position */); if (list == null) { - list = new ObjyFeatureMapArrayList(objyObject.get_class_obj(position)); - objyObject.setFeatureList(position, list); + list = new ObjyFeatureMapArrayList(objyObject.get_class_obj(attributeName/* position */)); + objyObject.setFeatureList(attributeName/* position */, list); } return list; } @@ -105,6 +106,9 @@ public class FeatureMapTypeMapper extends BasicTypeMapper implements IManyTypeMa // create the reference. Class_Object newClassObject = Class_Object .new_persistent_object(getArrayListClass(), classObject.objectID(), false); + // { + // ObjyObjectManager.newInternalObjCount++; + // } Class_Position position = classObject.type_of().position_in_class(getAttributeName(feature)); classObject.set_ooId(position, newClassObject.objectID()); // initialize the list structure. @@ -113,8 +117,8 @@ public class FeatureMapTypeMapper extends BasicTypeMapper implements IManyTypeMa public void delete(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); - ooId tobeDeleted = objyObject.get_ooId(position); + // Class_Position position = getAttributePosition(objyObject, feature); + ooId tobeDeleted = objyObject.get_ooId(getAttributeName(feature)/* position */); ooObj objectToDelete = ooObj.create_ooObj(tobeDeleted); objectToDelete.delete(); } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java index 59d8fb0172..b13f6bae08 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java @@ -28,6 +28,7 @@ import com.objy.as.app.d_Class; import com.objy.db.ObjyRuntimeException; import com.objy.db.app.ooId; import com.objy.db.app.ooObj; +import com.objy.db.util.ooTreeListX; /** * @author Simon McDuff @@ -93,40 +94,42 @@ public class ManyReferenceMapper extends BasicTypeMapper implements IManyTypeMap { ObjyArrayListId list = getList(internal, feature); - if (list != null) - { - list.set(index, TypeConvert.toOoId(newValue)); - } - else + try { - try + if (list != null) { - throw new Exception("Trying to setValue for object while the list is null."); + list.set(index, TypeConvert.toOoId(newValue)); } - catch (Exception e) + else { - // TODO Auto-generated catch block - e.printStackTrace(); + throw new Exception("Trying to setValue for object while the list is null."); } } + catch (Exception e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } } public ObjyArrayListId getList(ObjyObject objyObject, EStructuralFeature feature) { // System.out.println("getList() for : " + objyObject.ooId().getStoreString() + " feature: " + feature.getName()); - Class_Position position = getAttributePosition(objyObject, feature); - ObjyArrayListId list = (ObjyArrayListId)objyObject.getFeatureList(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + ObjyArrayListId list = (ObjyArrayListId)objyObject.getFeatureList(attributeName/* position */); if (list == null) { try { - ooId oid = objyObject.get_ooId(position); + ooId oid = objyObject.get_ooId(attributeName/* position */); if (!oid.isNull()) { list = new ObjyArrayListId(Class_Object.class_object_from_oid(oid)); - objyObject.setFeatureList(position, list); + objyObject.setFeatureList(attributeName/* position */, list); } + // System.out.println("... getList() -> gotOID: " + oid.getStoreString()); } catch (ObjyRuntimeException e) { @@ -198,22 +201,28 @@ public class ManyReferenceMapper extends BasicTypeMapper implements IManyTypeMap public void initialize(Class_Object classObject, EStructuralFeature feature) { Class_Position position = classObject.position_in_class(getAttributeName(feature)); - Class_Object newClassObject = Class_Object - .new_persistent_object(getArrayListClass(), classObject.objectID(), false); - classObject.set_ooId(position, newClassObject.objectID()); - ObjyArrayListId.initObject(newClassObject); + // Class_Object newClassObject = Class_Object + // .new_persistent_object(getArrayListClass(), classObject.objectID(), false); + ooTreeListX list = new ooTreeListX(2, false); + // ObjyObjectManager.newInternalObjCount++; + ooObj anObj = ooObj.create_ooObj(classObject.objectID()); + anObj.cluster(list); + classObject.set_ooId(position, list.getOid()); + // classObject.set_ooId(position, newClassObject.objectID()); + // ObjyArrayListId.initObject(newClassObject); } public void delete(ObjyObject objyObject, EStructuralFeature feature) { // System.out.println("delete() for : " + objyObject.ooId().getStoreString() + " feature: " + feature.getName()); - Class_Position position = getAttributePosition(objyObject, feature); - ooId tobeDeleted = objyObject.get_ooId(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + ooId tobeDeleted = objyObject.get_ooId(attributeName/* position */); ooObj objectToDelete = ooObj.create_ooObj(tobeDeleted); objectToDelete.delete(); // set the reference to null. - objyObject.set_ooId(position, null); - objyObject.setFeatureList(position, null); + objyObject.set_ooId(getAttributeName(feature)/* position */, null); + objyObject.setFeatureList(attributeName/* position */, null); } public void clear(ObjyObject objyObject, EStructuralFeature feature) diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java index 1f0b5844e4..84584c7435 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java @@ -20,7 +20,6 @@ import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.emf.ecore.EStructuralFeature; import com.objy.as.app.Class_Object; -import com.objy.as.app.Class_Position; import com.objy.as.app.Numeric_Value; import com.objy.as.app.Proposed_Basic_Attribute; import com.objy.as.app.Proposed_Class; @@ -378,8 +377,9 @@ public abstract class NumericManyTypeMapper extends BasicTypeMapper implements I protected VArray_Object getArray(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); - return objyObject.get_varray(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + return objyObject.get_varray(attributeName/* position */); } // ------------------------------------------------------------------------ diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java index 2c8076b38a..c8c4b88810 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java @@ -20,7 +20,6 @@ import org.eclipse.emf.ecore.EStructuralFeature; import com.objy.as.app.Basic_Type; import com.objy.as.app.Class_Object; -import com.objy.as.app.Class_Position; import com.objy.as.app.Numeric_Value; import com.objy.as.app.Proposed_Basic_Attribute; import com.objy.as.app.Proposed_Class; @@ -148,17 +147,19 @@ public abstract class NumericTypeMapper extends BasicTypeMapper implements ISing public Object getValue(ObjyObject objyObject, EStructuralFeature feature) { Numeric_Value numericValue = null; - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); - boolean isNull = objyObject.get_numeric(nullPosition).booleanValue(); + boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue(); // if (isNull && feature.isUnsettable()) // return CDORevisionData.NIL; if (!isNull) { - Class_Position position = getAttributePosition(objyObject, feature); - numericValue = objyObject.get_numeric(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + numericValue = objyObject.get_numeric(attributeName/* position */); } return fromNumericValue(numericValue, isNull); @@ -168,16 +169,18 @@ public abstract class NumericTypeMapper extends BasicTypeMapper implements ISing { boolean isNull = newValue == null || newValue == CDORevisionData.NIL; Numeric_Value isNullValue = isNull ? numericTrue : numericFalse; - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); if (!isNull) { - Class_Position position = getAttributePosition(objyObject, feature); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); Numeric_Value numericValue = toNumericValue(newValue); - objyObject.set_numeric(position, numericValue); + objyObject.set_numeric(attributeName/* position */, numericValue); } - objyObject.set_numeric(nullPosition, isNullValue); + objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue); } public Object remove(ObjyObject objyObject, EStructuralFeature feature) @@ -189,14 +192,15 @@ public abstract class NumericTypeMapper extends BasicTypeMapper implements ISing { // throw new UnsupportedOperationException("Implement me!!"); // we just set the numeric _null to "true" - Class_Position position = getNullAttributePosition(objyObject, feature); - objyObject.set_numeric(position, numericTrue); + // Class_Position position = getNullAttributePosition(objyObject, feature); + // String nullAttributeName = getNullAttributeName(feature); + objyObject.set_numeric(getNullAttributeName(feature)/* position */, numericTrue); } public void initialize(Class_Object classObject, EStructuralFeature feature) { - Class_Position position = classObject.type_of().position_in_class(getNullAttributeName(feature)); - classObject.set_numeric(position, numericTrue); + // Class_Position position = classObject.type_of().position_in_class(getNullAttributeName(feature)); + classObject.nset_numeric(getNullAttributeName(feature) /* position */, numericTrue); } // various numeric types.... diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java index 9d1f4e5917..9747872bca 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java @@ -18,7 +18,6 @@ import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EStructuralFeature; import com.objy.as.app.Class_Object; -import com.objy.as.app.Class_Position; import com.objy.as.app.Proposed_Class; import com.objy.as.app.d_Access_Kind; import com.objy.as.app.d_Attribute; @@ -49,22 +48,25 @@ public class SingleContainementReferenceMapper extends BasicTypeMapper implement public Object getValue(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); // TODO Auto-generated method stub - ooId id2 = objyObject.get_ooId(position); + ooId id2 = objyObject.get_ooId(attributeName/* position */); if (id2 == null || id2.isNull()) { return null; } - Class_Object childObject = objyObject.get_class_obj(position); + Class_Object childObject = objyObject.get_class_obj(attributeName/* position */); return childObject; } public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue) { - Class_Position position = getAttributePosition(objyObject, feature); - objyObject.set_ooId(position, (ooId)newValue); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + + objyObject.set_ooId(attributeName/* position */, (ooId)newValue); } public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature) diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java index 184537e466..cbb62a2ff0 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java @@ -22,7 +22,6 @@ import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EStructuralFeature; import com.objy.as.app.Class_Object; -import com.objy.as.app.Class_Position; import com.objy.as.app.Proposed_Class; import com.objy.as.app.d_Access_Kind; import com.objy.as.app.d_Attribute; @@ -55,15 +54,16 @@ public class SingleReferenceMapper extends BasicTypeMapper implements ISingleTyp /*** * ooId id2 = internal.ooClassObject().get_ooId(position); if (id2 == null || id2.isNull()) { return null; } ***/ - Class_Position position = getAttributePosition(objyObject, feature); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); - return getValue(objyObject, position); + return getValue(objyObject, attributeName/* position */); } // called by ObjyObject to get some resource elements. - public Object getValue(ObjyObject objyObject, Class_Position position) + public Object getValue(ObjyObject objyObject, String attributeName/* Class_Position position */) { - ooId childObject = objyObject.get_ooId(position); + ooId childObject = objyObject.get_ooId(attributeName/* position */); if (!childObject.isNull()) { @@ -86,17 +86,20 @@ public class SingleReferenceMapper extends BasicTypeMapper implements ISingleTyp public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue) { - Class_Position position = getAttributePosition(objyObject, feature); - setValue(objyObject, position, newValue); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + + setValue(objyObject, attributeName/* position */, newValue); } // called by ObjyObject to set resource elements. - public void setValue(ObjyObject objyObject, Class_Position position, Object newValue) + public void setValue(ObjyObject objyObject, String attributeName/* Class_Position position */, Object newValue) { ooId ooid = null; if (newValue instanceof CDOIDExternal) { + System.out.println("... CDOIDExternal inserted, content:" + ((CDOIDExternal)newValue).getURI()); // create an ObjyProxy object to hold the the value. ObjyProxy proxyObject = ObjyProxy.createObject(objyObject.ooId()); proxyObject.setUri(((CDOIDExternal)newValue).getURI()); @@ -107,7 +110,7 @@ public class SingleReferenceMapper extends BasicTypeMapper implements ISingleTyp ooid = TypeConvert.toOoId(newValue); } - objyObject.set_ooId(position, ooid); + objyObject.set_ooId(attributeName/* position */, ooid); } public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature) @@ -119,8 +122,10 @@ public class SingleReferenceMapper extends BasicTypeMapper implements ISingleTyp public void delete(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); - ooId childOid = objyObject.get_ooId(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + + ooId childOid = objyObject.get_ooId(attributeName/* position */); if (!childOid.isNull()) { // This is a single reference, so we shouldn't be deleting the reference diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java index 5832c6368e..cfa7c7fb43 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java @@ -78,12 +78,14 @@ public class StringManyTypeMapper extends BasicTypeMapper implements IManyTypeMa protected ObjyArrayListString getList(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); - ObjyArrayListString list = (ObjyArrayListString)objyObject.getFeatureList(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + + ObjyArrayListString list = (ObjyArrayListString)objyObject.getFeatureList(attributeName/* position */); if (list == null) { - list = new ObjyArrayListString(objyObject.get_class_obj(position)); - objyObject.setFeatureList(position, list); + list = new ObjyArrayListString(objyObject.get_class_obj(attributeName/* position */)); + objyObject.setFeatureList(attributeName/* position */, list); } return list; } @@ -172,6 +174,7 @@ public class StringManyTypeMapper extends BasicTypeMapper implements IManyTypeMa Class_Position position = classObject.type_of().position_in_class(getAttributeName(feature)); Class_Object newClassObject = Class_Object.new_persistent_object( ObjySchema.getObjyClass(ObjyArrayListString.ClassName).getASClass(), classObject.objectID(), false); + // ObjyObjectManager.newInternalObjCount++; classObject.set_ooId(position, newClassObject.objectID()); ObjyArrayListString.initObject(newClassObject); } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java index beef516693..e78669f365 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java @@ -65,10 +65,12 @@ public class StringTypeMapper extends BasicTypeMapper implements ISingleTypeMapp public Object getValue(ObjyObject objyObject, EStructuralFeature feature) { - Class_Position position = getAttributePosition(objyObject, feature); - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); - String_Value stringValue = objyObject.get_string(position); - boolean isNull = objyObject.get_numeric(nullPosition).booleanValue(); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); + String_Value stringValue = objyObject.get_string(attributeName/* position */); + boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue(); Object value = null; if (!isNull) @@ -84,17 +86,19 @@ public class StringTypeMapper extends BasicTypeMapper implements ISingleTypeMapp public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue) { boolean isNull = newValue == null || newValue == CDORevisionData.NIL; - Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + // Class_Position nullPosition = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); if (!isNull) { - Class_Position position = getAttributePosition(objyObject, feature); - String_Value stringValue = objyObject.get_string(position); + // Class_Position position = getAttributePosition(objyObject, feature); + String attributeName = getAttributeName(feature); + String_Value stringValue = objyObject.get_string(attributeName/* position */); stringValue.update(); stringValue.set((String)newValue); } Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse; - objyObject.set_numeric(nullPosition, isNullValue); + objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue); } public Object remove(ObjyObject objyObject, EStructuralFeature feature) @@ -106,8 +110,9 @@ public class StringTypeMapper extends BasicTypeMapper implements ISingleTypeMapp { // we could set the string value to "", but it would be easier to just set // the numeric _null to "true" - Class_Position position = getNullAttributePosition(objyObject, feature); - objyObject.set_numeric(position, numericTrue); + // Class_Position position = getNullAttributePosition(objyObject, feature); + String nullAttributeName = getNullAttributeName(feature); + objyObject.set_numeric(nullAttributeName/* position */, numericTrue); // throw new UnsupportedOperationException("Implement me!!"); } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java index 86f590b8a7..b6ffdef2b7 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java @@ -1,120 +1,262 @@ -/** - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * 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: - * Simon McDuff - initial API and implementation - * Ibrahim Sallam - code refactoring for CDO 3.0 - */ -package org.eclipse.emf.cdo.server.internal.objectivity.schema; - -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM; -import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import com.objy.as.app.Class_Object; -import com.objy.as.app.Proposed_Class; -import com.objy.as.app.d_Access_Kind; -import com.objy.as.app.d_Module; -import com.objy.as.app.ooBaseType; -import com.objy.db.app.ooId; - -/** - * @author Simon McDuff - */ -public class ObjyArrayListId extends ObjyArrayList<ooId> -{ - - private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyArrayListId.class); - - static public String className = "ObjyArrayListId"; - - public static void buildSchema() - { - d_Module top_mod = ObjySchema.getTopModule(); - if (top_mod.resolve_class(ObjyArrayListId.className) == null - && top_mod.resolve_proposed_class(ObjyArrayListId.className) == null) - { - - if (TRACER_DEBUG.isEnabled()) - { - TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId"); - } - - boolean inProcess = top_mod.proposed_classes().hasNext(); - - // Proposed_Class A = new Proposed_Class(ooArrayListId.ClassName); - Proposed_Class A = top_mod.propose_new_class(ObjyArrayListId.className); - - A.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj" /* "ooObj" */); - - A.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind - ObjyArrayList.sizeName, // Attribute name - 1, // # elements in fixed-size array - ooBaseType.ooINT32 // Type of numeric data - ); // Default value - - A.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind - ObjyArrayList.arrayName, // Attribute name - 1, // # elements in fixed-size array - false, "ooObj"); - - // top_mod.propose_new_class(A); - if (!inProcess) - { - top_mod.activate_proposals(true, true); - } - - if (TRACER_DEBUG.isEnabled()) - { - TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added"); - } - } - - } - - public ObjyArrayListId(Class_Object classObject) - { - super(classObject); - // TODO Auto-generated constructor stub - } - - @Override - protected void setValue(long index, ooId newValue) - { - getVArray().update(); - getVArray().set_ooId(index, newValue); - } - - @Override - protected ooId getValue(long index) - { - // System.out.println(" - ooArrayListId.getValue() at index: " + index + - // " for classObject: " + classObject.objectID().getStoreString() ); - return getVArray().get_ooId(index); - } - - public ooId[] getAll(int index, int chunkSize) - { - long size = size(); - // System.out.println("ooArrayListId.getAll() - size:" + size); - - if (chunkSize != CDORevision.UNCHUNKED) - { - size = Math.min(size, chunkSize); - } - - ooId[] ooIds = new ooId[(int)size]; - for (int i = 0; i < size; i++) - { - ooIds[i] = getValue(i + index); - } - return ooIds; - } - -} +/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.as.app.Class_Object;
+import com.objy.db.app.Session;
+import com.objy.db.app.ooFDObj;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeListX;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Simon McDuff
+ * @author ibrahim 100920 - IS: modified to use ooTreeListX instead of ObjyArrayList<ooId>. minimize the changes for the
+ * 3.0.x build. 100927 - IS: changed to wrap ooTreeListX to avoid using extra class/Class_Object creation
+ */
+public class ObjyArrayListId
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyArrayListId.class);
+
+ static public String className = "ooTreeListX";
+
+ private Class_Object classObject = null;
+
+ private ooTreeListX list = null;
+
+ // private int size = 0;
+
+ public static void buildSchema()
+ {
+ return;
+ // d_Module top_mod = ObjySchema.getTopModule();
+ // if (top_mod.resolve_class(ObjyArrayListId.className) == null
+ // && top_mod.resolve_proposed_class(ObjyArrayListId.className) == null)
+ // {
+ //
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
+ // }
+ //
+ // boolean inProcess = top_mod.proposed_classes().hasNext();
+ //
+ // // Proposed_Class A = new Proposed_Class(ooArrayListId.ClassName);
+ // Proposed_Class A = top_mod.propose_new_class(ObjyArrayListId.className);
+ //
+ // A.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj" /* "ooObj" */);
+ //
+ // A.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ // ObjyArrayList.sizeName, // Attribute name
+ // 1, // # elements in fixed-size array
+ // ooBaseType.ooINT32 // Type of numeric data
+ // ); // Default value
+ //
+ // A.add_ref_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ // ObjyArrayList.arrayName, // Attribute name
+ // 1, // # elements in fixed-size array
+ // "ooTreeListX", false);
+ //
+ // // top_mod.propose_new_class(A);
+ // if (!inProcess)
+ // {
+ // top_mod.activate_proposals(true, true);
+ // }
+ //
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
+ // }
+ // }
+
+ }
+
+ public static void initObject(Class_Object classObject)
+ {
+ return;
+ // // set the size to 0;
+ // classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(0));
+ // // create the ooTreeListX.
+ // ooTreeListX list = new ooTreeListX();
+ // ooObj anObj = ooObj.create_ooObj(classObject.objectID());
+ // anObj.cluster(list);
+ // // System.out.println("initObject: " + anObj.getOid().getStoreString() + " treeListX: "
+ // // + list.getOid().getStoreString());
+ // classObject.nset_ooId(ObjyArrayList.arrayName, list.getOid());
+ }
+
+ public ObjyArrayListId(Class_Object classObject)
+ {
+ this.classObject = classObject;
+ // get the ooTreeList object.
+ // ooId listId = classObject.nget_ooId(ObjyArrayList.arrayName);
+ ooId listId = classObject.objectID();
+ list = (ooTreeListX)Session.getCurrent().getFD().objectFrom(listId);
+ // size = (int)classObject.nget_numeric(ObjyArrayList.sizeName).longValue();
+ }
+
+ protected void setValue(long index, ooObj newValue)
+ {
+ list.set((int)index, newValue);
+ }
+
+ protected ooObj getValue(long index)
+ {
+ return (ooObj)list.get((int)index);
+ }
+
+ protected ooId getOidValue(long index)
+ {
+ // System.out.println(" - ooArrayListId.getValue() at index: " + index +
+ // " for classObject: " + classObject.objectID().getStoreString() );
+ return getValue(index).getOid();
+ }
+
+ public ooId get(long index)
+ {
+ if (index >= size())
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ return getOidValue(index);
+ }
+
+ public void set(long index, ooId newValue)
+ {
+ setValue(index, ooObj.create_ooObj(newValue));
+ setSize();
+ }
+
+ public ooId[] getAll(int index, int chunkSize)
+ {
+ long size = size();
+
+ if (chunkSize != CDORevision.UNCHUNKED)
+ {
+ size = Math.min(size, chunkSize);
+ }
+ if (size == 0)
+ {
+ return null;
+ }
+
+ ooId[] ooIds = new ooId[(int)size];
+ for (int i = 0; i < size; i++)
+ {
+ ooIds[i] = getOidValue(i + index);
+ }
+ return ooIds;
+ }
+
+ public void add(ooId newValue)
+ {
+ list.add(ooObj.create_ooObj(newValue));
+ // size++;
+ }
+
+ public void add(int index, ooId newValue)
+ {
+ try
+ {
+ list.add(index, ooObj.create_ooObj(newValue));
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ // size++;
+ }
+
+ public void addAll(int index, Object[] newValue)
+ {
+ List<Object> objList = new ArrayList<Object>();
+ ooFDObj fdObj = Session.getCurrent().getFD();
+ for (int i = 0; i < newValue.length; i++)
+ {
+ objList.add(ooObj.create_ooObj((ooId)newValue[i]));
+ }
+
+ list.addAll(index, objList);
+ // setSize();
+ }
+
+ public void move(long newPosition, long oldPosition)
+ {
+ if (oldPosition == newPosition)
+ {
+ return;
+ }
+
+ // get the object at oldPosition.
+ ooObj value = getValue(oldPosition);
+
+ // remove the oldPosition.
+ remove((int)oldPosition);
+ list.add((int)newPosition, value);
+ }
+
+ public void remove(int index)
+ {
+ list.remove(index);
+ // setSize();
+ }
+
+ public void clear()
+ {
+ list.clear();
+ // size = 0;
+ // setSize();
+ }
+
+ protected void setSize()
+ {
+ // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
+ // System.out.println("ooArrayList.saveSize() - value to store in objy is: " + cacheSize);
+ // classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(size));
+ }
+
+ public long size()
+ {
+ // size = (int)classObject.nget_numeric(ObjyArrayList.sizeName).longValue();
+ int size = list.size();
+ return size;
+ }
+
+ public ooObj copy(ooObj nearObj)
+ {
+
+ ooTreeListX newList = new ooTreeListX(2/* (int)size() */, false);
+ // ObjyObjectManager.newInternalObjCount++;
+
+ nearObj.cluster(newList);
+ if (size() > 0)
+ {
+ newList.addAll(list);
+ }
+
+ // Class_Object newClassObject = new Class_Object(newObj);
+ // newClassObject.nset_ooId(ObjyArrayList.arrayName, newList.getOid());
+
+ return newList;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java index 87c6e23ee7..058b5d920f 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java @@ -130,9 +130,10 @@ public class ObjyBranchManager extends ooObj ObjyBranch objyBranch = null; while (treeItr.hasNext()) { - objyBranch = treeItr.next(); - if (branchId == objyBranch.getBranchId()) + ObjyBranch tempObjyBranch = treeItr.next(); + if (branchId == tempObjyBranch.getBranchId()) { + objyBranch = tempObjyBranch; break; } } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java index 8611f175b3..43b6a7494b 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java @@ -14,6 +14,7 @@ package org.eclipse.emf.cdo.server.internal.objectivity.schema; import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema; import com.objy.as.app.Class_Object; +import com.objy.as.app.Numeric_Value; import com.objy.as.app.Proposed_Class; import com.objy.as.app.d_Access_Kind; import com.objy.as.app.d_Module; @@ -73,6 +74,7 @@ public class ObjyFeatureMapEntry false); classObject.nset_ooId(EntryObject, object); + classObject.nset_numeric(EntryName, new Numeric_Value(tagId)); } public ObjyFeatureMapEntry(Class_Object classObject) @@ -82,23 +84,33 @@ public class ObjyFeatureMapEntry object = classObject.nget_ooId(EntryObject); } + protected void fetchObject() + { + tagId = classObject.nget_numeric(EntryName).intValue(); + object = classObject.nget_ooId(EntryObject); + } + public int getTagId() { + fetchObject(); return tagId; } public void setTagId(int tagId) { + classObject.nset_numeric(EntryName, new Numeric_Value(tagId)); this.tagId = tagId; } public ooId getObject() { + fetchObject(); return object; } public void setObject(ooId object) { + classObject.nset_ooId(EntryObject, object); this.object = object; } diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java new file mode 100644 index 0000000000..9a2303cea3 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java @@ -0,0 +1,182 @@ +/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
+
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeSetX;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class ObjyLockArea extends ooObj
+{
+
+ public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32;
+
+ private String durableLockingID;
+
+ private String userID;
+
+ private ObjyBranch branchPoint;
+
+ private boolean readOnly;
+
+ private ooTreeSetX readLockSet;
+
+ private ooTreeSetX writeLockSet;
+
+ private ooTreeSetX readWriteLockSet;
+
+ protected ObjyLockArea(String durableLockingID, String userID, ObjyBranch branchPoint, boolean readOnly)
+ {
+ this.durableLockingID = durableLockingID;
+ this.userID = userID;
+ this.branchPoint = branchPoint;
+ this.readOnly = readOnly;
+ }
+
+ public static ObjyLockArea create(ooId scopeContOid, String durableLockingID, String userID, ObjyBranch branchPoint,
+ boolean readOnly, Map<CDOID, LockGrade> locks)
+ {
+ ObjyLockArea objyLockArea = new ObjyLockArea(durableLockingID, userID, branchPoint, readOnly);
+ ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
+ clusterObject.cluster(objyLockArea);
+
+ objyLockArea.createLockSets(locks);
+
+ return objyLockArea;
+ }
+
+ protected void createLockSets(Map<CDOID, LockGrade> locks)
+ {
+ readLockSet = new ooTreeSetX();
+ this.cluster(readLockSet);
+ writeLockSet = new ooTreeSetX();
+ this.cluster(writeLockSet);
+ readWriteLockSet = new ooTreeSetX();
+ this.cluster(readWriteLockSet);
+
+ for (Entry<CDOID, LockGrade> entry : locks.entrySet())
+ {
+ CDOID id = entry.getKey();
+ LockGrade grade = entry.getValue();
+
+ switch (grade)
+ {
+ case READ_WRITE:
+ readWriteLockSet.add(id);
+ break;
+ case READ:
+ readLockSet.add(id);
+ break;
+ case WRITE:
+ writeLockSet.add(id);
+ break;
+ }
+ }
+
+ }
+
+ public String getDurableLockingID()
+ {
+ fetch();
+ return durableLockingID;
+ }
+
+ public String getUserID()
+ {
+ fetch();
+ return userID;
+ }
+
+ public ObjyBranch getBranch()
+ {
+ fetch();
+ return branchPoint;
+ }
+
+ public long getTimeStamp()
+ {
+ fetch();
+ return branchPoint.getBranchInfo().getBaseTimeStamp();
+ }
+
+ public boolean isReadOnly()
+ {
+ fetch();
+ return readOnly;
+ }
+
+ public Map<CDOID, LockGrade> getLocks()
+ {
+ fetch();
+
+ Map<CDOID, LockGrade> locks = new HashMap<CDOID, LockGrade>();
+
+ @SuppressWarnings("rawtypes")
+ Iterator itr = readLockSet.iterator();
+ while (itr.hasNext())
+ {
+ locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.READ);
+ }
+
+ itr = writeLockSet.iterator();
+ while (itr.hasNext())
+ {
+ locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.WRITE);
+ }
+
+ itr = readWriteLockSet.iterator();
+ while (itr.hasNext())
+ {
+ locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.READ_WRITE);
+ }
+
+ return locks;
+ }
+
+ @Override
+ public String toString()
+ {
+ fetch();
+ return MessageFormat
+ .format(
+ "ObjyLockArea[id={0}, user={1}, branchPoint={2}, readOnly={3}, readlocks={4}, writeLocks{5}, readWriteLocks{6}",
+ durableLockingID, userID, branchPoint, readOnly, readLockSet.size(), writeLockSet.size(),
+ readWriteLockSet.size());
+ }
+
+ // public static String createDurableLockingID()
+ // {
+ // return createDurableLockingID(DEFAULT_DURABLE_LOCKING_ID_BYTES);
+ // }
+ //
+ // public static String createDurableLockingID(int bytes)
+ // {
+ // byte[] buffer = new byte[bytes];
+ //
+ // Random random = new Random(System.currentTimeMillis());
+ // random.nextBytes(buffer);
+ //
+ // return HexUtil.bytesToHex(buffer);
+ // }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockAreaManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockAreaManager.java new file mode 100644 index 0000000000..959f7b8a5b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockAreaManager.java @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * 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: + * Ibrahim Sallam - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.objectivity.schema; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea.Handler; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; +import org.eclipse.emf.cdo.spi.server.DurableLockArea; + +import com.objy.db.app.Iterator; +import com.objy.db.app.ooId; +import com.objy.db.app.ooObj; +import com.objy.db.util.ooMap; + +/** + * @author Ibrahim Sallam + */ +public class ObjyLockAreaManager extends ooObj +{ + + private ooMap lockAreasMap; + + private ObjyLockAreaManager() + { + } + + protected void createMap(ooObj clusterObject) + { + lockAreasMap = new ooMap(); + clusterObject.cluster(lockAreasMap); + } + + public static ObjyLockAreaManager create(ooId scopeContOid) + { + ObjyLockAreaManager manager = new ObjyLockAreaManager(); + ooObj clusterObject = ooObj.create_ooObj(scopeContOid); + clusterObject.cluster(manager); + + manager.createMap(manager); + + return manager; + } + + public void getLockAreas(InternalCDOBranchManager branchManager, String userIDPrefix, Handler handler) + { + fetch(); + Iterator itr = lockAreasMap.elements(); + while (itr.hasNext()) + { + ObjyLockArea objyLockArea = (ObjyLockArea)itr.next(); + String userID = objyLockArea.getUserID(); + if (userID != null && userID.startsWith(userIDPrefix)) + { + if (!handler.handleLockArea(makeLockArea(branchManager, objyLockArea))) + { + return; + } + } + } + } + + private LockArea makeLockArea(InternalCDOBranchManager branchManager, ObjyLockArea objyLockArea) + { + ObjyBranch objyBranch = objyLockArea.getBranch(); + CDOBranchPoint branchPoint = branchManager.getBranch(objyBranch.getBranchId()) + .getPoint(objyLockArea.getTimeStamp()); + return new DurableLockArea(objyLockArea.getDurableLockingID(), objyLockArea.getUserID(), branchPoint, + objyLockArea.isReadOnly(), objyLockArea.getLocks()); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java index 17a8f2bafb..d2ed2c4ef3 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java @@ -1,236 +1,284 @@ -/** - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * 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: - * Ibrahim Sallam - initial API and implementation - */ -package org.eclipse.emf.cdo.server.internal.objectivity.schema; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.eresource.EresourcePackage; -import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor; -import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM; -import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject; -import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema; -import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.emf.ecore.EStructuralFeature; - -import com.objy.as.app.Class_Object; -import com.objy.as.app.Class_Position; -import com.objy.as.app.Proposed_Class; -import com.objy.as.app.d_Access_Kind; -import com.objy.as.app.d_Module; -import com.objy.db.ObjyRuntimeException; -import com.objy.db.app.ooId; - -/*** - * OoResouceList is a specialized ooArrayListId, where all elements are of type Resourc(Node|Folder). The class will - * allow adding, validating and removing resources From the list. - * - * @author ibrahim - */ -public class ObjyResourceList -{ - - private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyProxy.class); - - static public String className = "ooResourceList"; - - static public String Attribute_arrayName = "oo_array"; - - private ObjySession objySession; - - protected Class_Object classObject; - - protected ObjyArrayListId list = null; - - protected ooId objectId; - - private static final EStructuralFeature featureName = EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME; - - // we could use this "EresourcePackage.eINSTANCE.getCDOResourceNode_Name()" instead of above. - - public static void buildSchema() - { - d_Module top_mod = ObjySchema.getTopModule(); - if (top_mod.resolve_class(ObjyResourceList.className) == null - && top_mod.resolve_proposed_class(ObjyResourceList.className) == null) - { - - if (TRACER_DEBUG.isEnabled()) - { - TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId"); - } - - boolean inProcess = top_mod.proposed_classes().hasNext(); - - // Proposed_Class A = new Proposed_Class(ooArrayListId.ClassName); - Proposed_Class propClass = top_mod.propose_new_class(ObjyResourceList.className); - - propClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, - ObjyBase.CLASS_NAME /* "ooObj" */); - - propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind - d_Access_Kind.d_PUBLIC, // Access kind - ObjyResourceList.Attribute_arrayName, // Attribute name - 1, // # elements in fixed-size array - ObjyArrayListId.className, false); // Default value // Default value - - // top_mod.propose_new_class(A); - if (!inProcess) - { - top_mod.activate_proposals(true, true); - } - - if (TRACER_DEBUG.isEnabled()) - { - TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added"); - } - } - - } - - public ObjyResourceList(ObjySession objySession, ObjyObject objyObject) - { - classObject = objyObject.ooClassObject(); - this.objySession = objySession; - objectId = objyObject.ooId(); - } - - // public OoResourceList(ObjySession objySession, Class_Object classObject) - // { - // this.classObject = classObject; - // this.objySession = objySession; - // } - - private ObjyArrayListId getList() - { - if (list != null) - { - return list; - } - - try - { - Class_Position position = classObject.position_in_class(ObjyResourceList.Attribute_arrayName); - ooId oid = classObject.get_ooId(position); - if (!oid.isNull()) - { - list = new ObjyArrayListId(Class_Object.class_object_from_oid(oid)); - } - } - catch (ObjyRuntimeException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return list; - } - - public void remove(ObjyObject objyObject) - { - int size = (int)getList().size(); - for (int i = 0; i < size; i++) - { - if (objyObject.ooId().equals(getList().get(i))) - { - getList().remove(i); - break; - } - } - } - - public void add(ObjyObject objyObject) - { - // TODO - we need to make sure that objyObject is a resource!!! - getList().add(objyObject.ooId()); - } - - public void checkDuplicateResources(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision) - throws IllegalStateException - { - // CDOID folderID = (CDOID)revision.data().getContainerID(); - CDOID folderId = (CDOID)revision.data().getContainerID(); - String name = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0); - - // ooId folderId = objyObject.getEContainerAsOid(); - // String name = OoResourceList.getResourceName(objyObject); - - // iterate over all resource in the list, and verify if we have both name and folderID. - int size = (int)getList().size(); - for (int i = 0; i < size; i++) - { - ObjyObject resource = getResource(i); - ObjyObject resourceRevision = resource; - // get the proper revision of the resource (might need to refactor this code, see readRevision()) - if (storeAccessor.getStore().isRequiredToSupportBranches()) - { - resourceRevision = resource.getRevision(revision.getTimeStamp(), revision.getBranch().getID()); - } - else if (storeAccessor.getStore().isRequiredToSupportAudits()) - { - resourceRevision = resource.getRevision(revision.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID); - } - - if (resourceRevision == null || resourceRevision.getVersion() < 0) - { - continue; - } - - // int v = resource.getVersion(); - CDOID resourceFolderId = (CDOID)resourceRevision.getEContainer(); - String resourceName = ObjyResourceList.getResourceName(resourceRevision); - if (resourceFolderId != null && resourceFolderId.equals(folderId) && resourceName != null - && resourceName.equals(name)) - { - throw new IllegalStateException("Duplicate resource or folder: " + name + " in folder: " + folderId); //$NON-NLS-1$ - } - } - } - - public ObjyObject getResource(int index) - { - return objySession.getObjectManager().getObject(getList().get(index)); - } - - public static String getResourceName(ObjyObject objyObject) - { - String name = (String)objyObject.get(featureName); - return name; - } - - public static ObjyObject create(ooId nearOid) - { - Class_Object classObject = Class_Object.new_persistent_object(ObjySchema.getObjyClass(ObjyResourceList.className) - .getASClass(), nearOid, false); - Class_Position position = classObject.position_in_class(ObjyResourceList.Attribute_arrayName); - Class_Object arrayClassObject = Class_Object.new_persistent_object( - ObjySchema.getTopModule().resolve_class(ObjyArrayListId.className), classObject.objectID(), false); - // ooId arrayOid = arrayClassObject.objectID(); - - classObject.set_ooId(position, arrayClassObject.objectID()); - ObjyArrayListId.initObject(arrayClassObject); - ObjyObject objyObject = new ObjyObject(classObject); - return objyObject; - } - - public ooId ooId() - { - return objectId; - } - - public int size() - { - return (int)getList().size(); - } - -} +/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObjectManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Class_Position;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Module;
+import com.objy.db.ObjyRuntimeException;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeListX;
+
+/***
+ * OoResouceList is a specialized ooArrayListId, where all elements are of type Resourc(Node|Folder). The class will
+ * allow adding, validating and removing resources From the list.
+ *
+ * @author ibrahim
+ */
+public class ObjyResourceList
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyProxy.class);
+
+ static public String className = "ooResourceList";
+
+ static public String Attribute_arrayName = "oo_array";
+
+ private ObjySession objySession;
+
+ protected Class_Object classObject;
+
+ protected ObjyArrayListId list = null;
+
+ protected ooId objectId;
+
+ private static final EStructuralFeature featureName = EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME;
+
+ // we could use this "EresourcePackage.eINSTANCE.getCDOResourceNode_Name()" instead of above.
+
+ public static void buildSchema()
+ {
+ d_Module top_mod = ObjySchema.getTopModule();
+ if (top_mod.resolve_class(ObjyResourceList.className) == null
+ && top_mod.resolve_proposed_class(ObjyResourceList.className) == null)
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
+ }
+
+ boolean inProcess = top_mod.proposed_classes().hasNext();
+
+ // Proposed_Class A = new Proposed_Class(ooArrayListId.ClassName);
+ Proposed_Class propClass = top_mod.propose_new_class(ObjyResourceList.className);
+
+ propClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC,
+ ObjyBase.CLASS_NAME /* "ooObj" */);
+
+ propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyResourceList.Attribute_arrayName, // Attribute name
+ 1, // # elements in fixed-size array
+ ObjyArrayListId.className, false); // Default value // Default value
+
+ // top_mod.propose_new_class(A);
+ if (!inProcess)
+ {
+ top_mod.activate_proposals(true, true);
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
+ }
+ }
+
+ }
+
+ public ObjyResourceList(ObjySession objySession, ObjyObject objyObject)
+ {
+ classObject = objyObject.ooClassObject();
+ this.objySession = objySession;
+ objectId = objyObject.ooId();
+ }
+
+ // public OoResourceList(ObjySession objySession, Class_Object classObject)
+ // {
+ // this.classObject = classObject;
+ // this.objySession = objySession;
+ // }
+
+ private ObjyArrayListId getList()
+ {
+ if (list != null)
+ {
+ return list;
+ }
+
+ try
+ {
+ Class_Position position = classObject.position_in_class(ObjyResourceList.Attribute_arrayName);
+ ooId oid = classObject.get_ooId(position);
+ if (!oid.isNull())
+ {
+ list = new ObjyArrayListId(Class_Object.class_object_from_oid(oid));
+ }
+ }
+ catch (ObjyRuntimeException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return list;
+ }
+
+ public void remove(ObjyObject objyObject)
+ {
+ int size = (int)getList().size();
+ for (int i = 0; i < size; i++)
+ {
+ if (objyObject.ooId().equals(getList().get(i)))
+ {
+ getList().remove(i);
+ break;
+ }
+ }
+ }
+
+ public void add(ObjyObject objyObject)
+ {
+ // TODO - we need to make sure that objyObject is a resource!!!
+ getList().add(objyObject.ooId());
+ }
+
+ // public void checkDuplicateResources(ObjectivityStoreAccessor storeAccessor, CDORevision revision)
+ // throws IllegalStateException
+ // {
+ // CDOID folderID = (CDOID)revision.data().getContainerID();
+ // String name = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);
+ // CDOID existingID = storeAccessor.readResourceID(folderID, name, revision.getBranch().getHead());
+ // if (existingID != CDOID.NULL && !existingID.equals(revision.getID()))
+ // {
+ // throw new IllegalStateException("Duplicate resource or folder: " + name + " in folder " + folderID); //$NON-NLS-1$ //$NON-NLS-2$
+ // }
+ // }
+
+ public void checkDuplicateResources(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision)
+ throws IllegalStateException
+ {
+ // CDOID folderID = (CDOID)revision.data().getContainerID();
+ CDOID folderId = (CDOID)revision.data().getContainerID();
+ String name = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);
+
+ // ooId folderId = objyObject.getEContainerAsOid();
+ // String name = OoResourceList.getResourceName(objyObject);
+
+ // iterate over all resource in the list, and verify if we have both name and folderID.
+ int size = (int)getList().size();
+ ObjyObjectManager objyObjectManager = storeAccessor.getObjySession().getObjectManager();
+ for (int i = 0; i < size; i++)
+ {
+ ObjyObject resource = getResource(i);
+ ObjyObject resourceRevision = resource;
+ // get the proper revision of the resource (might need to refactor this code, see readRevision())
+ if (storeAccessor.getStore().isRequiredToSupportBranches())
+ {
+ try
+ {
+ resourceRevision = resource.getRevision(revision.getTimeStamp(), revision.getBranch().getID(),
+ objyObjectManager);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ else if (storeAccessor.getStore().isRequiredToSupportAudits())
+ {
+ try
+ {
+ resourceRevision = resource.getRevision(revision.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID, objyObjectManager);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ if (resourceRevision == null || resourceRevision.getVersion() < 0)
+ {
+ continue;
+ }
+
+ // int v = resource.getVersion();
+ CDOID resourceFolderId = (CDOID)resourceRevision.getEContainer();
+ String resourceName = ObjyResourceList.getResourceName(resourceRevision);
+ if (resourceFolderId != null && resourceFolderId.equals(folderId) && resourceName != null
+ && resourceName.equals(name))
+ {
+ throw new IllegalStateException("Duplicate resource or folder: " + name + " in folder: " + folderId); //$NON-NLS-1$
+ }
+ }
+ }
+
+ public ObjyObject getResource(int index)
+ {
+ return objySession.getObjectManager().getObject(getList().get(index));
+ }
+
+ public static String getResourceName(ObjyObject objyObject)
+ {
+ String name = (String)objyObject.get(featureName);
+ return name;
+ }
+
+ public static ObjyObject create(ooId nearOid)
+ {
+ Class_Object classObject = Class_Object.new_persistent_object(ObjySchema.getObjyClass(ObjyResourceList.className)
+ .getASClass(), nearOid, false);
+ // ObjyObjectManager.newInternalObjCount++;
+ Class_Position position = classObject.position_in_class(ObjyResourceList.Attribute_arrayName);
+ // Class_Object arrayClassObject = Class_Object.new_persistent_object(
+ // ObjySchema.getTopModule().resolve_class(ObjyArrayListId.className), classObject.objectID(), false);
+ // // ooId arrayOid = arrayClassObject.objectID();
+ ooTreeListX list = new ooTreeListX(10, false);
+ // ObjyObjectManager.newInternalObjCount++;
+ ooObj anObj = ooObj.create_ooObj(classObject.objectID());
+ anObj.cluster(list);
+ // System.out.println("initObject: " + anObj.getOid().getStoreString() + " treeListX: "
+ // // + list.getOid().getStoreString());
+ classObject.set_ooId(position, list.getOid());
+
+ // classObject.set_ooId(position, arrayClassObject.objectID());
+ // ObjyArrayListId.initObject(arrayClassObject);
+ ObjyObject objyObject = null;
+ try
+ {
+ objyObject = new ObjyObject(classObject);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return objyObject;
+ }
+
+ public ooId ooId()
+ {
+ return objectId;
+ }
+
+ public int size()
+ {
+ return (int)getList().size();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java index 8261564d5b..e3e9369f1a 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java @@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPackageHandler; import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPropertyMapHandler; import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager; +import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager; import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -51,6 +52,10 @@ public class ObjyDb public static final String BRANCHING_CONT_NAME = "BranchingCont"; + public static final String LOCKAREAMANAGER_NAME = "LockAreaManager"; + + public static final String LOCKAREA_CONT_NAME = "LockAreaCont"; + private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyDb.class); // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyDb.class); @@ -182,6 +187,32 @@ public class ObjyDb return objyBranchManager; } + protected static ObjyLockAreaManager createLockAreaManager(ObjyScope objyScope) + { + ObjyLockAreaManager objyLockAreaManager = ObjyLockAreaManager.create(objyScope.getScopeContOid()); + objyScope.nameObj(ObjyDb.LOCKAREAMANAGER_NAME, objyLockAreaManager.getOid()); + return objyLockAreaManager; + } + + public static ObjyLockAreaManager getOrCreateLockAreaManager(String repositoryName) + { + ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.LOCKAREA_CONT_NAME); + ObjyLockAreaManager objyLockAreaManager = null; + try + { + objyLockAreaManager = (ObjyLockAreaManager)objyScope.lookupObject(ObjyDb.LOCKAREAMANAGER_NAME); + } + catch (ObjyRuntimeException ex) + { + objyLockAreaManager = createLockAreaManager(objyScope); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + return objyLockAreaManager; + } + protected static ooId createPackageMap(ObjyScope objyScope) { // TODO - this need refactoring... diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java index eef9336aa8..9eca138e8f 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java @@ -19,7 +19,7 @@ import org.eclipse.emf.ecore.EStructuralFeature; /** * @author Ibrahim Sallam */ -public interface IObjectivityStoreAccessor extends IStoreAccessor +public interface IObjectivityStoreAccessor extends IStoreAccessor.Raw { public IObjectivityStore getStore(); diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreConfig.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreConfig.java index 5feca9eeaf..3832e2f919 100644 --- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreConfig.java +++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreConfig.java @@ -23,4 +23,14 @@ public interface IObjectivityStoreConfig extends Serializable int getSessionMaxCacheSize(); + /** + * @since 4.0 + */ + String getLogPath(); + + /** + * @since 4.0 + */ + int getLogOption(); + } |