Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
0
 public void WriteInt(int aInt)
 {
     _payLoad.WriteInt(aInt);
 }
 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.º 4
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.º 5
0
 internal static void SlotEntryToZeroes(LocalObjectContainer file, int address)
 {
     var writer = new StatefulBuffer(file.SystemTransaction(), address, SlotLength
         ());
     for (var i = 0; i < IntsInSlot; i++)
     {
         writer.WriteInt(0);
     }
     writer.WriteEncrypt();
 }