• Stars
    star
    1,598
  • Rank 29,281 (Top 0.6 %)
  • Language
    Java
  • License
    BSD 3-Clause "New...
  • Created almost 10 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

FastDFS java client SDK

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.30-SNAPSHOT</version>
</dependency>

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

配置文件名fdfs_client.conf(或使用其它文件名xxx_yyy.conf)

文件所在位置可以是项目classpath(或OS文件系统目录比如/opt/):
/opt/fdfs_client.conf
C:\Users\James\config\fdfs_client.conf

优先按OS文件系统路径读取,没有找到才查找项目classpath,尤其针对linux环境下的相对路径比如:
fdfs_client.conf
config/fdfs_client.conf
connect_timeout = 2
network_timeout = 30
charset = UTF-8
http.tracker_http_port = 80
http.anti_steal_token = no
http.secret_key = FastDFS1234567890

tracker_server = 10.0.11.247:22122
tracker_server = 10.0.11.248:22122
tracker_server = 10.0.11.249:22122

connection_pool.enabled = true
connection_pool.max_count_per_entry = 500
connection_pool.max_idle_time = 3600
connection_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.properties
C:\Users\James\config\fastdfs-client.properties

优先按OS文件系统路径读取,没有找到才查找项目classpath,尤其针对linux环境下的相对路径比如:
fastdfs-client.properties
config/fastdfs-client.properties
fastdfs.connect_timeout_in_seconds = 5
fastdfs.network_timeout_in_seconds = 30
fastdfs.charset = UTF-8
fastdfs.http_anti_steal_token = false
fastdfs.http_secret_key = FastDFS1234567890
fastdfs.http_tracker_http_port = 80

fastdfs.tracker_servers = 10.0.11.201:22122,10.0.11.202:22122,10.0.11.203:22122

fastdfs.connection_pool.enabled = true
fastdfs.connection_pool.max_count_per_entry = 500
fastdfs.connection_pool.max_idle_time = 3600
fastdfs.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
}

More Repositories

1

fastdfs

FastDFS is an open source high performance distributed file system (DFS). It's major functions include: file storing, file syncing and file accessing, and design for high capacity and load balance. Wechat/Weixin public account (Chinese Language): fastdfs
C
9,016
star
2

libfastcommon

c common functions library extracted from my open source project FastDFS. this library is very simple and stable. functions including: string, logger, chain, hash, socket, ini file reader, base64 encode / decode, url encode / decode, fast timer, skiplist, object pool etc. detail info please see the c header files.
C
897
star
3

FastCFS

A high performance distributed file system which can be used as the back-end storage of databases, K8s and VM etc.
C
551
star
4

libshmcache

libshmcache is a local cache in the share memory for multi processes. high performance due to read is lockless. libshmcache is 100+ times faster than a remote interface such as redis.
C
447
star
5

fastdfs-nginx-module

FastDFS nginx module
C
433
star
6

fastdht

FastDHT is a high performance distributed hash table (DHT) which based key value pairs. It can store mass key value pairs such as filename mapping, session data and user related data.
C
122
star
7

faststore

a high performance distributed file storage service.
C
30
star
8

fastkengine

knowledge base engine
C
25
star
9

fastDIR

a high performance distributed directory service.
C
24
star
10

watchd

watchd is a process watcher / monitor, so watchd is a process watch dog to keep the watched processes alive.
C
21
star
11

libserverframe

C network service framework library extract from FastDFS
C
20
star
12

fastcfs-csi

k8s CSI driver for FastCFS
Go
11
star
13

fastconfig

the config server and agent for configuration items.
C
11
star
14

cparser

an open C language parser. you can walk through the AST for special purpose.
C
9
star
15

fastdfs-apache-module

FastDFS apache module
C
8
star
16

fasttemplate

C library and PHP extension for fast variables replace of template.
C
6
star
17

FastOS.repo

Fast Open Source yum repo
Shell
4
star
18

cplus

C language data type and syntax extension for quick development. extended data type including: string, map, list and dynamic array.
3
star
19

libdiskallocator

sequential disk allocator based trunk files
C
2
star
20

test

just a test
C++
1
star