Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
            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);
            }