Esempio n. 1
0
        private int incr(byte[] key, int incremental, int initValue, bool retry)
        {
            Socket socket = getConnection(key);

            SocketUtil.WriteIncrRequest(socket, key, incremental, initValue);
            int value = 0;
            int ret   = SocketUtil.ReadIncrResponse(socket, out value);

            if (ret == ProtocolCode.Invalid_Key && retry)
            {
                UpdateRegionTable();
                return(incr(key, incremental, initValue, false));
            }
            else if (ret != ProtocolCode.Success)
            {
                throw new KVException(ProtocolCode.getMessage(ret));
            }
            else
            {
                return(value);
            }
        }
Esempio n. 2
0
        private DataServerStruct[] stat(bool retry)
        {
            Socket socket = getMasterConnection();

            SocketUtil.WriteStatRequest(socket);
            DataServerStruct[] dataServers = null;
            int ret = SocketUtil.ReadStatResponse(socket, out dataServers);

            if (ret == ProtocolCode.Invalid_Key && retry)
            {
                UpdateRegionTable();
                return(stat(false));
            }
            else if (ret != ProtocolCode.Success)
            {
                throw new KVException(ProtocolCode.getMessage(ret));
            }
            else
            {
                return(dataServers);
            }
        }
Esempio n. 3
0
        private byte[] get(byte[] key, bool retry)
        {
            Socket socket = getConnection(key);

            SocketUtil.WriteGetRequest(socket, key);
            byte[] value = null;
            int    ret   = SocketUtil.ReadGetResponse(socket, out value);

            if (ret == ProtocolCode.Invalid_Key && retry)
            {
                UpdateRegionTable();
                return(get(key, false));
            }
            else if (ret != ProtocolCode.Success)
            {
                throw new KVException(ProtocolCode.getMessage(ret));
            }
            else
            {
                return(value);
            }
        }