private void Connect() { const int retryCount = 20; // With 20 retries we'll wait at most 11 seconds until fail. var exceptions = new Stack <Exception>(); _client = null; long timeToWait = 100; for (var i = 0; i < retryCount; ++i) { try { var clientConfiguration = Db4oClientServerLegacyConfigurationBridge.AsClientConfiguration(Config()); _client = Db4oClientServer.OpenClient(clientConfiguration, "localhost", Port, USER_NAME, USER_PWD); return; } catch (Exception e) { if (NotTheSameAsLast(e, exceptions)) { exceptions.Push(e); } } Runtime4.Sleep(timeToWait); if (i == 10) { timeToWait = 1000; } } FailConnect(retryCount, exceptions); }
/// <exception cref="System.Exception"></exception> protected virtual void WaitForAllTasksDone() { while (!AreAllTasksDone()) { Runtime4.Sleep(1); } }
public override void Run() { while (NotStopped()) { _dispatcher.Write(Msg.Ping); Runtime4.Sleep(1); } }
public virtual void TestKeptAliveClient() { ClientTimeOutTestCase.Item item = new ClientTimeOutTestCase.Item("one"); Store(item); Runtime4.Sleep(Timeout * 2); Assert.AreSame(item, ((ClientTimeOutTestCase.Item)RetrieveOnlyInstance(typeof(ClientTimeOutTestCase.Item )))); }
public virtual void EnsureStarted() { _thread.Start(); while (!IsRunning()) { Runtime4.Sleep(10); } Runtime4.Sleep(10); }
/// <exception cref="System.Exception"></exception> public virtual void _test() { ObjectServerImpl serverImpl = (ObjectServerImpl)ClientServerFixture().Server(); IEnumerator iter = serverImpl.IterateDispatchers(); iter.MoveNext(); IServerMessageDispatcher serverDispatcher = (IServerMessageDispatcher)iter.Current; IClientMessageDispatcher clientDispatcher = ((ClientObjectContainer)Db()).MessageDispatcher (); clientDispatcher.Close(); Runtime4.Sleep(1000); Assert.IsFalse(serverDispatcher.IsMessageDispatcherAlive()); }
public void OnMessage(Msg msg) { if (msg is MQueryExecute) { this._enclosing.processingMessage = true; barrier.Add(new object()); Runtime4.Sleep(500); this._enclosing.processingMessage = false; } else { if (msg is MIsAlive) { Assert.IsFalse(this._enclosing.processingMessage); } } }
public void Run() { lock (this._enclosing._lock) { this._enclosing.CheckClosed(); if (this._enclosing._backupFile != null) { throw new BackupInProgressException(); } this._enclosing._backupFile = new BlockAwareBin(targetStorage.Open(new BinConfiguration (path, true, this._enclosing._file.Length(), false, this._enclosing._blockConverter .BlocksToBytes(1)))); } long pos = 0; byte[] buffer = new byte[8192]; while (true) { lock (this._enclosing._lock) { int read = this._enclosing._file.Read(pos, buffer); if (read <= 0) { break; } this._enclosing._backupFile.Write(pos, buffer, read); pos += read; } // Let the database engine continue to do // some work if it likes to. Runtime4.Sleep(1); } lock (this._enclosing._lock) { try { Db4objects.Db4o.Internal.IoAdaptedObjectContainer.SyncAndClose(this._enclosing._backupFile ); } finally { this._enclosing._backupFile = null; } } }
public virtual void Run() { try { for (var i = 0; i < NumIterations; i++) { Exercise(_db); Runtime4.Sleep(1); } } catch (Exception ex) { lock (_exceptions) { _exceptions.Add(ex); } } }
/// <exception cref="System.Exception"></exception> public virtual void Test() { IExtObjectContainer db = Fixture().Db(); ObjectServerImpl serverImpl = (ObjectServerImpl)ClientServerFixture().Server(); try { IEnumerator iter = serverImpl.IterateDispatchers(); iter.MoveNext(); ServerMessageDispatcherImpl serverDispatcher = (ServerMessageDispatcherImpl)iter. Current; serverDispatcher.Socket().Close(); Runtime4.Sleep(1000); Assert.Expect(typeof(DatabaseClosedException), new _ICodeBlock_30(db)); Assert.IsTrue(db.IsClosed()); } finally { serverImpl.Close(); } }
public virtual void Conc(IExtObjectContainer oc, int seq) { EventRegistry(oc).Committed += new System.EventHandler <Db4objects.Db4o.Events.CommitEventArgs> (new _IEventListener4_74(oc).OnEvent); CommittedCallbackRefreshTestCase.Item[] items = new CommittedCallbackRefreshTestCase.Item [Count]; IObjectSet objectSet = NewQuery(typeof(CommittedCallbackRefreshTestCase.Item)).Execute (); int count = 0; while (objectSet.HasNext()) { lock (_lock) { items[count] = (CommittedCallbackRefreshTestCase.Item)objectSet.Next(); items[count].Check(); count++; } } for (int i = 0; i < items.Length; i++) { lock (_lock) { items[i].Update(); Store(items[i]._subItem); Store(items[i]); } Db().Commit(); } Runtime4.Sleep(1000); for (int i = 0; i < items.Length; i++) { lock (_lock) { items[i].Check(); } } Runtime4.Sleep(3000); }
public virtual void Conc(IExtObjectContainer oc, int seq) { EventRegistry(oc).Committed += new _IEventListener4_74(oc).OnEvent; var items = new Item [Count]; var objectSet = NewQuery(typeof(Item)).Execute (); var count = 0; while (objectSet.HasNext()) { lock (_lock) { items[count] = (Item)objectSet.Next(); items[count].Check(); count++; } } for (var i = 0; i < items.Length; i++) { lock (_lock) { items[i].Update(); Store(items[i]._subItem); Store(items[i]); } Db().Commit(); } Runtime4.Sleep(1000); for (var i = 0; i < items.Length; i++) { lock (_lock) { items[i].Check(); } } Runtime4.Sleep(3000); }
public virtual void ProcessMessage(IMessageContext con, object message) { _clientWasBlocked = true; Runtime4.Sleep(Timeout * 3); }
public virtual void ProcessMessage(IMessageContext con, object message) { Runtime4.Sleep(3000); }