Exemple #1
0
 static void Main(string[] args)
 {
     ClientOption option = new ClientOption(2000);
     option.AddMasterAddr(new Address("127.0.0.1",20000));
     KVClient client = new KVClient(option);
     client.UpdateRegionTable();
 }
Exemple #2
0
        static void Main(string[] args)
        {
            ClientOption option = new ClientOption(2000);

            option.AddMasterAddr(new Address("127.0.0.1", 20000));
            KVClient client = new KVClient(option);

            client.UpdateRegionTable();
        }
        public void TestOperation()
        {
            ClientOption option = new ClientOption(2000);
            option.AddMasterAddr(new Address("127.0.0.1", 20000));
            IKVClient client = new KVClient(option);

            try
            {
                for (byte i = 0; i < 100; i++)
                {
                    client.Set(new byte[] { i }, new byte[] { i });
                }
                for (byte i = 0; i < 100; i += 2)
                {
                    client.Delete(new byte[] { i });
                }
                for (byte i = 0; i < 100; i++)
                {
                    byte[] value = client.Get(new byte[] { i });
                    if (i % 2 != 0)
                    {
                        CollectionAssert.AreEqual(value, new byte[] { i });
                    }
                    else
                    {
                        Assert.IsNull(value);
                    }
                }

                client.Incr(new byte[] { 100 }, 0, 10);
                Assert.AreEqual(client.GetCounter(new byte[] { 100 }), 10);

                DataServerStruct[] dataServers = client.Stat();
                formatStat(dataServers);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }
Exemple #4
0
 public KVClient(ClientOption option)
 {
     this.option      = option;
     this.connections = new Dictionary <Address, Socket>();
     activeMaster     = null;
 }
Exemple #5
0
 public KVClient(ClientOption option)
 {
     this.option = option;
     this.connections = new Dictionary<Address, Socket>();
     activeMaster = null;
 }