Exemplo n.º 1
0
        private void ApplyTo()
        {
            int realWriteNumber = 0;
            int noPointerWA     = 0;

            if (!isCommited)
            {
                NeoDatis.Tool.DLogger.Info("can not execute a transaction that is not confirmed");
                return;
            }
            if (hasAllWriteActionsInMemory)
            {
                for (int i = 0; i < writeActions.Count; i++)
                {
                    NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction wa = (NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
                                                                                )writeActions[i];
                    wa.ApplyTo(fsiToApplyWriteActions, i + 1);
                    wa.Clear();
                }
                fsiToApplyWriteActions.Flush();
            }
            else
            {
                LoadWriteActions(true);
                fsiToApplyWriteActions.Flush();
            }
        }
Exemplo n.º 2
0
 /// <summary>Adds a write action to the transaction</summary>
 /// <param name="writeAction">The write action to be added</param>
 /// <param name="persistWriteAcion">To indicate if write action must be persisted</param>
 public virtual void AddWriteAction(NeoDatis.Odb.Core.Transaction.IWriteAction writeAction
                                    , bool persistWriteAcion)
 {
     if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
     {
         NeoDatis.Tool.DLogger.Info("Adding WA in Transaction of session " + session.GetId
                                        ());
     }
     if (writeAction.IsEmpty())
     {
         return;
     }
     CheckRollback();
     if (!hasBeenPersisted && persistWriteAcion)
     {
         Persist();
     }
     if (persistWriteAcion)
     {
         writeAction.Persist(fsi, numberOfWriteActions + 1);
     }
     // Only adds the writeaction to the list if the transaction keeps all in
     // memory
     if (hasAllWriteActionsInMemory)
     {
         writeActions.Add(writeAction);
     }
     numberOfWriteActions++;
     if (hasAllWriteActionsInMemory && numberOfWriteActions > NeoDatis.Odb.OdbConfiguration
         .GetMaxNumberOfWriteObjectPerTransaction())
     {
         hasAllWriteActionsInMemory = false;
         System.Collections.IEnumerator iterator = writeActions.GetEnumerator();
         NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction wa = null;
         while (iterator.MoveNext())
         {
             wa = (NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction)iterator.Current;
             wa.Clear();
         }
         writeActions.Clear();
         if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
         {
             NeoDatis.Tool.DLogger.Info("Number of objects has exceeded the max number " + numberOfWriteActions
                                        + "/" + NeoDatis.Odb.OdbConfiguration.GetMaxNumberOfWriteObjectPerTransaction()
                                        + ": switching to persistent transaction managment");
         }
     }
 }
Exemplo n.º 3
0
 public virtual void LoadWriteActions(string filename, bool apply)
 {
     if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
     {
         NeoDatis.Tool.DLogger.Debug("Load write actions of " + filename);
     }
     NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction wa = null;
     try
     {
         CheckFileAccess(false, filename);
         fsi.UseBuffer(true);
         fsi.SetReadPosition(0);
         isCommited       = fsi.ReadByte() == 1;
         creationDateTime = fsi.ReadLong();
         long totalNumberOfWriteActions = fsi.ReadLong();
         if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
         {
             NeoDatis.Tool.DLogger.Info(writeActions.Count + " write actions in file");
         }
         for (int i = 0; i < totalNumberOfWriteActions; i++)
         {
             wa = NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.Read(fsi, i + 1);
             if (apply)
             {
                 wa.ApplyTo(fsiToApplyWriteActions, i + 1);
                 wa.Clear();
             }
             else
             {
                 AddWriteAction(wa, false);
             }
         }
         if (apply)
         {
             fsiToApplyWriteActions.Flush();
         }
     }
     finally
     {
     }
 }