public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 2)
            {
                throw new FDFSException("param count is wrong");
            }
            QUERY_UPDATE queryUpDate = new QUERY_UPDATE();
            string       groupName   = (string)paramList[0];
            string       fileName    = (string)paramList[1];

            var groupNameByteCount = Util.StringByteCount(groupName);

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

            queryUpDate.SetBodyBuffer(length);
            Util.StringToByte(groupName, queryUpDate.BodyBuffer, 0, groupNameByteCount);
            if (groupNameByteCount < 16)
            {
                for (var i = groupNameByteCount; i < 16; i++)
                {
                    queryUpDate.BodyBuffer[i] = 0;
                }
            }

            Util.StringToByte(fileName, queryUpDate.BodyBuffer, 16, fileNameByteCount);
            queryUpDate.Header = new FDFSHeader(length, FDFSConstants.TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE, 0);
            return(queryUpDate);
        }
Example #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)
            {
                throw new FDFSException("param count is wrong");
            }

            QUERY_UPDATE result    = new QUERY_UPDATE();
            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(fileNameBuffer, 0, body, Consts.FDFS_GROUP_NAME_MAX_LEN, fileNameBuffer.Length);

            result.Body   = body;
            result.Header = new FDFSHeader(length,
                                           Consts.TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE, 0);
            return(result);
        }
Example #3
0
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if ((int)paramList.Length != 2)
            {
                throw new FDFSException("param count is wrong");
            }
            QUERY_UPDATE queryupDate = new QUERY_UPDATE();
            string       str         = (string)paramList[0];
            string       str1        = (string)paramList[1];

            if (str.Length > 16)
            {
                throw new FDFSException("GroupName is too long");
            }
            byte[] num      = Util.StringToByte(str);
            byte[] numArray = Util.StringToByte(str1);
            int    length   = 16 + (int)numArray.Length;

            byte[] numArray1 = new byte[length];
            Array.Copy(num, 0, numArray1, 0, (int)num.Length);
            Array.Copy(numArray, 0, numArray1, 16, (int)numArray.Length);
            queryupDate.Body   = numArray1;
            queryupDate.Header = new FDFSHeader((long)length, 103, 0);
            return(queryupDate);
        }
Example #4
0
 public static void AppendFile(string groupName, string fileName, byte[] contentByte)
 {
     fileName = GetFileName(groupName, fileName);
     using (var updateFile = new QUERY_UPDATE())
     {
         var trackerRequest  = updateFile.GetRequest(groupName, fileName);
         var trackerResponse = new QUERY_UPDATE.Response(trackerRequest.GetTrackerResponse());
         var storeEndPoint   = new IPEndPoint(IPAddress.Parse(trackerResponse.IpStr), trackerResponse.Port);
         var storageReqeust  = APPEND_FILE.Instance.GetRequest(storeEndPoint, fileName, contentByte);
         storageReqeust.GetStorageResponse();
     }
 }
Example #5
0
 public static string UploadSlaveFile(string groupName, byte[] contentByte, string masterFilename, string prefixName, string fileExt)
 {
     using (var updateFile = new QUERY_UPDATE())
     {
         var trackerRequest  = updateFile.GetRequest(groupName, masterFilename);
         var trackerResponse = new QUERY_UPDATE.Response(trackerRequest.GetTrackerResponse());
         var storeEndPoint   = new IPEndPoint(IPAddress.Parse(trackerResponse.IpStr), trackerResponse.Port);
         var storageReqeust  = UPLOAD_SLAVE_FILE.Instance.GetRequest(storeEndPoint, contentByte.Length, masterFilename, prefixName, fileExt, contentByte);
         var storageResponse = new UPLOAD_FILE.Response(storageReqeust.GetStorageResponse());
         return(storageResponse.FileName);
     }
 }
Example #6
0
 /// <summary>
 /// 删除文件
 /// </summary>
 /// <param name="groupName">组名</param>
 /// <param name="fileName">文件名</param>
 public static void RemoveFile(string groupName, string fileName)
 {
     fileName = GetFileName(groupName, fileName);
     using (var trackerRequest = QUERY_UPDATE.CreateRequest(groupName, fileName))
     {
         var trackerResponse = new QUERY_UPDATE.Response(trackerRequest.GetTrackerResponse());
         var storeEndPoint   = new IPEndPoint(IPAddress.Parse(trackerResponse.IpStr), trackerResponse.Port);
         using (var storageReqeust = DELETE_FILE.CreateRequest(storeEndPoint, groupName, fileName))
         {
             byte[] responseByte = storageReqeust.GetStorageResponse();
             string result       = Util.ByteToString(responseByte).TrimEnd('\0');
         }
     }
 }
Example #7
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_UPDATE result = new QUERY_UPDATE();
            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(fileNameBuffer, 0, body, Consts.FDFS_GROUP_NAME_MAX_LEN, fileNameBuffer.Length);

            result.Body = body;
            result.Header = new FDFSHeader(length,
                Consts.TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE, 0);
            return result;
        }
Example #8
0
 static QUERY_UPDATE()
 {
     QUERY_UPDATE._instance = null;
 }