/// <summary>LoadContent
        /// </summary>
        public override void LoadContent(ClusterConfiguration configuration, byte[] data)
        {
            int bytesRead = 0;

            byte[] groupNameBuffer = new byte[Consts.FDFS_GROUP_NAME_MAX_LEN];
            Array.Copy(data, bytesRead, groupNameBuffer, 0, Consts.FDFS_GROUP_NAME_MAX_LEN);
            GroupName = EndecodeUtil.DecodeString(groupNameBuffer, configuration.Charset);
            //Util.ByteToString(option.Charset, groupNameBuffer).TrimEnd('\0');
            bytesRead += Consts.FDFS_GROUP_NAME_MAX_LEN;

            byte[] ipAddressBuffer = new byte[Consts.IP_ADDRESS_SIZE - 1];
            Array.Copy(data, bytesRead, ipAddressBuffer, 0, Consts.IP_ADDRESS_SIZE - 1);
            IPAddresses.Add(EndecodeUtil.DecodeString(ipAddressBuffer, configuration.Charset));
            //IPAddresses.Add(new string(option.Charset.GetChars(ipAddressBuffer)).TrimEnd('\0'));
            bytesRead += Consts.IP_ADDRESS_SIZE - 1;

            byte[] portBuffer = new byte[Consts.FDFS_PROTO_PKG_LEN_SIZE];
            Array.Copy(data, bytesRead, portBuffer, 0, Consts.FDFS_PROTO_PKG_LEN_SIZE);
            Port       = (int)ByteUtil.BufferToLong(portBuffer, 0);
            bytesRead += Consts.FDFS_PROTO_PKG_LEN_SIZE;

            while (data.Length - bytesRead >= Consts.IP_ADDRESS_SIZE - 1)
            {
                ipAddressBuffer = new byte[Consts.IP_ADDRESS_SIZE - 1];
                Array.Copy(data, bytesRead, ipAddressBuffer, 0, Consts.IP_ADDRESS_SIZE - 1);
                IPAddresses.Add(EndecodeUtil.DecodeString(ipAddressBuffer, configuration.Charset));
                // IPAddresses.Add(new string(option.Charset.GetChars(ipAddressBuffer)).TrimEnd('\0'));
                bytesRead += Consts.IP_ADDRESS_SIZE - 1;
            }
        }
Beispiel #2
0
        /// <summary>LoadContent
        /// </summary>
        public override void LoadContent(FastDFSOption option, byte[] data)
        {
            var span          = data.AsSpan();
            var groupNameSpan = span.Slice(0, Consts.FDFS_GROUP_NAME_MAX_LEN);

            GroupName = EndecodeUtil.DecodeString(groupNameSpan.ToArray(), option.Charset);

            var fileNameSpan = span.Slice(Consts.FDFS_GROUP_NAME_MAX_LEN, data.Length - Consts.FDFS_GROUP_NAME_MAX_LEN);

            FileId = EndecodeUtil.DecodeString(fileNameSpan.ToArray(), option.Charset);
        }
Beispiel #3
0
        /// <summary>LoadContent
        /// </summary>
        public override void LoadContent(FastDFSOption option, byte[] data)
        {
            byte[] groupNameBuffer = new byte[Consts.FDFS_GROUP_NAME_MAX_LEN];
            Array.Copy(data, groupNameBuffer, Consts.FDFS_GROUP_NAME_MAX_LEN);
            GroupName = EndecodeUtil.DecodeString(groupNameBuffer);

            byte[] ipAddressBuffer = new byte[Consts.IP_ADDRESS_SIZE - 1];
            Array.Copy(data, Consts.FDFS_GROUP_NAME_MAX_LEN, ipAddressBuffer, 0, Consts.IP_ADDRESS_SIZE - 1);
            IPAddress = EndecodeUtil.DecodeString(ipAddressBuffer);
            //new string(option.Charset.GetChars(ipAddressBuffer)).TrimEnd('\0');

            byte[] portBuffer = new byte[Consts.FDFS_PROTO_PKG_LEN_SIZE];
            Array.Copy(data, Consts.FDFS_GROUP_NAME_MAX_LEN + Consts.IP_ADDRESS_SIZE - 1,
                       portBuffer, 0, Consts.FDFS_PROTO_PKG_LEN_SIZE);

            Port = (int)ByteUtil.BufferToLong(portBuffer, 0);
        }