免费注册 查看新帖 |

Chinaunix

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

[FastDFS] FastDFS的java客户端支持随机读取吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-01 18:23 |只看该作者 |倒序浏览
如题~~

论坛徽章:
0
2 [报告]
发表于 2012-04-02 09:21 |只看该作者
回复 1# happystar22


    能解释下你说的随机读取是指什么意思呢?
   
    FastDFS client  通过API 在向Tracker 请求Storage 的时候,Tracker 可以根据负载均衡策略(其中包含轮询等等几种策略),返回合适的storage。你说的随机读取是指的负载均衡策略? 可以把tracker 上传、下载支持的策略贴出来:

# which storage server to upload file
# 0: round robin (default)
# 1: the first server order by ip address
# 2: the first server order by priority (the minimal)
store_server=0

# which path(means disk or mount point) of the storage server to upload file
# 0: round robin
# 2: load balance, select the max free space path to upload file
store_path=0

# which storage server to download file
# 0: round robin (default)
# 1: the source storage server which the current file uploaded to
download_server=0

论坛徽章:
0
3 [报告]
发表于 2012-04-02 09:50 |只看该作者
哦,不是,不好意思,没说清楚。我指的是支持文件的随机读取吗?就是从一个文件的某个字节开始读,不是从头开始。

论坛徽章:
0
4 [报告]
发表于 2012-04-02 10:22 |只看该作者
本帖最后由 doit_zzg 于 2012-04-02 10:23 编辑

回复 3# happystar22


            /**
        * download file from storage server
        * @param file_id the file id(including group name and filename)
        * @param file_offset the start offset of the file
        * @param download_bytes download bytes, 0 for remain bytes from offset
        * @return file content/buff, return null if fail
        */
        public byte[] download_file1(String file_id, long file_offset, long download_bytes) throws IOException, Exception
        {
                String[] parts = new String[2];
                this.errno = this.split_file_id(file_id, parts);
                if (this.errno != 0)
                {
                        return null;
                }
               
                return this.download_file(parts[0], parts[1], file_offset, download_bytes);
        }


        注意上面的file_offset参数


论坛徽章:
0
5 [报告]
发表于 2012-04-02 10:41 |只看该作者
哦好,我再看看源代码吧,谢谢哈~~~
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP