public void Test3(ref int op) { Console.WriteLine("Test 3: Testing 1000 puts and 1 get with 1000 " + "results with the same key."); RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] key = new byte[10]; byte[] value = new byte[value_size]; rng.GetBytes(key); ArrayList al_results = new ArrayList(); BlockingQueue[] results_queue = new BlockingQueue[60]; for (int i = 0; i < 60; i++) { value = new byte[value_size]; rng.GetBytes(value); al_results.Add(value); results_queue[i] = new BlockingQueue(); default_dht.AsyncPut(key, value, 3000, results_queue[i]); } for (int i = 0; i < 60; i++) { try { bool res = (bool)results_queue[i].Dequeue(); Console.WriteLine("success in put : " + i); } catch { Console.WriteLine("Failure in put : " + i); } } Console.WriteLine("Insertion done..."); this.SerialAsyncGet(key, (byte[][])al_results.ToArray(typeof(byte[])), op++); Thread.Sleep(5000); Console.WriteLine("This checks to make sure our follow up Puts succeeded"); this.SerialAsyncGet(key, (byte[][])al_results.ToArray(typeof(byte[])), op++); Console.WriteLine("If no error messages successful up to: " + (op - 1)); }
override public void Start() { Channel returns = new Channel(); returns.CloseEvent += delegate(object o, EventArgs ea) { try { bool success = (bool)returns.Dequeue(); _result = new DhtPutResult(success, null); } catch (Exception e) { _result = new DhtPutResult(false, e); } finally { Finished(); } }; Dht dht = new Dht(Node, 3, 20); dht.AsyncPut(Key, Value, Ttl, returns); }
public void Start() { Channel returns = new Channel(); returns.CloseEvent += delegate(object o, EventArgs ea) { try { _successful = (bool)returns.Dequeue(); } catch { } _done = true; if (_callback != null) { _callback(this, EventArgs.Empty); } }; Dht dht = new Dht(_node, 3, 20); dht.AsyncPut(_key, _value, _ttl, returns); }