Пример #1
0
        public void DoPut()
        {
            for (int c=0; ; c++)
            {
                Thread.Sleep(1000);
                Console.WriteLine("OPERATION " + c);
                Packet request = new Packet();
                Random random = new Random(5);

                byte[] key = new byte[10];
                byte[] val = new byte[1000];
                random.NextBytes(key);
                request.set("c:default", ClusterOperation.CONCURRENT_MAP_PUT, key, val);
                Call call = new Call(request);
                outThread.enQueue(call);
                Packet result = null;
                int timeout = 5000;
                for (int i = 1; ; i++)
                {
                    result = call.getResult(timeout);
                    if (result != null)
                    {
                        if (result.callId != request.callId)
                        {
                            Console.WriteLine("Id's don't match!");
                        }
                        Interlocked.Increment(ref puts);
                        break;
                    }
                    else {
                        Console.WriteLine("Call"  + call.getId() + " didn't get answer within "+ timeout*i/1000 + " seconds");
                    }
                }
            }
        }
 public void enQueue(Call call)
 {
     //long t = System.DateTime.Now.Ticks;
     inQ.Add(call);
     //Console.WriteLine("Add in ticks" + (System.DateTime.Now.Ticks - t));
 }
 public bool contains(Call call)
 {
     return inQ.Contains(call);
 }