public override void Open(IFile file, int cacheSizeInBytes) { acceptor = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); acceptor.Bind(new IPEndPoint(IPAddress.Any, port)); acceptor.Listen(ListenQueueSize); if (file.Length > 0) { byte[] rootPage = new byte[Page.pageSize]; try { file.Read(0, rootPage); prevIndex = rootPage[DB_HDR_CURR_INDEX_OFFSET]; initialized = rootPage[DB_HDR_INITIALIZED_OFFSET] != 0; } catch (DatabaseException) { initialized = false; prevIndex = -1; } } else { prevIndex = -1; initialized = false; } this.file = file; lck = new PersistentResource(); init = new object(); done = new object(); commit = new object(); listening = true; connect(); pool = new PagePool(cacheSizeInBytes / Page.pageSize); pool.open(file); thread = new Thread(new ThreadStart(run)); thread.Name = "ReplicationSlaveStorageImpl"; thread.Start(); WaitInitializationCompletion(); base.Open(file, cacheSizeInBytes); }
public override void Open(IFile file, int cacheSizeInBytes) { acceptor = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); acceptor.Bind(new IPEndPoint(IPAddress.Any, port)); acceptor.Listen(ListenQueueSize); if (file.Length > 0) { byte[] rootPage = new byte[Page.pageSize]; try { file.Read(0, rootPage); prevIndex = rootPage[DB_HDR_CURR_INDEX_OFFSET]; initialized = rootPage[DB_HDR_INITIALIZED_OFFSET] != 0; } catch (DatabaseException) { initialized = false; prevIndex = -1; } } else { prevIndex = -1; initialized = false; } this.file = file; lck = new PersistentResource(); init = new object(); done = new object(); commit = new object(); listening = true; connect(); pool = new PagePool(cacheSizeInBytes / Page.pageSize); pool.open(file); thread = new Thread(new ThreadStart(run)); thread.Name = "ReplicationSlaveStorageImpl"; thread.Start(); WaitInitializationCompletion(); base.Open(file, cacheSizeInBytes); }