Skip to content

Commit bf8c0f4

Browse files
author
json20080301
authored
Merge pull request #1 from happyfish100/master
merge from happyfish100
2 parents 7332ac5 + db0e652 commit bf8c0f4

File tree

78 files changed

+9002
-9664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+9002
-9664
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bin
2+
build
3+
out
4+
target
5+
.settings
6+
.classpath
7+
.project
8+
.gradle
9+
.DS_Store
10+
*.iml
11+
*.ipr
12+
*.iws
13+
*.log
14+
.idea

src/HISTORY renamed to HISTORY

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
Version 1.26 2017-04-17
3+
* IniFileReader use getResourceAsStream first
4+
* change charactor encoding to UTF-8
5+
26
Version 1.25 2014-12-07
37
* support connection stats since FastDFS Server v5.04
48

src/README renamed to README

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
Copyright (C) 2008 Happy Fish / YuQing
22

3-
FastDFS Java Client API may be copied only under the terms of
3+
FastDFS Java Client API may be copied only under the terms of
44
the BSD license.
55
Please visit the FastDFS Home Page for more detail.
66
English language: http://english.csource.org/
77
Chinese language: http://www.csource.org/
88

99

10-
The jar file is compiled by JDK1.5, you can download the last version
10+
The jar file is compiled by JDK1.5, you can download the last version
1111
from google code: http://code.google.com/p/fastdfs/downloads/list
1212

1313
run the FastDFS Java Client test:
1414
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.TestClient <config_filename> <upload_filename>
1515

1616
eg.:
17-
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.TestClient fdfs_client.conf c:\windows\system32\notepad.exe
17+
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.TestClient fdfs_client.conf c:\windows\system32\notepad.exe
1818

1919
or:
20-
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.TestClient fdfs_client.conf /usr/include/stdlib.h
20+
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.TestClient fdfs_client.conf /usr/include/stdlib.h
2121

2222

2323
run the FastDFS monitor:
2424
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.Monitor <config_filename>
2525

2626
eg.:
27-
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.Monitor fdfs_client.conf
27+
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.Monitor fdfs_client.conf

README.md

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,127 @@
11

2-
FastDFS java client SDK
2+
# FastDFS java client SDK
33

4+
FastDFS Java Client API may be copied only under the terms of the BSD license.
5+
6+
## 使用ant从源码构建
7+
8+
```
9+
ant clean package
10+
```
11+
12+
## 使用maven从源码安装
13+
14+
```
15+
mvn clean install
16+
```
17+
18+
## 使用maven从jar文件安装
19+
```
20+
mvn install:install-file -DgroupId=org.csource -DartifactId=fastdfs-client-java -Dversion=${version} -Dpackaging=jar -Dfile=fastdfs-client-java-${version}.jar
21+
```
22+
23+
## 在您的maven项目pom.xml中添加依赖
24+
25+
```xml
26+
<dependency>
27+
<groupId>org.csource</groupId>
28+
<artifactId>fastdfs-client-java</artifactId>
29+
<version>1.27-SNAPSHOT</version>
30+
</dependency>
31+
```
32+
33+
## .conf 配置文件、所在目录、加载优先顺序
34+
35+
配置文件名fdfs_client.conf(或使用其它文件名xxx_yyy.conf)
36+
37+
文件所在位置可以是项目classpath(或OS文件系统目录比如/opt/):
38+
/opt/fdfs_client.conf
39+
C:\Users\James\config\fdfs_client.conf
40+
41+
优先按OS文件系统路径读取,没有找到才查找项目classpath,尤其针对linux环境下的相对路径比如:
42+
fdfs_client.conf
43+
config/fdfs_client.conf
44+
45+
```
46+
connect_timeout = 2
47+
network_timeout = 30
48+
charset = UTF-8
49+
http.tracker_http_port = 80
50+
http.anti_steal_token = no
51+
http.secret_key = FastDFS1234567890
52+
53+
tracker_server = 10.0.11.247:22122
54+
tracker_server = 10.0.11.248:22122
55+
tracker_server = 10.0.11.249:22122
56+
```
57+
58+
注1:tracker_server指向您自己IP地址和端口,1-n个
59+
注2:除了tracker_server,其它配置项都是可选的
60+
61+
62+
## .properties 配置文件、所在目录、加载优先顺序
63+
64+
配置文件名 fastdfs-client.properties(或使用其它文件名 xxx-yyy.properties)
65+
66+
文件所在位置可以是项目classpath(或OS文件系统目录比如/opt/):
67+
/opt/fastdfs-client.properties
68+
C:\Users\James\config\fastdfs-client.properties
69+
70+
优先按OS文件系统路径读取,没有找到才查找项目classpath,尤其针对linux环境下的相对路径比如:
71+
fastdfs-client.properties
72+
config/fastdfs-client.properties
73+
74+
```
75+
fastdfs.connect_timeout_in_seconds = 5
76+
fastdfs.network_timeout_in_seconds = 30
77+
fastdfs.charset = UTF-8
78+
fastdfs.http_anti_steal_token = false
79+
fastdfs.http_secret_key = FastDFS1234567890
80+
fastdfs.http_tracker_http_port = 80
81+
82+
fastdfs.tracker_servers = 10.0.11.201:22122,10.0.11.202:22122,10.0.11.203:22122
83+
```
84+
85+
注1:properties 配置文件中属性名跟 conf 配置文件不尽相同,并且统一加前缀"fastdfs.",便于整合到用户项目配置文件
86+
注2:fastdfs.tracker_servers 配置项不能重复属性名,多个 tracker_server 用逗号","隔开
87+
注3:除了fastdfs.tracker_servers,其它配置项都是可选的
88+
89+
90+
## 加载配置示例
91+
92+
加载原 conf 格式文件配置:
93+
ClientGlobal.init("fdfs_client.conf");
94+
ClientGlobal.init("config/fdfs_client.conf");
95+
ClientGlobal.init("/opt/fdfs_client.conf");
96+
ClientGlobal.init("C:\\Users\\James\\config\\fdfs_client.conf");
97+
98+
加载 properties 格式文件配置:
99+
ClientGlobal.initByProperties("fastdfs-client.properties");
100+
ClientGlobal.initByProperties("config/fastdfs-client.properties");
101+
ClientGlobal.initByProperties("/opt/fastdfs-client.properties");
102+
ClientGlobal.initByProperties("C:\\Users\\James\\config\\fastdfs-client.properties");
103+
104+
加载 Properties 对象配置:
105+
Properties props = new Properties();
106+
props.put(ClientGlobal.PROP_KEY_TRACKER_SERVERS, "10.0.11.101:22122,10.0.11.102:22122");
107+
ClientGlobal.initByProperties(props);
108+
109+
加载 trackerServers 字符串配置:
110+
String trackerServers = "10.0.11.101:22122,10.0.11.102:22122";
111+
ClientGlobal.initByTrackers(trackerServers);
112+
113+
114+
## 检查加载配置结果:
115+
116+
System.out.println("ClientGlobal.configInfo(): " + ClientGlobal.configInfo());
117+
```
118+
ClientGlobal.configInfo(): {
119+
g_connect_timeout(ms) = 5000
120+
g_network_timeout(ms) = 30000
121+
g_charset = UTF-8
122+
g_anti_steal_token = false
123+
g_secret_key = FastDFS1234567890
124+
g_tracker_http_port = 80
125+
trackerServers = 10.0.11.101:22122,10.0.11.102:22122
126+
}
127+
```

build.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0"?>
2+
3+
<project name="fastdfs-client-java" default="package" basedir=".">
4+
5+
<target name="init">
6+
<property name="project.name" value="fastdfs-client-java"/>
7+
<property name="project.version" value="1.27-SNAPSHOT"/>
8+
<property name="project.java" value="${basedir}/src/main/java"/>
9+
<property name="project.resources" value="${basedir}/src/main/resources"/>
10+
<property name="project.build" value="${basedir}/build"/>
11+
<property name="project.classes" value="${project.build}/classes"/>
12+
<property name="target.jar.file" value="${project.build}/${project.name}-${project.version}.jar"/>
13+
</target>
14+
15+
<target name="compile" depends="init">
16+
<mkdir dir="${project.classes}"/>
17+
<javac destdir="${project.classes}" encoding="UTF-8" failonerror="true" debug="on">
18+
<src path="${project.java}"/>
19+
</javac>
20+
<copy todir="${project.classes}">
21+
<fileset dir="${project.resources}" includes="**/*"/>
22+
</copy>
23+
</target>
24+
25+
<target name="package" depends="compile">
26+
<jar jarfile="${target.jar.file}"
27+
basedir="${project.classes}"
28+
includes="**/*">
29+
</jar>
30+
</target>
31+
32+
<target name="clean" depends="init">
33+
<delete dir="${project.build}"/>
34+
</target>
35+
36+
</project>
37+

fastdfs-client.properties

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## fastdfs-client.properties
2+
3+
fastdfs.connect_timeout_in_seconds = 5
4+
fastdfs.network_timeout_in_seconds = 30
5+
6+
fastdfs.charset = UTF-8
7+
8+
fastdfs.http_anti_steal_token = false
9+
fastdfs.http_secret_key = FastDFS1234567890
10+
fastdfs.http_tracker_http_port = 80
11+
12+
fastdfs.tracker_servers = 10.0.11.201:22122,10.0.11.202:22122,10.0.11.203:22122
13+

fdfs_client.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
connect_timeout = 2
2+
network_timeout = 30
3+
charset = UTF-8
4+
http.tracker_http_port = 8080
5+
http.anti_steal_token = no
6+
http.secret_key = FastDFS1234567890
7+
8+
tracker_server = 10.0.11.247:22122
9+
tracker_server = 10.0.11.248:22122
10+
tracker_server = 10.0.11.249:22122

pom.xml

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,35 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
3+
<modelVersion>4.0.0</modelVersion>
44

5-
<groupId>org.csource</groupId>
6-
<artifactId>fastdfs-client-java</artifactId>
7-
<version>1.25</version>
8-
<name>fastdfs-client-java</name>
9-
<description>fastdfs client with java</description>
10-
<packaging>jar</packaging>
5+
<groupId>org.csource</groupId>
6+
<artifactId>fastdfs-client-java</artifactId>
7+
<version>1.27-SNAPSHOT</version>
8+
<name>fastdfs-client-java</name>
9+
<description>fastdfs client for java</description>
10+
<packaging>jar</packaging>
1111

12-
<properties>
13-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
15-
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
16-
</properties>
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
15+
<maven.test.failure.ignore>true</maven.test.failure.ignore>
16+
<maven.test.skip>true</maven.test.skip>
17+
<jdk.version>1.5</jdk.version>
18+
</properties>
1719

18-
<build>
19-
<sourceDirectory>src</sourceDirectory>
20-
<plugins>
21-
<plugin>
22-
<groupId>org.apache.maven.plugins</groupId>
23-
<artifactId>maven-compiler-plugin</artifactId>
24-
<version>2.5.1</version>
25-
<configuration>
26-
<encoding>UTF-8</encoding>
27-
<skip>true</skip>
28-
<source>1.5</source>
29-
<target>1.5</target>
30-
</configuration>
31-
</plugin>
32-
<plugin>
33-
<groupId>org.apache.maven.plugins</groupId>
34-
<artifactId>maven-jar-plugin</artifactId>
35-
<version>2.4</version>
36-
<executions>
37-
<execution>
38-
<phase>package</phase>
39-
<goals>
40-
<goal>jar</goal>
41-
</goals>
42-
<configuration>
43-
<excludes>
44-
<exclude>**/test/*.class</exclude>
45-
</excludes>
46-
</configuration>
47-
</execution>
48-
</executions>
49-
</plugin>
50-
</plugins>
51-
</build>
52-
</project>
20+
<build>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<version>3.5.1</version>
26+
<configuration>
27+
<encoding>UTF-8</encoding>
28+
<source>${jdk.version}</source>
29+
<target>${jdk.version}</target>
30+
</configuration>
31+
</plugin>
32+
</plugins>
33+
</build>
34+
35+
</project>

src/build.xml

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)