/// <summary> /// Creates an instance of CachedIoAdapter with a custom page size and page /// count.<br /> /// </summary> /// <param name="ioAdapter">delegate IO adapter (RandomAccessFileAdapter by default)</param> /// <param name="pageSize">cache page size</param> /// <param name="pageCount">allocated amount of pages</param> public CachedIoAdapter(IoAdapter ioAdapter, int pageSize, int pageCount) { // private Hashtable4 _posPageMap = new Hashtable4(PAGE_COUNT); _io = ioAdapter; _pageSize = pageSize; _pageCount = pageCount; }
public LoggingIoAdapter(IoAdapter delegateAdapter, string fileName, int config, TextWriter existingOut) : base(delegateAdapter) { _fileName = fileName; _out = existingOut; _config = config; }
protected virtual void Open(bool readOnly) { if (null != _adapter) { throw new InvalidOperationException(); } _adapter = Factory().Open(TempFile(), false, 0, readOnly); }
protected virtual void Close() { if (null != _adapter) { _adapter.Close(); _adapter = null; } }
public LogReplayer(String logFilePath, IoAdapter io, ISet commands) { _logFilePath = logFilePath; _io = io; _commands = commands; _counts = new Hashtable(); foreach (object com in commands) { _counts[com] = (Int64)0; } }
/// <summary>Creates an instance of CachedIoAdapter with extended parameters.<br /></summary> /// <param name="path">database file path</param> /// <param name="lockFile">determines if the file should be locked</param> /// <param name="initialLength"> /// initial file length, new writes will start from this point /// </param> /// <param name="readOnly"> /// if the file should be used in read-onlyt mode. /// </param> /// <param name="io">delegate IO adapter (RandomAccessFileAdapter by default)</param> /// <param name="pageSize">cache page size</param> /// <param name="pageCount">allocated amount of pages</param> /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> public CachedIoAdapter(string path, bool lockFile, long initialLength, bool readOnly , IoAdapter io, int pageSize, int pageCount) { _readOnly = readOnly; _pageSize = pageSize; _pageCount = pageCount; InitCache(); InitIOAdaptor(path, lockFile, initialLength, readOnly, io); _position = initialLength; _filePointer = initialLength; _fileLength = _io.GetLength(); }
public LoggingIoAdapter(IoAdapter delegateAdapter, string fileName, int config) : base(delegateAdapter) { _fileName = fileName; try { _out = new StreamWriter(new FileStream(fileName, FileMode.Append, FileAccess.Write)); } catch (FileNotFoundException e) { throw new Db4oIOException(e); } _config = config; }
/// <exception cref="IOException"></exception> private void BenchmarkCommand(string command, int itemCount, string dbFileName, TextWriter @out) { HashSet commands = CommandSet(command); Db4objects.Db4o.IO.IoAdapter io = IoAdapter(dbFileName); LogReplayer replayer = new LogReplayer(CrudApplication.LogFileName(itemCount), io , commands); List4 commandList = replayer.ReadCommandList(); StopWatch watch = new StopWatch(); watch.Start(); replayer.PlayCommandList(commandList); watch.Stop(); io.Close(); long timeElapsed = watch.Elapsed(); long operationCount = ((long)replayer.OperationCounts()[command]); PrintStatisticsForCommand(@out, command, timeElapsed, operationCount); }
private void PrepareDbFile(int itemCount) { Sysout("Preparing DB file ..."); DeleteFile(_dbFileName); Db4objects.Db4o.IO.IoAdapter rafFactory = new RandomAccessFileAdapter(); Db4objects.Db4o.IO.IoAdapter raf = rafFactory.Open(_dbFileName, false, 0, false); LogReplayer replayer = new LogReplayer(CrudApplication.LogFileName(itemCount), raf ); try { replayer.ReplayLog(); } catch (IOException) { ExitWithError("Error reading I/O operations log file"); } finally { raf.Close(); } }
public NonFlushingIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter) { }
public IoAdapterStorage(IoAdapter io) { _io = io; }
/// <exception cref="System.Exception"></exception> private void AssertReadWriteString(IoAdapter adapter, string str) { var data = Runtime.GetBytesForString(str); var read = new byte[2048]; adapter.Seek(0); adapter.Write(data); adapter.Seek(0); adapter.Read(read); Assert.AreEqual(str, Runtime.GetStringForBytes(read, 0, data.Length)); }
public DebugIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter) { }
public virtual void Replay(IoAdapter adapter) { adapter.Sync(); }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long initialLength, Delays delays) : this(delegateAdapter.Open(path, lockFile, initialLength , false), delays) { }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> private void InitIOAdaptor(string path, bool lockFile, long initialLength, bool readOnly , IoAdapter io) { _io = io.Open(path, lockFile, initialLength, readOnly); }
/// <summary> /// Creates an instance of CachedIoAdapter with the default page size and /// page count. /// </summary> /// <remarks> /// Creates an instance of CachedIoAdapter with the default page size and /// page count. /// </remarks> /// <param name="ioAdapter">delegate IO adapter (RandomAccessFileAdapter by default)</param> public CachedIoAdapter(IoAdapter ioAdapter) : this(ioAdapter, DefaultPageSize, DefaultPageCount ) { }
public virtual void Replay(IoAdapter adapter) { adapter.Write(PrepareBuffer()); }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> private NonFlushingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile , long initialLength, bool readOnly) : base(delegateAdapter, path, lockFile, initialLength , readOnly) { }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> protected VanillaIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long initialLength, bool readOnly) : this(delegateAdapter.Open(path, lockFile, initialLength , readOnly)) { }
public IoAdapterBin(IoAdapter io) { _io = io; }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long initialLength) : this(delegateAdapter, path, lockFile, initialLength, _delays) { }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> protected DebugIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long initialLength, bool readOnly) : base(delegateAdapter.Open(path, lockFile, initialLength , readOnly)) { }
public VanillaIoAdapter(IoAdapter delegateAdapter) { _delegate = delegateAdapter; }
public void Io(IoAdapter adapter) { GlobalSettingOnly(); Storage = new IoAdapterStorage(adapter); }
/// <exception cref="System.Exception"></exception> private void AssertReadWriteAheadFileEnd(IoAdapter adapter, string str) { var data = Runtime.GetBytesForString(str); var read = new byte[2048]; adapter.Seek(10); var readBytes = adapter.Read(data); Assert.AreEqual(-1, readBytes); Assert.AreEqual(0, adapter.GetLength()); adapter.Seek(0); readBytes = adapter.Read(data); Assert.AreEqual(-1, readBytes); Assert.AreEqual(0, adapter.GetLength()); adapter.Seek(10); adapter.Write(data); Assert.AreEqual(10 + data.Length, adapter.GetLength()); adapter.Seek(0); readBytes = adapter.Read(read); Assert.AreEqual(10 + data.Length, readBytes); adapter.Seek(20 + data.Length); readBytes = adapter.Read(read); Assert.AreEqual(-1, readBytes); adapter.Seek(1024 + data.Length); readBytes = adapter.Read(read); Assert.AreEqual(-1, readBytes); adapter.Seek(1200); adapter.Write(data); adapter.Seek(0); readBytes = adapter.Read(read); Assert.AreEqual(1200 + data.Length, readBytes); }
public DelayingIoAdapter(IoAdapter delegateAdapter, Delays delays) : base(delegateAdapter ) { _delays = delays; _timing = new TicksTiming(); }
private void WriteBytes(IoAdapter io, int numBytes) { io.Write(new byte[numBytes]); }
public LogReplayer(String logFilePath, IoAdapter io): this(logFilePath, io, LogConstants.AllEntries()) { }
private void AssertReadOnly(IoAdapter adapter) { Assert.Expect(typeof (Db4oIOException), new _ICodeBlock_21(adapter)); }
public virtual void Replay(IoAdapter adapter) { adapter.Read(PrepareBuffer(), _length); }
public _ICodeBlock_21(IoAdapter adapter) { this.adapter = adapter; }