mirror of
https://github.com/happyfish100/fastdfs-client-java.git
synced 2026-09-17 09:20:46 +00:00
adapt to FastDFS server V6.11 for IPv6
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
|
||||
Version 1.31 2023-12-07
|
||||
* adapt to FastDFS server V6.11 for IPv6
|
||||
you must upgrade your FastDFS server to V6.11 or higher version
|
||||
|
||||
Version 1.30 2023-01-29
|
||||
* support tracker server fail over
|
||||
If the tracker server is not specified, when the tracker server fails to
|
||||
|
||||
@@ -26,7 +26,7 @@ mvn install:install-file -DgroupId=org.csource -DartifactId=fastdfs-client-java
|
||||
<dependency>
|
||||
<groupId>org.csource</groupId>
|
||||
<artifactId>fastdfs-client-java</artifactId>
|
||||
<version>1.30-SNAPSHOT</version>
|
||||
<version>1.31-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>org.csource</groupId>
|
||||
<artifactId>fastdfs-client-java</artifactId>
|
||||
<version>1.30-SNAPSHOT</version>
|
||||
<version>1.31-SNAPSHOT</version>
|
||||
<name>fastdfs-client-java</name>
|
||||
<description>fastdfs client for java</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -49,8 +49,6 @@ public class ClientGlobal {
|
||||
public static final String PROP_KEY_CONNECTION_POOL_MAX_IDLE_TIME = "fastdfs.connection_pool.max_idle_time";
|
||||
public static final String PROP_KEY_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS = "fastdfs.connection_pool.max_wait_time_in_ms";
|
||||
|
||||
public static final String PROP_KEY_SERVER_IPV6_ENABLED = "fastdfs.server_ipv6.enabled";
|
||||
|
||||
public static final int DEFAULT_CONNECT_TIMEOUT = 5; //second
|
||||
public static final int DEFAULT_NETWORK_TIMEOUT = 30; //second
|
||||
public static final String DEFAULT_CHARSET = "UTF-8";
|
||||
@@ -148,9 +146,6 @@ public class ClientGlobal {
|
||||
if (g_connection_pool_max_wait_time_in_ms < 0) {
|
||||
g_connection_pool_max_wait_time_in_ms = DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS;
|
||||
}
|
||||
if(iniReader.getBoolValue("server_ipv6.enabled",false)){
|
||||
ProtoCommon.useIPv6();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +187,6 @@ public class ClientGlobal {
|
||||
String poolMaxCountPerEntry = props.getProperty(PROP_KEY_CONNECTION_POOL_MAX_COUNT_PER_ENTRY);
|
||||
String poolMaxIdleTime = props.getProperty(PROP_KEY_CONNECTION_POOL_MAX_IDLE_TIME);
|
||||
String poolMaxWaitTimeInMS = props.getProperty(PROP_KEY_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS);
|
||||
String serverIPv6Enabled = props.getProperty(PROP_KEY_SERVER_IPV6_ENABLED);
|
||||
if (connectTimeoutInSecondsConf != null && connectTimeoutInSecondsConf.trim().length() != 0) {
|
||||
g_connect_timeout = Integer.parseInt(connectTimeoutInSecondsConf.trim()) * 1000;
|
||||
}
|
||||
@@ -223,11 +217,6 @@ public class ClientGlobal {
|
||||
if (poolMaxWaitTimeInMS != null && poolMaxWaitTimeInMS.trim().length() != 0) {
|
||||
g_connection_pool_max_wait_time_in_ms = Integer.parseInt(poolMaxWaitTimeInMS);
|
||||
}
|
||||
if (serverIPv6Enabled != null && serverIPv6Enabled.trim().length() != 0) {
|
||||
if(Boolean.parseBoolean(poolEnabled)){
|
||||
ProtoCommon.useIPv6();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,11 +232,11 @@ public class ClientGlobal {
|
||||
String spr2 = ":";
|
||||
String[] arr1 = trackerServers.trim().split(spr1);
|
||||
for (String addrStr : arr1) {
|
||||
if(addrStr.contains("[")){
|
||||
if(addrStr.contains("[")) {
|
||||
String host = addrStr.substring(1, addrStr.indexOf("]"));
|
||||
int port = Integer.parseInt(addrStr.substring(addrStr.lastIndexOf(":") + 1));
|
||||
list.add(new InetSocketAddress(InetAddress.getByName(host), port));
|
||||
}else {
|
||||
} else {
|
||||
String[] arr2 = addrStr.trim().split(spr2);
|
||||
String host = arr2[0].trim();
|
||||
int port = Integer.parseInt(arr2[1].trim());
|
||||
|
||||
@@ -72,17 +72,15 @@ public class ProtoCommon {
|
||||
public static final int FDFS_PROTO_PKG_LEN_SIZE = 8;
|
||||
public static final int FDFS_PROTO_CMD_SIZE = 1;
|
||||
public static final int FDFS_GROUP_NAME_MAX_LEN = 16;
|
||||
public static final int FDFS_IPADDR_V4_SIZE = 16;
|
||||
public static final int FDFS_IPADDR_V6_SIZE = 46;
|
||||
public static int FDFS_IPADDR_SIZE = FDFS_IPADDR_V4_SIZE;
|
||||
public static final int FDFS_IPADDR_SIZE = 46;
|
||||
public static final int FDFS_DOMAIN_NAME_MAX_SIZE = 128;
|
||||
public static final int FDFS_VERSION_SIZE = 6;
|
||||
public static final int FDFS_STORAGE_ID_MAX_SIZE = 16;
|
||||
public static final String FDFS_RECORD_SEPERATOR = "\u0001";
|
||||
public static final String FDFS_FIELD_SEPERATOR = "\u0002";
|
||||
public static int TRACKER_QUERY_STORAGE_FETCH_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
public static final int TRACKER_QUERY_STORAGE_FETCH_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPADDR_SIZE - 1 + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
public static int TRACKER_QUERY_STORAGE_STORE_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
public static final int TRACKER_QUERY_STORAGE_STORE_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPADDR_SIZE + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
public static final byte FDFS_FILE_EXT_NAME_MAX_LEN = 6;
|
||||
public static final byte FDFS_FILE_PREFIX_MAX_LEN = 16;
|
||||
@@ -504,16 +502,4 @@ public class ProtoCommon {
|
||||
this.body_len = body_len;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置系统使用IPv6地址进行通信
|
||||
*/
|
||||
public static void useIPv6(){
|
||||
FDFS_IPADDR_SIZE = FDFS_IPADDR_V6_SIZE;
|
||||
|
||||
TRACKER_QUERY_STORAGE_FETCH_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPADDR_SIZE - 1 + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPADDR_SIZE + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,5 +29,3 @@ fastdfs.connection_pool.max_idle_time = 3600
|
||||
|
||||
## Maximum waiting time when the maximum number of connections is reached, unit: millisecond, default value is 1000
|
||||
fastdfs.connection_pool.max_wait_time_in_ms = 1000
|
||||
|
||||
server_ipv6.enabled = false
|
||||
@@ -19,5 +19,3 @@ 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
|
||||
|
||||
server_ipv6.enabled = false
|
||||
Reference in New Issue
Block a user