Пример #1
0
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if ((int)paramList.Length != 3)
            {
                throw new FDFSException("param count is wrong");
            }
            IPEndPoint      pEndPoint     = (IPEndPoint)paramList[0];
            string          groupName     = (string)paramList[1];
            string          fileName      = (string)paramList[2];
            QUERY_FILE_INFO queryFileInfo = new QUERY_FILE_INFO
            {
                ConnectionType = FDFSConnectionType.StorageConnection,
                EndPoint       = pEndPoint
            };
            var groupNameByteCount = Util.StringByteCount(groupName);

            if (groupNameByteCount > 16)
            {
                throw new FDFSException("groupName is too long");
            }
            var fileNameByteCount = Util.StringByteCount(fileName);
            int length            = 16 + fileNameByteCount;

            queryFileInfo.SetBodyBuffer(length);
            Util.StringToByte(groupName, queryFileInfo.BodyBuffer, 0, groupNameByteCount);
            Util.StringToByte(fileName, queryFileInfo.BodyBuffer, 16, fileNameByteCount);
            queryFileInfo.Header = new FDFSHeader(length, FDFSConstants.STORAGE_PROTO_CMD_QUERY_FILE_INFO, 0);
            return(queryFileInfo);
        }
Пример #2
0
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if ((int)paramList.Length != 3)
            {
                throw new FDFSException("param count is wrong");
            }
            IPEndPoint      pEndPoint     = (IPEndPoint)paramList[0];
            string          str           = (string)paramList[1];
            string          str1          = (string)paramList[2];
            QUERY_FILE_INFO queryFileInfo = new QUERY_FILE_INFO()
            {
                ConnectionType = 1,
                EndPoint       = pEndPoint
            };

            if (str.Length > 16)
            {
                throw new FDFSException("groupName is too long");
            }
            long length = 16 + str1.Length;

            byte[] numArray = new byte[length];
            byte[] num      = Util.StringToByte(str);
            byte[] num1     = Util.StringToByte(str1);
            Array.Copy(num, 0, numArray, 0, (int)num.Length);
            Array.Copy(num1, 0, numArray, 16, (int)num1.Length);
            queryFileInfo.Body   = numArray;
            queryFileInfo.Header = new FDFSHeader(length, 22, 0);
            return(queryFileInfo);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="paramList">
        /// 1,IPEndPoint    IPEndPoint-->the storage IPEndPoint
        /// 2,string fileName
        /// 3,string fileBytes
        /// </param>
        /// <returns></returns>
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 3)
            {
                throw new FDFSException("param count is wrong");
            }
            IPEndPoint endPoint = (IPEndPoint)paramList[0];

            string groupName = (string)paramList[1];
            string fileName  = (string)paramList[2];

            QUERY_FILE_INFO result = new QUERY_FILE_INFO();

            result.Connection = ConnectionManager.GetStorageConnection(endPoint);

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

            long length = Consts.FDFS_GROUP_NAME_MAX_LEN + fileName.Length;

            byte[] bodyBuffer      = new byte[length];
            byte[] groupNameBuffer = Util.StringToByte(groupName);
            byte[] fileNameBuffer  = Util.StringToByte(fileName);

            Array.Copy(groupNameBuffer, 0, bodyBuffer, 0, groupNameBuffer.Length);
            Array.Copy(fileNameBuffer, 0, bodyBuffer, Consts.FDFS_GROUP_NAME_MAX_LEN, fileNameBuffer.Length);

            result.Body   = bodyBuffer;
            result.Header = new FDFSHeader(length, Consts.STORAGE_PROTO_CMD_QUERY_FILE_INFO, 0);
            return(result);
        }
Пример #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="paramList">
        /// 1,IPEndPoint    IPEndPoint-->the storage IPEndPoint
        /// 2,string fileName
        /// 3,string fileBytes
        /// </param>
        /// <returns></returns>
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 3)
                throw new FDFSException("param count is wrong");
            IPEndPoint endPoint = (IPEndPoint)paramList[0];

            string groupName = (string)paramList[1];
            string fileName = (string)paramList[2];

            QUERY_FILE_INFO result = new QUERY_FILE_INFO();
            result.Connection = ConnectionManager.GetStorageConnection(endPoint);

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

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

            Array.Copy(groupNameBuffer, 0, bodyBuffer, 0, groupNameBuffer.Length);
            Array.Copy(fileNameBuffer, 0, bodyBuffer, Consts.FDFS_GROUP_NAME_MAX_LEN, fileNameBuffer.Length);

            result.Body = bodyBuffer;
            result.Header = new FDFSHeader(length, Consts.STORAGE_PROTO_CMD_QUERY_FILE_INFO, 0);
            return result;
        }       
Пример #5
0
 /// <summary>
 /// 获取文件信息
 /// </summary>
 /// <param name="storageNode">GetStorageNode方法返回的存储节点</param>
 /// <param name="fileName">文件名</param>
 /// <returns></returns>
 public static FDFSFileInfo GetFileInfo(StorageNode storageNode, string fileName)
 {
     fileName = GetFileName(storageNode.GroupName, fileName);
     using (var storageReqeust = QUERY_FILE_INFO.CreateRequest(storageNode.EndPoint, storageNode.GroupName, fileName))
     {
         var result = new FDFSFileInfo(storageReqeust.GetStorageResponse());
         return(result);
     }
 }
Пример #6
0
 static QUERY_FILE_INFO()
 {
     QUERY_FILE_INFO._instance = null;
 }