Exemplo n.º 1
0
        public override void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread
                                            , bool shuttingDown, StatefulBuffer writer, int blockSize)
        {
            SystemData systemData = file.SystemData();

            writer.Append(Signature);
            writer.WriteByte(Version());
            writer.WriteInt((int)TimeToWrite(_timerFileLock.OpenTime(), shuttingDown));
            writer.WriteLong(TimeToWrite(_timerFileLock.OpenTime(), shuttingDown));
            writer.WriteLong(TimeToWrite(Runtime.CurrentTimeMillis(), shuttingDown));
            writer.WriteInt(blockSize);
            writer.WriteInt(systemData.ClassCollectionID());
            writer.WriteByte(systemData.IdSystemType());
            writer.WriteInt(((FileHeaderVariablePart2)_variablePart).Address());
            writer.WriteInt(((FileHeaderVariablePart2)_variablePart).Length());
            writer.WriteInt(_transactionPointerAddress);
            writer.Write();
            if (shuttingDown)
            {
                WriteVariablePart(file, true);
            }
            else
            {
                file.SyncFiles();
            }
            if (startFileLockingThread)
            {
                file.ThreadPool().Start("db4o lock thread", _timerFileLock);
            }
        }
Exemplo n.º 2
0
 public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount
                                       , Slot reservedSlot)
 {
     if (slotChangeCount > 0)
     {
         Slot transactionLogSlot = SlotLongEnoughForLog(slotChangeCount, reservedSlot) ? reservedSlot
                                  : AllocateSlot(true, slotChangeCount);
         StatefulBuffer buffer = new StatefulBuffer(_container.SystemTransaction(), transactionLogSlot
                                                    );
         buffer.WriteInt(transactionLogSlot.Length());
         buffer.WriteInt(slotChangeCount);
         AppendSlotChanges(buffer, slotChangeTree);
         buffer.Write();
         IRunnable commitHook = _container.CommitHook();
         FlushDatabaseFile();
         _container.WriteTransactionPointer(transactionLogSlot.Address());
         FlushDatabaseFile();
         if (WriteSlots(slotChangeTree))
         {
             FlushDatabaseFile();
         }
         _container.WriteTransactionPointer(0);
         commitHook.Run();
         FlushDatabaseFile();
         if (transactionLogSlot != reservedSlot)
         {
             FreeSlot(transactionLogSlot);
         }
     }
     FreeSlot(reservedSlot);
 }
Exemplo n.º 3
0
        protected virtual void WriteTransactionPointer(Transaction systemTransaction, int
                                                       transactionPointer, int address, int offset)
        {
            StatefulBuffer bytes = new StatefulBuffer(systemTransaction, address, TransactionPointerLength
                                                      );

            bytes.MoveForward(offset);
            bytes.WriteInt(transactionPointer);
            bytes.WriteInt(transactionPointer);
            // Dangerous write.
            // On corruption transaction pointers will not be the same and nothing will happen.
            bytes.Write();
        }
 public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount
     , Slot reservedSlot)
 {
     if (slotChangeCount > 0)
     {
         var transactionLogSlot = SlotLongEnoughForLog(slotChangeCount, reservedSlot)
             ? reservedSlot
             : AllocateSlot(true, slotChangeCount);
         var buffer = new StatefulBuffer(_container.SystemTransaction(), transactionLogSlot
             );
         buffer.WriteInt(transactionLogSlot.Length());
         buffer.WriteInt(slotChangeCount);
         AppendSlotChanges(buffer, slotChangeTree);
         buffer.Write();
         var commitHook = _container.CommitHook();
         FlushDatabaseFile();
         _container.WriteTransactionPointer(transactionLogSlot.Address());
         FlushDatabaseFile();
         if (WriteSlots(slotChangeTree))
         {
             FlushDatabaseFile();
         }
         _container.WriteTransactionPointer(0);
         commitHook.Run();
         FlushDatabaseFile();
         if (transactionLogSlot != reservedSlot)
         {
             FreeSlot(transactionLogSlot);
         }
     }
     FreeSlot(reservedSlot);
 }
Exemplo n.º 5
0
 protected virtual void WriteTransactionPointer(Transaction systemTransaction, int
     transactionPointer, int address, int offset)
 {
     var bytes = new StatefulBuffer(systemTransaction, address, TransactionPointerLength
         );
     bytes.MoveForward(offset);
     bytes.WriteInt(transactionPointer);
     bytes.WriteInt(transactionPointer);
     // Dangerous write. 
     // On corruption transaction pointers will not be the same and nothing will happen.
     bytes.Write();
 }
Exemplo n.º 6
0
 public override void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread
     , bool shuttingDown, StatefulBuffer writer, int blockSize)
 {
     var systemData = file.SystemData();
     writer.Append(Signature);
     writer.WriteByte(Version());
     writer.WriteInt((int) TimeToWrite(_timerFileLock.OpenTime(), shuttingDown));
     writer.WriteLong(TimeToWrite(_timerFileLock.OpenTime(), shuttingDown));
     writer.WriteLong(TimeToWrite(Runtime.CurrentTimeMillis(), shuttingDown));
     writer.WriteInt(blockSize);
     writer.WriteInt(systemData.ClassCollectionID());
     writer.WriteByte(systemData.IdSystemType());
     writer.WriteInt(((FileHeaderVariablePart2) _variablePart).Address());
     writer.WriteInt(((FileHeaderVariablePart2) _variablePart).Length());
     writer.WriteInt(_transactionPointerAddress);
     writer.Write();
     if (shuttingDown)
     {
         WriteVariablePart(file, true);
     }
     else
     {
         file.SyncFiles();
     }
     if (startFileLockingThread)
     {
         file.ThreadPool().Start("db4o lock thread", _timerFileLock);
     }
 }