• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

fastdfs-client-java: FastDFS java SDK

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

fastdfs-client-java

开源软件地址:

https://gitee.com/fastdfs100/fastdfs-client-java

开源软件介绍:

FastDFS java client SDK

FastDFS Java Client API may be copied only under the terms of the BSD license.

使用ant从源码构建

ant clean package

使用maven从源码安装

mvn clean install

使用maven从jar文件安装

mvn install:install-file -DgroupId=org.csource -DartifactId=fastdfs-client-java -Dversion=${version} -Dpackaging=jar -Dfile=fastdfs-client-java-${version}.jar

在您的maven项目pom.xml中添加依赖

<dependency>    <groupId>org.csource</groupId>    <artifactId>fastdfs-client-java</artifactId>    <version>1.29-SNAPSHOT</version></dependency>

.conf 配置文件、所在目录、加载优先顺序

配置文件名fdfs_client.conf(或使用其它文件名xxx_yyy.conf)文件所在位置可以是项目classpath(或OS文件系统目录比如/opt/):/opt/fdfs_client.confC:\Users\James\config\fdfs_client.conf优先按OS文件系统路径读取,没有找到才查找项目classpath,尤其针对linux环境下的相对路径比如:fdfs_client.confconfig/fdfs_client.conf
connect_timeout = 2network_timeout = 30charset = UTF-8http.tracker_http_port = 80http.anti_steal_token = nohttp.secret_key = FastDFS1234567890tracker_server = 10.0.11.247:22122tracker_server = 10.0.11.248:22122tracker_server = 10.0.11.249:22122connection_pool.enabled = trueconnection_pool.max_count_per_entry = 500connection_pool.max_idle_time = 3600connection_pool.max_wait_time_in_ms = 1000
注1:tracker_server指向您自己IP地址和端口,1-n个注2:除了tracker_server,其它配置项都是可选的

.properties 配置文件、所在目录、加载优先顺序

配置文件名 fastdfs-client.properties(或使用其它文件名 xxx-yyy.properties)文件所在位置可以是项目classpath(或OS文件系统目录比如/opt/):/opt/fastdfs-client.propertiesC:\Users\James\config\fastdfs-client.properties优先按OS文件系统路径读取,没有找到才查找项目classpath,尤其针对linux环境下的相对路径比如:fastdfs-client.propertiesconfig/fastdfs-client.properties
fastdfs.connect_timeout_in_seconds = 5fastdfs.network_timeout_in_seconds = 30fastdfs.charset = UTF-8fastdfs.http_anti_steal_token = falsefastdfs.http_secret_key = FastDFS1234567890fastdfs.http_tracker_http_port = 80fastdfs.tracker_servers = 10.0.11.201:22122,10.0.11.202:22122,10.0.11.203:22122fastdfs.connection_pool.enabled = truefastdfs.connection_pool.max_count_per_entry = 500fastdfs.connection_pool.max_idle_time = 3600fastdfs.connection_pool.max_wait_time_in_ms = 1000
注1:properties 配置文件中属性名跟 conf 配置文件不尽相同,并且统一加前缀"fastdfs.",便于整合到用户项目配置文件注2:fastdfs.tracker_servers 配置项不能重复属性名,多个 tracker_server 用逗号","隔开注3:除了fastdfs.tracker_servers,其它配置项都是可选的

加载配置示例

加载原 conf 格式文件配置:ClientGlobal.init("fdfs_client.conf");ClientGlobal.init("config/fdfs_client.conf");ClientGlobal.init("/opt/fdfs_client.conf");ClientGlobal.init("C:\\Users\\James\\config\\fdfs_client.conf");加载 properties 格式文件配置:ClientGlobal.initByProperties("fastdfs-client.properties");ClientGlobal.initByProperties("config/fastdfs-client.properties");ClientGlobal.initByProperties("/opt/fastdfs-client.properties");ClientGlobal.initByProperties("C:\\Users\\James\\config\\fastdfs-client.properties");加载 Properties 对象配置:Properties props = new Properties();props.put(ClientGlobal.PROP_KEY_TRACKER_SERVERS, "10.0.11.101:22122,10.0.11.102:22122");ClientGlobal.initByProperties(props);加载 trackerServers 字符串配置:String trackerServers = "10.0.11.101:22122,10.0.11.102:22122";ClientGlobal.initByTrackers(trackerServers);

检查加载配置结果:

System.out.println("ClientGlobal.configInfo(): " + ClientGlobal.configInfo());
ClientGlobal.configInfo(): {  g_connect_timeout(ms) = 5000  g_network_timeout(ms) = 30000  g_charset = UTF-8  g_anti_steal_token = false  g_secret_key = FastDFS1234567890  g_tracker_http_port = 80  g_connection_pool_enabled = true  g_connection_pool_max_count_per_entry = 500  g_connection_pool_max_idle_time(ms) = 3600000  g_connection_pool_max_wait_time_in_ms(ms) = 1000  trackerServers = 10.0.11.101:22122,10.0.11.102:22122}

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap