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);
		}
Ejemplo n.º 2
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);
			}
		}
Ejemplo n.º 3
0
		private void AppendPayLoad(StatefulBuffer target, Pointer4 pointer, ByteArrayBuffer
			 payLoad)
		{
			target.WriteInt(payLoad.Length());
			target.WriteInt(pointer.Id());
			target.WriteInt(pointer.Address());
			target.Append(payLoad._buffer);
		}
Ejemplo n.º 4
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();
		}
Ejemplo n.º 5
0
		public virtual StatefulBuffer PayLoad()
		{
			StatefulBuffer writer = new StatefulBuffer(Transaction(), Const4.MessageLength);
			writer.WriteInt(_msgID);
			return writer;
		}
Ejemplo n.º 6
0
		internal static void SlotEntryToZeroes(LocalObjectContainer file, int address)
		{
			StatefulBuffer writer = new StatefulBuffer(file.SystemTransaction(), address, SlotLength
				());
			for (int i = 0; i < IntsInSlot; i++)
			{
				writer.WriteInt(0);
			}
			writer.WriteEncrypt();
		}