/// <summary> /// /// </summary> /// <param name="paramList"> /// 1,string groupName-->the storage groupName /// </param> /// <returns></returns> public override FDFSRequest GetRequest(params object[] paramList) { long length = Consts.FDFS_GROUP_NAME_MAX_LEN; byte cmd = Consts.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE; QUERY_STORE_WITH_GROUP_ONE result = new QUERY_STORE_WITH_GROUP_ONE(); if (paramList.Length == 0) { length = 0L; cmd = Consts.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITHOUT_GROUP_ONE; } //throw new FDFSException("GroupName is null"); if (paramList.Length > 0) { byte[] groupName = Util.StringToByte((string)paramList[0]); if (groupName.Length > Consts.FDFS_GROUP_NAME_MAX_LEN) { throw new FDFSException("GroupName is too long"); } byte[] body = new byte[Consts.FDFS_GROUP_NAME_MAX_LEN]; Array.Copy(groupName, 0, body, 0, groupName.Length); result.Body = body; } result.Header = new FDFSHeader(length, cmd, 0); return(result); }
/// <summary> /// /// </summary> /// <param name="paramList"> /// 1,string groupName-->the storage groupName /// </param> /// <returns></returns> public override FDFSRequest GetRequest(params object[] paramList) { long length = Consts.FDFS_GROUP_NAME_MAX_LEN; byte cmd = Consts.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE; QUERY_STORE_WITH_GROUP_ONE result = new QUERY_STORE_WITH_GROUP_ONE(); if (paramList.Length == 0) { length = 0L; cmd = Consts.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITHOUT_GROUP_ONE; } //throw new FDFSException("GroupName is null"); if (paramList.Length > 0) { byte[] groupName = Util.StringToByte((string)paramList[0]); if (groupName.Length > Consts.FDFS_GROUP_NAME_MAX_LEN) { throw new FDFSException("GroupName is too long"); } byte[] body = new byte[Consts.FDFS_GROUP_NAME_MAX_LEN]; Array.Copy(groupName, 0, body, 0, groupName.Length); result.Body = body; } result.Header = new FDFSHeader(length, cmd, 0); return result; }
/// <summary> /// 获取存储节点 /// </summary> /// <param name="groupName">组名,如果没有组名由服务器自动分配</param> /// <returns>存储节点实体类</returns> public static StorageNode GetStorageNode(string groupName) { if (string.IsNullOrEmpty(groupName)) { using (var trackerRequest = QUERY_STORE_WITHOUT_GROUP_ONE.CreateRequest()) { var trackerResponse = new QUERY_STORE_WITHOUT_GROUP_ONE.Response(trackerRequest.GetTrackerResponse()); var storeEndPoint = new IPEndPoint(IPAddress.Parse(trackerResponse.IpStr), trackerResponse.Port); Console.WriteLine($"{DateTime.Now.ToString("yyyyMMdd hh:mm:ss:fff")} => GetStorageNode(tracker = {trackerResponse.IpStr},store = {storeEndPoint.Address})");//log var result = new StorageNode { GroupName = trackerResponse.GroupName, EndPoint = storeEndPoint, StorePathIndex = trackerResponse.StorePathIndex }; return(result); } } else { using (var trackerRequest = QUERY_STORE_WITH_GROUP_ONE.CreateRequest(groupName)) { var trackerResponse = new QUERY_STORE_WITH_GROUP_ONE.Response(trackerRequest.GetTrackerResponse()); var storeEndPoint = new IPEndPoint(IPAddress.Parse(trackerResponse.IpStr), trackerResponse.Port); Console.WriteLine($"{DateTime.Now.ToString("yyyyMMdd hh:mm:ss:fff")} => GetStorageNode(tracker = {trackerResponse.IpStr},store = {storeEndPoint.Address})");//log var result = new StorageNode { GroupName = trackerResponse.GroupName, EndPoint = storeEndPoint, StorePathIndex = trackerResponse.StorePathIndex }; return(result); } } }
public override FDFSRequest GetRequest(params object[] paramList) { if (paramList.Length == 0) { throw new FDFSException("GroupName is null"); } QUERY_STORE_WITH_GROUP_ONE queryStoreWithGroupOne = new QUERY_STORE_WITH_GROUP_ONE(); var groupName = (string)paramList[0]; var groupNameByteCount = Util.StringByteCount(groupName); if (groupNameByteCount > 16) { throw new FDFSException("GroupName is too long"); } const int length = 16; queryStoreWithGroupOne.SetBodyBuffer(length); Util.StringToByte(groupName, queryStoreWithGroupOne.BodyBuffer, 0, groupNameByteCount); if (groupNameByteCount < 16) { for (var i = groupNameByteCount; i < 16; i++) { queryStoreWithGroupOne.BodyBuffer[i] = 0; } } queryStoreWithGroupOne.Header = new FDFSHeader(length, FDFSConstants.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE, 0); return(queryStoreWithGroupOne); }
public override FDFSRequest GetRequest(params object[] paramList) { if ((int)paramList.Length == 0) { throw new FDFSException("GroupName is null"); } QUERY_STORE_WITH_GROUP_ONE queryStoreWithGroupOne = new QUERY_STORE_WITH_GROUP_ONE(); byte[] num = Util.StringToByte((string)paramList[0]); if ((int)num.Length > 16) { throw new FDFSException("GroupName is too long"); } byte[] numArray = new byte[16]; Array.Copy(num, 0, numArray, 0, (int)num.Length); queryStoreWithGroupOne.Body = numArray; queryStoreWithGroupOne.Header = new FDFSHeader((long)16, 104, 0); return(queryStoreWithGroupOne); }
static QUERY_STORE_WITH_GROUP_ONE() { QUERY_STORE_WITH_GROUP_ONE._instance = null; }