From 020857dbf11ff70b7f03362d98ae23e43df88c91 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Thu, 7 Dec 2023 16:31:46 +0800 Subject: [PATCH] adapt to FastDFS server V6.11 for IPv6 --- HISTORY | 5 +++++ README.md | 2 +- pom.xml | 2 +- .../org/csource/fastdfs/ClientGlobal.java | 15 ++------------ .../java/org/csource/fastdfs/ProtoCommon.java | 20 +++---------------- .../fastdfs-client.properties.sample | 2 -- src/main/resources/fdfs_client.conf.sample | 2 -- 7 files changed, 12 insertions(+), 36 deletions(-) diff --git a/HISTORY b/HISTORY index b1a12b7..64bd5a0 100644 --- a/HISTORY +++ b/HISTORY @@ -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 diff --git a/README.md b/README.md index b69c30f..c5a5418 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ mvn install:install-file -DgroupId=org.csource -DartifactId=fastdfs-client-java org.csource fastdfs-client-java - 1.30-SNAPSHOT + 1.31-SNAPSHOT ``` diff --git a/pom.xml b/pom.xml index 65f6ea2..ac5d66e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.csource fastdfs-client-java - 1.30-SNAPSHOT + 1.31-SNAPSHOT fastdfs-client-java fastdfs client for java jar diff --git a/src/main/java/org/csource/fastdfs/ClientGlobal.java b/src/main/java/org/csource/fastdfs/ClientGlobal.java index 4041139..0cccf01 100644 --- a/src/main/java/org/csource/fastdfs/ClientGlobal.java +++ b/src/main/java/org/csource/fastdfs/ClientGlobal.java @@ -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()); diff --git a/src/main/java/org/csource/fastdfs/ProtoCommon.java b/src/main/java/org/csource/fastdfs/ProtoCommon.java index 8586a58..a8a4de7 100644 --- a/src/main/java/org/csource/fastdfs/ProtoCommon.java +++ b/src/main/java/org/csource/fastdfs/ProtoCommon.java @@ -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; - } } diff --git a/src/main/resources/fastdfs-client.properties.sample b/src/main/resources/fastdfs-client.properties.sample index 38217c9..cd1fcf0 100644 --- a/src/main/resources/fastdfs-client.properties.sample +++ b/src/main/resources/fastdfs-client.properties.sample @@ -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 \ No newline at end of file diff --git a/src/main/resources/fdfs_client.conf.sample b/src/main/resources/fdfs_client.conf.sample index ff99ef7..cd90a5a 100644 --- a/src/main/resources/fdfs_client.conf.sample +++ b/src/main/resources/fdfs_client.conf.sample @@ -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 \ No newline at end of file