Configuration class
Inheritance: IMembaseClientConfiguration
Esempio n. 1
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            // or just initialize the client from code
            var nscc = new MembaseClientConfiguration();

            nscc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 2);
            nscc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            nscc.Urls.Add(new Uri("http://192.168.2.160:8091/pools/default"));
            //nscc.Urls.Add(new Uri("http://192.168.2.162:8091/pools/default"));
            nscc.Credentials = new NetworkCredential("A", "11111111");
            nscc.PerformanceMonitorFactory = new Membase.Configuration.DefaultPerformanceMonitorFactory();
            //nscc.BucketPassword = "******";

            ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_A_"));
            ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient("content"), "TesT_B_"));

            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_B_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_C_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_D_"));

            Console.ReadLine();

            return;

            var mcc = new MemcachedClientConfiguration();
            mcc.AddServer("192.168.2.200:11211");
            mcc.AddServer("192.168.2.202:11211");

            mcc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 4);
            mcc.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 4);
            mcc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            StressTest(new MemcachedClient(mcc), "TesT_");

            return;

            var nc = new MembaseClient(nscc, "content");

            var stats1 = nc.Stats("slabs");
            foreach (var kvp in stats1.GetRaw("curr_connections"))
                Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);

            var nc2 = new MembaseClient(nscc, "content");

            var stats2 = nc2.Stats();
            foreach (var kvp in stats2.GetRaw("curr_connections"))
                Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            // or just initialize the client from code
            var nscc = new MembaseClientConfiguration();

            nscc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 2);
            nscc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            nscc.Urls.Add(new Uri("http://192.168.2.160:8091/pools/default"));
            //nscc.Urls.Add(new Uri("http://192.168.2.162:8091/pools/default"));
            //nscc.Credentials = new NetworkCredential("A", "11111111");
            //nscc.Bucket = "content";
            //nscc.BucketPassword = "******";

            var client = new MembaseClient(nscc);
            Console.WriteLine("Store = " + client.Store(StoreMode.Set, "4q", 1, new TimeSpan(0, 0, 4)));

            Console.WriteLine("Setting expiration to the far future.");
            //Console.ReadLine();

            client.Touch("4q", DateTime.Now.AddDays(1));

            Console.WriteLine("Wait for 4 sec.");
            Console.ReadLine();

            Console.WriteLine(client.Get("4q") ?? "<null>");

            //new MembaseClient(nscc, "data", "data").Store(StoreMode.Set, "q4", 2);
            //new MembaseClient(nscc, "feedback", null).Store(StoreMode.Set, "q4", 2);

            Console.ReadLine();

            //nscc.PerformanceMonitorFactory = new Membase.Configuration.DefaultPerformanceMonitorFactory();
            //nscc.BucketPassword = "******";

            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc), "TesT_A_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient("content", "content"), "TesT_B_"));

            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_B_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_C_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_D_"));

            Console.ReadLine();

            return;

            var mcc = new MemcachedClientConfiguration();
            mcc.AddServer("192.168.2.200:11211");
            mcc.AddServer("192.168.2.202:11211");

            mcc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 4);
            mcc.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 4);
            mcc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            StressTest(new MemcachedClient(mcc), "TesT_");

            return;

            var nc = new MembaseClient(nscc, "content", "content");

            var stats1 = nc.Stats("slabs");
            foreach (var kvp in stats1.GetRaw("curr_connections"))
                Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);

            var nc2 = new MembaseClient(nscc, "content", "content");

            var stats2 = nc2.Stats();
            foreach (var kvp in stats2.GetRaw("curr_connections"))
                Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            var mbcc = new MembaseClientConfiguration();

            mbcc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 2);
            mbcc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            mbcc.Urls.Add(new Uri("http://localhost:8091/pools/default"));

            var client = new MembaseClient(mbcc);

            var item1 = client.Cas(StoreMode.Set, "item1", 1);
            var item2 = client.Cas(StoreMode.Set, "item2", 2);

            var add1 = client.Cas(StoreMode.Add, "item1", 4);

            Console.WriteLine(add1.Result);
            Console.WriteLine(add1.Cas);
            Console.WriteLine(add1.StatusCode);

            Console.WriteLine("item1 = " + item1.Cas);
            Console.WriteLine("item2 = " + item2.Cas);

            Console.WriteLine("Go?");
            Console.ReadLine();

            var mre = new ManualResetEvent(false);

            ThreadPool.QueueUserWorkItem(o =>
            {
                mre.WaitOne();

                Console.WriteLine("Waiting before change 1");
                Thread.Sleep(4000);

                Console.WriteLine("item1 overwrite = " + client.Cas(StoreMode.Set, "item1", 4, item1.Cas).Result);

                Console.WriteLine("Waiting before change 2");
                Thread.Sleep(4000);

                Console.WriteLine("item2 overwrite = " + client.Cas(StoreMode.Set, "item2", 4, item2.Cas).Result);
            });

            //mre.Set();

            //client.Sync("item1", item1.Cas, SyncMode.Mutation);
            client.Sync(SyncMode.Mutation, new[] { new KeyValuePair<string, ulong>("item1", item1.Cas), new KeyValuePair<string, ulong>("item2", item2.Cas) });
            Console.WriteLine("Changed");

            Console.ReadLine();

            ////nscc.PerformanceMonitorFactory = new Membase.Configuration.DefaultPerformanceMonitorFactory();
            ////nscc.BucketPassword = "******";

            ////ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc), "TesT_A_"));
            ////ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient("content", "content"), "TesT_B_"));

            ////ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_B_"));
            ////ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_C_"));
            ////ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_D_"));

            //Console.ReadLine();

            //return;

            //var mcc = new MemcachedClientConfiguration();
            //mcc.AddServer("192.168.2.200:11211");
            //mcc.AddServer("192.168.2.202:11211");

            //mcc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 4);
            //mcc.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 4);
            //mcc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            //StressTest(new MemcachedClient(mcc), "TesT_");

            //return;

            //var nc = new MembaseClient(nscc, "content", "content");

            //var stats1 = nc.Stats("slabs");
            //foreach (var kvp in stats1.GetRaw("curr_connections"))
            //    Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);

            //var nc2 = new MembaseClient(nscc, "content", "content");

            //var stats2 = nc2.Stats();
            //foreach (var kvp in stats2.GetRaw("curr_connections"))
            //    Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
        }