internal void ApplyTo(IFileSystemInterface fsi) { fsi.SetWritePosition(_position, false); foreach (var bytes in _listOfBytes) fsi.WriteBytes(bytes, false); }
protected override void Establish_context() { _position = 3L; _data = new byte[] { 1, 2, 3 }; _fsi = new FileSystemInterfaceFake(); }
internal void PersistMeTo(IFileSystemInterface fsi) { var sizeOfLong = OdbType.Long.Size; var sizeOfInt = OdbType.Integer.Size; // build the full byte array to write once var bytes = new byte[sizeOfLong + sizeOfInt + _size]; var bytesOfPosition = ByteArrayConverter.LongToByteArray(_position); var bytesOfSize = ByteArrayConverter.IntToByteArray(_size); for (var i = 0; i < sizeOfLong; i++) bytes[i] = bytesOfPosition[i]; var offset = sizeOfLong; for (var i = 0; i < sizeOfInt; i++) { bytes[offset] = bytesOfSize[i]; offset++; } foreach (var tmp in _listOfBytes) { Buffer.BlockCopy(tmp, 0, bytes, offset, tmp.Length); offset += tmp.Length; } fsi.WriteBytes(bytes, false); }
internal void PersistMeTo(IFileSystemInterface fsi) { var sizeOfLong = OdbType.Long.Size; var sizeOfInt = OdbType.Integer.Size; // build the full byte array to write once var bytes = new byte[sizeOfLong + sizeOfInt + _size]; var bytesOfPosition = ByteArrayConverter.LongToByteArray(_position); var bytesOfSize = ByteArrayConverter.IntToByteArray(_size); for (var i = 0; i < sizeOfLong; i++) { bytes[i] = bytesOfPosition[i]; } var offset = sizeOfLong; for (var i = 0; i < sizeOfInt; i++) { bytes[offset] = bytesOfSize[i]; offset++; } foreach (var tmp in _listOfBytes) { Buffer.BlockCopy(tmp, 0, bytes, offset, tmp.Length); offset += tmp.Length; } fsi.WriteBytes(bytes, false); }
public override void SetFileSystemInterfaceToApplyTransaction(IFileSystemInterface fsi) { _fsiToApplyTransaction = fsi; if (_transaction != null) { _transaction.SetFsiToApplyWriteActions(_fsiToApplyTransaction); } }
internal void ApplyTo(IFileSystemInterface fsi) { fsi.SetWritePosition(_position, false); foreach (var bytes in _listOfBytes) { fsi.WriteBytes(bytes, false); } }
internal static WriteAction Read(IFileSystemInterface fsi) { try { var position = fsi.ReadLong(); var size = fsi.ReadInt(); var bytes = fsi.ReadBytes(size); var writeAction = new WriteAction(position, bytes); Log4NetHelper.Instance.LogDebugMessage(string.Format("Transaction WriteAction: Loading Write Action at {0} => {1}", fsi.GetPosition(), writeAction)); return(writeAction); } catch (OdbRuntimeException) { Log4NetHelper.Instance.LogErrorMessage(string.Format("Transaction WriteAction: error reading write action at position {0}", fsi.GetPosition())); throw; } }
internal static WriteAction Read(IFileSystemInterface fsi) { try { var position = fsi.ReadLong(); var size = fsi.ReadInt(); var bytes = fsi.ReadBytes(size); var writeAction = new WriteAction(position, bytes); if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug(string.Format("Transaction WriteAction: Loading Write Action at {0} => {1}", fsi.GetPosition(), writeAction)); } return(writeAction); } catch (OdbRuntimeException) { DLogger.Error(string.Format("Transaction WriteAction: error reading write action at position {0}", fsi.GetPosition())); throw; } }
private void CheckFileAccess(string fileName) { lock (this) { if (_fsi != null) { return; } IDbIdentification parameters; if (_fsiToApplyWriteActions.GetFileIdentification() is InMemoryIdentification) { parameters = GetParameters(); } else { parameters = _fsiToApplyWriteActions == null ? new FileIdentification(fileName) : GetParameters(); } _fsi = new FileSystemInterface(parameters, MultiBuffer.DefaultBufferSizeForTransaction, _session); } }
public abstract void SetFileSystemInterfaceToApplyTransaction(IFileSystemInterface fsi);
public OdbTransaction(ISession session, IFileSystemInterface fsiToApplyTransaction) { _fsiToApplyWriteActions = fsiToApplyTransaction; Init(session); }
public FileSystemReader(IStorageEngine engine) { _storageEngine = engine; _fsi = engine.GetObjectWriter().FileSystemProcessor.FileSystemInterface; }
/// <summary> /// Reset the transaction /// </summary> public void Reset() { Clear(); Init(_session); _fsi = null; }
public void BuildFileSystemInterface(IStorageEngine storageEngine, ISession session) { FileSystemInterface = new FileSystemInterface(storageEngine.GetBaseIdentification(), MultiBuffer.DefaultBufferSizeForData, session); }
internal static WriteAction Read(IFileSystemInterface fsi) { try { var position = fsi.ReadLong(); var size = fsi.ReadInt(); var bytes = fsi.ReadBytes(size); var writeAction = new WriteAction(position, bytes); if (OdbConfiguration.IsLoggingEnabled()) DLogger.Debug(string.Format("Transaction WriteAction: Loading Write Action at {0} => {1}", fsi.GetPosition(), writeAction)); return writeAction; } catch (OdbRuntimeException) { DLogger.Error(string.Format("Transaction WriteAction: error reading write action at position {0}", fsi.GetPosition())); throw; } }
public void SetFsiToApplyWriteActions(IFileSystemInterface fsi) { _fsiToApplyWriteActions = fsi; }
public PackageUpdater(IFileSystemInterface fileInterface) { this.fileInterface = fileInterface; }
public void Close() { FileSystemInterface.Close(); FileSystemInterface = null; }
public override void SetFileSystemInterfaceToApplyTransaction(IFileSystemInterface fsi) { }
public override void SetFileSystemInterfaceToApplyTransaction(IFileSystemInterface fsi) { _fsiToApplyTransaction = fsi; if (_transaction != null) _transaction.SetFsiToApplyWriteActions(_fsiToApplyTransaction); }
/// <exception cref="System.IO.IOException"></exception> public virtual void Write(IFileSystemInterface fsi, bool writeInTransaction) { fsi.WriteInt(1, writeInTransaction); }
public void Commit() { if (OdbConfiguration.IsLoggingEnabled()) { var numberOfWriteActionsAsString = _numberOfWriteActions.ToString(); var hasAllWriteActionsInMemoryAsString = _hasAllWriteActionsInMemory.ToString(); DLogger.Info("OdbTransaction: Commiting " + numberOfWriteActionsAsString + " write actions - In Memory : " + hasAllWriteActionsInMemoryAsString + string.Format(" - sid={0}", _session.GetId())); } // Check if database has been rollbacked CheckRollback(); // call the commit listeners ManageCommitListenersBefore(); if (_currentWriteAction != null && !_currentWriteAction.IsEmpty()) { AddWriteAction(_currentWriteAction, true); _currentWriteAction = null; } if (_fsi == null && _numberOfWriteActions != 0) { throw new OdbRuntimeException(NDatabaseError.TransactionAlreadyCommitedOrRollbacked); } if (_numberOfWriteActions == 0) { // FIXME call commitMetaModel in realOnlyMode? CommitMetaModel(); // Nothing to do if (_fsi != null) { _fsi.Close(); _fsi = null; } if (_session != null) { _session.GetCache().ClearOnCommit(); } return; } // Marks the transaction as committed SetCommited(); // Apply the write actions the main database file ApplyTo(); // Commit Meta Model changes CommitMetaModel(); if (_fsi != null) { _fsi.Close(); _fsi = null; } if (_session != null) { _session.GetCache().ClearOnCommit(); } ManageCommitListenersAfter(); }
public ProjectUpdater(IFileSystemInterface fileInterface) { this.fileInterface = fileInterface; }
public TemplateManager(string templateDirectory, IFileSystemInterface fileSystemInterface) { this.templateDirectory = templateDirectory; this.fileSystemInterface = fileSystemInterface; this.fileSystemInterface.CreateDirectory(this.templateDirectory); }
public void Commit() { if (OdbConfiguration.IsLoggingEnabled()) { var numberOfWriteActionsAsString = _numberOfWriteActions.ToString(); var hasAllWriteActionsInMemoryAsString = _hasAllWriteActionsInMemory.ToString(); DLogger.Info("OdbTransaction: Commiting " + numberOfWriteActionsAsString + " write actions - In Memory : " + hasAllWriteActionsInMemoryAsString + string.Format(" - sid={0}", _session.GetId())); } // Check if database has been rollbacked CheckRollback(); // call the commit listeners ManageCommitListenersBefore(); if (_currentWriteAction != null && !_currentWriteAction.IsEmpty()) { AddWriteAction(_currentWriteAction, true); _currentWriteAction = null; } if (_fsi == null && _numberOfWriteActions != 0) throw new OdbRuntimeException(NDatabaseError.TransactionAlreadyCommitedOrRollbacked); if (_numberOfWriteActions == 0) { // FIXME call commitMetaModel in realOnlyMode? CommitMetaModel(); // Nothing to do if (_fsi != null) { _fsi.Close(); _fsi = null; } if (_session != null) _session.GetCache().ClearOnCommit(); return; } // Marks the transaction as committed SetCommited(); // Apply the write actions the main database file ApplyTo(); // Commit Meta Model changes CommitMetaModel(); if (_fsi != null) { _fsi.Close(); _fsi = null; } if (_session != null) _session.GetCache().ClearOnCommit(); ManageCommitListenersAfter(); }
private void CheckFileAccess(string fileName) { lock (this) { if (_fsi != null) return; IDbIdentification parameters; if (_fsiToApplyWriteActions.GetFileIdentification() is InMemoryIdentification) { parameters = GetParameters(); } else { parameters = _fsiToApplyWriteActions == null ? new FileIdentification(fileName) : GetParameters(); } _fsi = new FileSystemInterface(parameters, MultiBuffer.DefaultBufferSizeForTransaction, _session); } }