Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="paramList">
        /// 1,string groupName
        /// 2,string fileName
        /// </param>
        /// <returns></returns>
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 2)
            {
                throw new FDFSException("param count is wrong");
            }

            QUERY_FETCH_ONE result    = new QUERY_FETCH_ONE();
            string          groupName = (string)paramList[0];
            string          fileName  = (string)paramList[1];

            if (groupName.Length > Consts.FDFS_GROUP_NAME_MAX_LEN)
            {
                throw new FDFSException("GroupName is too long");
            }

            byte[] groupNameBuffer = Util.StringToByte(groupName);
            byte[] fileNameBuffer  = Util.StringToByte(fileName);
            int    length          = Consts.FDFS_GROUP_NAME_MAX_LEN + fileNameBuffer.Length;

            byte[] body = new byte[length];

            Array.Copy(groupNameBuffer, 0, body, 0, groupNameBuffer.Length);
            Array.Copy(groupNameBuffer, 0, body, 0, groupNameBuffer.Length);

            result.Body   = body;
            result.Header = new FDFSHeader(length,
                                           Consts.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE, 0);
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="paramList">
        /// 1,string groupName
        /// 2,string fileName
        /// </param>
        /// <returns></returns>
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 2 && paramList.Length != 3)
                throw new FDFSException("param count is wrong");

            QUERY_FETCH_ONE result = new QUERY_FETCH_ONE();
            string groupName = (string)paramList[0];
            string fileName = (string)paramList[1];


            byte cmd = Consts.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE;
            if (paramList.Length == 3)
                cmd = (byte)paramList[2];

            if(groupName.Length > Consts.FDFS_GROUP_NAME_MAX_LEN)
                throw new FDFSException("GroupName is too long");

            byte[] groupNameBuffer = Util.StringToByte(groupName);
            byte[] fileNameBuffer = Util.StringToByte(fileName);
            int length = Consts.FDFS_GROUP_NAME_MAX_LEN + fileNameBuffer.Length;
            byte[] body = new byte[length];

            Array.Copy(groupNameBuffer, 0, body, 0, groupNameBuffer.Length);
            Array.Copy(groupNameBuffer, 0, body, 0, groupNameBuffer.Length);

            result.Body = body;
            result.Header = new FDFSHeader(length, cmd, 0);
            return result;
        }