免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 20846 | 回复: 0
打印 上一主题 下一主题

[FastDFS] 分享个带连接池的fastdfs Java client [复制链接]

论坛徽章:
0
1 [报告]
发表于 2015-04-27 14:22 |显示全部楼层
回复 1# mineral_cu


    你好 , 在么 , 关于这个有个问题想请教,不知道怎么联系到你~
    这边测试的时候, 在
if(dataLength%StorageInfo.BYTE_SIZE!=0){
                                throw new IOException("recv body length: " + data.length + " is not correct");
                        }
  这个部分会抛出异常, BYTE_SIZE 您这边定义的600  得到的是612 !!!


    public class StorageInfoCmd extends AbstractCmd<List<StorageInfo>> {

        @Override
        public Result<List<StorageInfo>> exec(Socket socket) throws IOException {
                request(socket.getOutputStream());
                Response response = response(socket.getInputStream());
                if(response.isSuccess()){
                        byte[] data = response.getData();
                        int dataLength = data.length;
                        if(dataLength%StorageInfo.BYTE_SIZE!=0){
                                throw new IOException("recv body length: " + data.length + " is not correct");
                        }

                        List<StorageInfo> storageInfos = new ArrayList<StorageInfo>();
                        int offset = 0;
                        while(offset<dataLength){
                                StorageInfo storageInfo = new StorageInfo(data,offset);
                                storageInfos.add(storageInfo);
                                offset += StorageInfo.BYTE_SIZE;
                        }
                        return new Result<List<StorageInfo>>(response.getCode(), storageInfos);
                }else{
                        return new Result<List<StorageInfo>>(response.getCode(), "Error");
                }
        }
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP