From 1336b2b07f02bbb9cefc5a02aaac757262f458e2 Mon Sep 17 00:00:00 2001 From: tanyawen Date: Sat, 28 Dec 2019 05:36:49 +0800 Subject: [PATCH] feature:add about connection config --- fastdfs-client.properties | 10 ++++++++++ fdfs_client.conf | 5 +++++ src/main/java/org/csource/fastdfs/ClientGlobal.java | 4 ++-- src/main/resources/fastdfs-client.properties.sample | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fastdfs-client.properties b/fastdfs-client.properties index 5031a45..df66a20 100644 --- a/fastdfs-client.properties +++ b/fastdfs-client.properties @@ -11,3 +11,13 @@ fastdfs.http_tracker_http_port = 80 fastdfs.tracker_servers = 10.0.11.201:22122,10.0.11.202:22122,10.0.11.203:22122 +## Whether to open the connection pool, if not, create a new connection every time +fastdfs.connection_pool.enabled = false + +## max_count_per_entry: max connection count per host:port , 0 is not limit +fastdfs.connection_pool.max_count_per_entry = 100 + +## connections whose the idle time exceeds this time will be closed, unit: second,default value is 60 +fastdfs.connection_pool.max_idle_time = 60 +## Maximum waiting time when the maximum number of connections is reached, unit: second, default value is 5 +fastdfs.connection_pool.max_wait_time = 5 diff --git a/fdfs_client.conf b/fdfs_client.conf index f28fd40..1f2029a 100644 --- a/fdfs_client.conf +++ b/fdfs_client.conf @@ -8,3 +8,8 @@ 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 = false +connection_pool.max_count_per_entry = 100 +connection_pool.max_idle_time = 60 +connection_pool.max_wait_time = 5 diff --git a/src/main/java/org/csource/fastdfs/ClientGlobal.java b/src/main/java/org/csource/fastdfs/ClientGlobal.java index b5928cf..4773f4a 100644 --- a/src/main/java/org/csource/fastdfs/ClientGlobal.java +++ b/src/main/java/org/csource/fastdfs/ClientGlobal.java @@ -57,9 +57,9 @@ public class ClientGlobal { public static final int DEFAULT_HTTP_TRACKER_HTTP_PORT = 80; public static final boolean DEFAULT_CONNECTION_POOL_ENABLED = true; - public static final int DEFAULT_CONNECTION_POOL_MAX_COUNT_PER_ENTRY = 50; + public static final int DEFAULT_CONNECTION_POOL_MAX_COUNT_PER_ENTRY = 100; public static final int DEFAULT_CONNECTION_POOL_MAX_IDLE_TIME = 60 ;//second - public static final int DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME = 3 ;//second + public static final int DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME = 5 ;//second public static int g_connect_timeout = DEFAULT_CONNECT_TIMEOUT * 1000; //millisecond public static int g_network_timeout = DEFAULT_NETWORK_TIMEOUT * 1000; //millisecond diff --git a/src/main/resources/fastdfs-client.properties.sample b/src/main/resources/fastdfs-client.properties.sample index 00e7deb..52fd46d 100644 --- a/src/main/resources/fastdfs-client.properties.sample +++ b/src/main/resources/fastdfs-client.properties.sample @@ -15,7 +15,7 @@ fastdfs.tracker_servers = 185.245.40.70:22122 fastdfs.connection_pool.enabled = false ## max_count_per_entry: max connection count per host:port , 0 is not limit -fastdfs.connection_pool.max_count_per_entry = 2 +fastdfs.connection_pool.max_count_per_entry = 100 fastdfs.connection_pool.max_idle_time = 60 fastdfs.connection_pool.max_wait_time = 5 \ No newline at end of file