public override FDFSRequest GetRequest(params object[] paramList) { IPEndPoint endPoint = (IPEndPoint)paramList[0]; string groupName = (string)paramList[1]; string fileName = (string)paramList[2]; IDictionary <string, string> metaData = (IDictionary <string, string>)paramList[3]; string option = (MetaDataOption)paramList[4] == MetaDataOption.Overwrite ? "O" : "M"; byte[] optionBuffer = Util.StringToByte(option); byte[] groupNameBuffer = Util.CreateGroupNameBuffer(groupName); byte[] fileNameBuffer = Util.StringToByte(fileName); byte[] metaDataBuffer = CreateMetaDataBuffer(metaData); byte[] fileNameLengthBuffer = Util.LongToBuffer(fileNameBuffer.Length); byte[] metaDataSizeBuffer = Util.LongToBuffer(metaDataBuffer.Length); int length = Consts.FDFS_PROTO_PKG_LEN_SIZE + // filename length Consts.FDFS_PROTO_PKG_LEN_SIZE + // metadata size 1 + // operation flag Consts.FDFS_GROUP_NAME_MAX_LEN + // group name fileNameBuffer.Length + // file name metaDataBuffer.Length; // metadata List <byte> bodyBuffer = new List <byte>(); bodyBuffer.AddRange(fileNameLengthBuffer); bodyBuffer.AddRange(metaDataSizeBuffer); bodyBuffer.AddRange(optionBuffer); bodyBuffer.AddRange(groupNameBuffer); bodyBuffer.AddRange(fileNameBuffer); bodyBuffer.AddRange(metaDataBuffer); Debug.Assert(length == bodyBuffer.Count); SET_METADATA request = new SET_METADATA(); request.Connection = ConnectionManager.GetStorageConnection(endPoint); request.Body = bodyBuffer.ToArray(); request.Header = new FDFSHeader(bodyBuffer.Count, Consts.STORAGE_PROTO_CMD_SET_METADATA, 0); return(request); }
public override FDFSRequest GetRequest(params object[] paramList) { IPEndPoint endPoint = (IPEndPoint)paramList[0]; string groupName = (string)paramList[1]; string fileName = (string)paramList[2]; IDictionary<string, string> metaData = (IDictionary<string,string>)paramList[3]; string option = (MetaDataOption)paramList[4] == MetaDataOption.Overwrite ? "O" : "M"; byte[] optionBuffer = Util.StringToByte(option); byte[] groupNameBuffer = Util.CreateGroupNameBuffer(groupName); byte[] fileNameBuffer = Util.StringToByte(fileName); byte[] metaDataBuffer = CreateMetaDataBuffer(metaData); byte[] fileNameLengthBuffer = Util.LongToBuffer(fileNameBuffer.Length); byte[] metaDataSizeBuffer = Util.LongToBuffer(metaDataBuffer.Length); int length = Consts.FDFS_PROTO_PKG_LEN_SIZE + // filename length Consts.FDFS_PROTO_PKG_LEN_SIZE + // metadata size 1 + // operation flag Consts.FDFS_GROUP_NAME_MAX_LEN + // group name fileNameBuffer.Length + // file name metaDataBuffer.Length; // metadata List<byte> bodyBuffer = new List<byte>(); bodyBuffer.AddRange(fileNameLengthBuffer); bodyBuffer.AddRange(metaDataSizeBuffer); bodyBuffer.AddRange(optionBuffer); bodyBuffer.AddRange(groupNameBuffer); bodyBuffer.AddRange(fileNameBuffer); bodyBuffer.AddRange(metaDataBuffer); Debug.Assert(length == bodyBuffer.Count); SET_METADATA request = new SET_METADATA(); request.Connection = ConnectionManager.GetStorageConnection(endPoint); request.Body = bodyBuffer.ToArray(); request.Header = new FDFSHeader(bodyBuffer.Count, Consts.STORAGE_PROTO_CMD_SET_METADATA, 0); return request; }