Exemplo n.º 1
0
 /// <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;
 }
Exemplo n.º 2
0
 /// <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;
 }
Exemplo n.º 3
0
 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;
			}
		}
Exemplo n.º 6
0
 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;
     }
 }
Exemplo n.º 7
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();
 }
Exemplo n.º 8
0
		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;
		}
Exemplo n.º 9
0
        /// <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);
        }
Exemplo n.º 10
0
        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)
 {
 }
Exemplo n.º 12
0
 public IoAdapterStorage(IoAdapter io)
 {
     _io = io;
 }
Exemplo n.º 13
0
 /// <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));
 }
Exemplo n.º 14
0
		public DebugIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter)
		{
		}
Exemplo n.º 15
0
 public DebugIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter)
 {
 }
Exemplo n.º 16
0
		public virtual void Replay(IoAdapter adapter)
		{
			adapter.Sync();
		}
Exemplo n.º 17
0
		/// <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)
		{
		}
Exemplo n.º 18
0
 /// <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);
 }
Exemplo n.º 19
0
 /// <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
                                                    )
 {
 }
Exemplo n.º 20
0
		public virtual void Replay(IoAdapter adapter)
		{
			adapter.Write(PrepareBuffer());
		}
Exemplo n.º 21
0
		/// <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)
		{
		}
Exemplo n.º 22
0
		public NonFlushingIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter)
		{
		}
Exemplo n.º 23
0
 /// <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))
 {
 }
Exemplo n.º 24
0
		public IoAdapterStorage(IoAdapter io)
		{
			_io = io;
		}
Exemplo n.º 25
0
 /// <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
     )
 {
 }
Exemplo n.º 26
0
			public IoAdapterBin(IoAdapter io)
			{
				_io = io;
			}
Exemplo n.º 27
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();
 }
Exemplo n.º 28
0
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long
			 initialLength) : this(delegateAdapter, path, lockFile, initialLength, _delays)
		{
		}
Exemplo n.º 29
0
 /// <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))
 {
 }
Exemplo n.º 30
0
 public VanillaIoAdapter(IoAdapter delegateAdapter)
 {
     _delegate = delegateAdapter;
 }
Exemplo n.º 31
0
		/// <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))
		{
		}
Exemplo n.º 32
0
		public void Io(IoAdapter adapter)
		{
			GlobalSettingOnly();
			Storage = new IoAdapterStorage(adapter);
		}
Exemplo n.º 33
0
 /// <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);
 }
Exemplo n.º 34
0
		public DelayingIoAdapter(IoAdapter delegateAdapter, Delays delays) : base(delegateAdapter
			)
		{
			_delays = delays;
			_timing = new TicksTiming();
		}
Exemplo n.º 35
0
 public IoAdapterBin(IoAdapter io)
 {
     _io = io;
 }
Exemplo n.º 36
0
		private void WriteBytes(IoAdapter io, int numBytes)
		{
			io.Write(new byte[numBytes]);
		}
 /// <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)
 {
 }
Exemplo n.º 38
0
 /// <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);
 }
Exemplo n.º 39
0
 public LogReplayer(String logFilePath, IoAdapter io): this(logFilePath, io, LogConstants.AllEntries())
 {
     
 }
Exemplo n.º 40
0
 public VanillaIoAdapter(IoAdapter delegateAdapter)
 {
     _delegate = delegateAdapter;
 }
Exemplo n.º 41
0
 /// <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))
 {
 }
Exemplo n.º 42
0
 private void AssertReadOnly(IoAdapter adapter)
 {
     Assert.Expect(typeof (Db4oIOException), new _ICodeBlock_21(adapter));
 }
Exemplo n.º 43
0
		public virtual void Replay(IoAdapter adapter)
		{
			adapter.Read(PrepareBuffer(), _length);
		}
Exemplo n.º 44
0
 public _ICodeBlock_21(IoAdapter adapter)
 {
     this.adapter = adapter;
 }