/// <summary>Mark te transaction file as committed</summary> /// <param name="isConfirmed"></param> private void SetCommited(bool isConfirmed) { this.isCommited = isConfirmed; CheckFileAccess(true); try { // TODO Check atomicity // Writes the number of write actions after the byte and date fsi.SetWritePositionNoVerification(NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.Byte .GetSize() + NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.Long.GetSize(), false); fsi.WriteLong(numberOfWriteActions, false, "nb write actions", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction .DirectWriteAction); // FIXME The fsi.flush should not be called after the last write? fsi.Flush(); // Only set useBuffer = false when it is a local database to avoid // net io overhead if (isLocal) { fsi.UseBuffer(false); } fsi.SetWritePositionNoVerification(0, false); fsi.WriteByte((byte)1, false); } finally { } }
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 { } }