Skip to content

Commit 020857d

Browse files
committed
adapt to FastDFS server V6.11 for IPv6
1 parent da417c7 commit 020857d

File tree

7 files changed

+12
-36
lines changed

7 files changed

+12
-36
lines changed

HISTORY

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2+
Version 1.31 2023-12-07
3+
* adapt to FastDFS server V6.11 for IPv6
4+
you must upgrade your FastDFS server to V6.11 or higher version
5+
16
Version 1.30 2023-01-29
27
* support tracker server fail over
38
If the tracker server is not specified, when the tracker server fails to

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mvn install:install-file -DgroupId=org.csource -DartifactId=fastdfs-client-java
2626
<dependency>
2727
<groupId>org.csource</groupId>
2828
<artifactId>fastdfs-client-java</artifactId>
29-
<version>1.30-SNAPSHOT</version>
29+
<version>1.31-SNAPSHOT</version>
3030
</dependency>
3131
```
3232

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.csource</groupId>
66
<artifactId>fastdfs-client-java</artifactId>
7-
<version>1.30-SNAPSHOT</version>
7+
<version>1.31-SNAPSHOT</version>
88
<name>fastdfs-client-java</name>
99
<description>fastdfs client for java</description>
1010
<packaging>jar</packaging>

src/main/java/org/csource/fastdfs/ClientGlobal.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public class ClientGlobal {
4949
public static final String PROP_KEY_CONNECTION_POOL_MAX_IDLE_TIME = "fastdfs.connection_pool.max_idle_time";
5050
public static final String PROP_KEY_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS = "fastdfs.connection_pool.max_wait_time_in_ms";
5151

52-
public static final String PROP_KEY_SERVER_IPV6_ENABLED = "fastdfs.server_ipv6.enabled";
53-
5452
public static final int DEFAULT_CONNECT_TIMEOUT = 5; //second
5553
public static final int DEFAULT_NETWORK_TIMEOUT = 30; //second
5654
public static final String DEFAULT_CHARSET = "UTF-8";
@@ -148,9 +146,6 @@ public static void init(String conf_filename) throws IOException, MyException {
148146
if (g_connection_pool_max_wait_time_in_ms < 0) {
149147
g_connection_pool_max_wait_time_in_ms = DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS;
150148
}
151-
if(iniReader.getBoolValue("server_ipv6.enabled",false)){
152-
ProtoCommon.useIPv6();
153-
}
154149
}
155150

156151
/**
@@ -192,7 +187,6 @@ public static void initByProperties(Properties props) throws IOException, MyExce
192187
String poolMaxCountPerEntry = props.getProperty(PROP_KEY_CONNECTION_POOL_MAX_COUNT_PER_ENTRY);
193188
String poolMaxIdleTime = props.getProperty(PROP_KEY_CONNECTION_POOL_MAX_IDLE_TIME);
194189
String poolMaxWaitTimeInMS = props.getProperty(PROP_KEY_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS);
195-
String serverIPv6Enabled = props.getProperty(PROP_KEY_SERVER_IPV6_ENABLED);
196190
if (connectTimeoutInSecondsConf != null && connectTimeoutInSecondsConf.trim().length() != 0) {
197191
g_connect_timeout = Integer.parseInt(connectTimeoutInSecondsConf.trim()) * 1000;
198192
}
@@ -223,11 +217,6 @@ public static void initByProperties(Properties props) throws IOException, MyExce
223217
if (poolMaxWaitTimeInMS != null && poolMaxWaitTimeInMS.trim().length() != 0) {
224218
g_connection_pool_max_wait_time_in_ms = Integer.parseInt(poolMaxWaitTimeInMS);
225219
}
226-
if (serverIPv6Enabled != null && serverIPv6Enabled.trim().length() != 0) {
227-
if(Boolean.parseBoolean(poolEnabled)){
228-
ProtoCommon.useIPv6();
229-
}
230-
}
231220
}
232221

233222
/**
@@ -243,11 +232,11 @@ public static void initByTrackers(String trackerServers) throws IOException, MyE
243232
String spr2 = ":";
244233
String[] arr1 = trackerServers.trim().split(spr1);
245234
for (String addrStr : arr1) {
246-
if(addrStr.contains("[")){
235+
if(addrStr.contains("[")) {
247236
String host = addrStr.substring(1, addrStr.indexOf("]"));
248237
int port = Integer.parseInt(addrStr.substring(addrStr.lastIndexOf(":") + 1));
249238
list.add(new InetSocketAddress(InetAddress.getByName(host), port));
250-
}else {
239+
} else {
251240
String[] arr2 = addrStr.trim().split(spr2);
252241
String host = arr2[0].trim();
253242
int port = Integer.parseInt(arr2[1].trim());

src/main/java/org/csource/fastdfs/ProtoCommon.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,15 @@ public class ProtoCommon {
7272
public static final int FDFS_PROTO_PKG_LEN_SIZE = 8;
7373
public static final int FDFS_PROTO_CMD_SIZE = 1;
7474
public static final int FDFS_GROUP_NAME_MAX_LEN = 16;
75-
public static final int FDFS_IPADDR_V4_SIZE = 16;
76-
public static final int FDFS_IPADDR_V6_SIZE = 46;
77-
public static int FDFS_IPADDR_SIZE = FDFS_IPADDR_V4_SIZE;
75+
public static final int FDFS_IPADDR_SIZE = 46;
7876
public static final int FDFS_DOMAIN_NAME_MAX_SIZE = 128;
7977
public static final int FDFS_VERSION_SIZE = 6;
8078
public static final int FDFS_STORAGE_ID_MAX_SIZE = 16;
8179
public static final String FDFS_RECORD_SEPERATOR = "\u0001";
8280
public static final String FDFS_FIELD_SEPERATOR = "\u0002";
83-
public static int TRACKER_QUERY_STORAGE_FETCH_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
81+
public static final int TRACKER_QUERY_STORAGE_FETCH_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
8482
+ FDFS_IPADDR_SIZE - 1 + FDFS_PROTO_PKG_LEN_SIZE;
85-
public static int TRACKER_QUERY_STORAGE_STORE_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
83+
public static final int TRACKER_QUERY_STORAGE_STORE_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
8684
+ FDFS_IPADDR_SIZE + FDFS_PROTO_PKG_LEN_SIZE;
8785
public static final byte FDFS_FILE_EXT_NAME_MAX_LEN = 6;
8886
public static final byte FDFS_FILE_PREFIX_MAX_LEN = 16;
@@ -504,16 +502,4 @@ public RecvHeaderInfo(byte errno, long body_len) {
504502
this.body_len = body_len;
505503
}
506504
}
507-
508-
/**
509-
* 设置系统使用IPv6地址进行通信
510-
*/
511-
public static void useIPv6(){
512-
FDFS_IPADDR_SIZE = FDFS_IPADDR_V6_SIZE;
513-
514-
TRACKER_QUERY_STORAGE_FETCH_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
515-
+ FDFS_IPADDR_SIZE - 1 + FDFS_PROTO_PKG_LEN_SIZE;
516-
TRACKER_QUERY_STORAGE_STORE_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
517-
+ FDFS_IPADDR_SIZE + FDFS_PROTO_PKG_LEN_SIZE;
518-
}
519505
}

src/main/resources/fastdfs-client.properties.sample

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,3 @@ fastdfs.connection_pool.max_idle_time = 3600
2929

3030
## Maximum waiting time when the maximum number of connections is reached, unit: millisecond, default value is 1000
3131
fastdfs.connection_pool.max_wait_time_in_ms = 1000
32-
33-
server_ipv6.enabled = false

src/main/resources/fdfs_client.conf.sample

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ connection_pool.enabled = true
1919
connection_pool.max_count_per_entry = 500
2020
connection_pool.max_idle_time = 3600
2121
connection_pool.max_wait_time_in_ms = 1000
22-
23-
server_ipv6.enabled = false

0 commit comments

Comments
 (0)