Esempio n. 1
0
 protected virtual void ManageFullCache()
 {
     if (OdbConfiguration.AutomaticallyIncreaseCacheSize())
     {
         OdbConfiguration.SetMaxNumberOfObjectInCache((long)(OdbConfiguration
                                                             .GetMaxNumberOfObjectInCache() * 1.2));
     }
 }
Esempio n. 2
0
 /// <summary>Only adds the Object info - used for non committed objects</summary>
 public virtual void AddObjectInfo(ObjectInfoHeader objectInfoHeader)
 {
     if (objectInfoHeader.GetOid() == null)
     {
         throw new ODBRuntimeException(NeoDatisError.CacheNullOid);
     }
     if (objectInfoHeader.GetClassInfoId() == null)
     {
         throw new ODBRuntimeException(NeoDatisError.CacheObjectInfoHeaderWithoutClassId.AddParameter(objectInfoHeader.GetOid()));
     }
     // TODO : Should remove first inserted object and not clear all cache
     if (objectInfoPointersCacheFromOid.Count > OdbConfiguration.GetMaxNumberOfObjectInCache())
     {
         ManageFullCache();
     }
     objectInfoPointersCacheFromOid[objectInfoHeader.GetOid()] = objectInfoHeader;
     // For monitoring purpose
     nbObjects = objects.Count;
     nbOids    = oids.Count;
     nbOih     = objectInfoPointersCacheFromOid.Count;
 }
Esempio n. 3
0
        public virtual void AddObject(OID oid, object o, ObjectInfoHeader objectInfoHeader)
        {
            if (oid == null)
            {
                throw new ODBRuntimeException(NeoDatisError.CacheNullOid);
            }
            if (CheckHeaderPosition() && objectInfoHeader.GetPosition() == -1)
            {
                throw new ODBRuntimeException(NeoDatisError.CacheNegativePosition
                                              .AddParameter("Adding OIH with position = -1"));
            }
            // TODO : Should remove first inserted object and not clear all cache
            if (objects.Count > OdbConfiguration.GetMaxNumberOfObjectInCache())
            {
                // clear();
                ManageFullCache();
            }

            oids[oid] = o;
            try
            {
                objects[o] = oid;
            }
            catch (System.ArgumentNullException)
            {
            }
            // FIXME URL in HashMap What should we do?
            // In some case, the object can throw exception when added to the
            // cache
            // because Map.put, end up calling the equals method that can throw
            // exception
            // This is the case of URL that has a transient attribute handler
            // that is used in the URL.equals method
            objectInfoPointersCacheFromOid[oid] = objectInfoHeader;
            // For monitoring purpose
            nbObjects = objects.Count;
            nbOids    = oids.Count;
            nbOih     = objectInfoPointersCacheFromOid.Count;
        }