diff --git a/fastdfs-client.properties b/fastdfs-client.properties index 54e30eb..aa82076 100644 --- a/fastdfs-client.properties +++ b/fastdfs-client.properties @@ -12,12 +12,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 +fastdfs.connection_pool.enabled = true -## max_count_per_entry: max connection count per host:port , 0 is not limit -fastdfs.connection_pool.max_count_per_entry = 100 +## max_count_per_entry: max connection count per host:port, 0 is not limit +fastdfs.connection_pool.max_count_per_entry = 500 -## 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: Millisecond, default value is 5000 -fastdfs.connection_pool.max_wait_time_in_ms = 5000 +## connections whose the idle time exceeds this time will be closed, unit: second, default value is 3600 +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 diff --git a/fdfs_client.conf b/fdfs_client.conf index 7d56fce..918f233 100644 --- a/fdfs_client.conf +++ b/fdfs_client.conf @@ -9,7 +9,7 @@ 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_in_ms = 5000 +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 diff --git a/src/main/java/org/csource/fastdfs/ClientGlobal.java b/src/main/java/org/csource/fastdfs/ClientGlobal.java index d364ac9..2099b3c 100644 --- a/src/main/java/org/csource/fastdfs/ClientGlobal.java +++ b/src/main/java/org/csource/fastdfs/ClientGlobal.java @@ -58,8 +58,8 @@ public class ClientGlobal { public static final boolean DEFAULT_CONNECTION_POOL_ENABLED = false; 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_IN_MS = 5000 ;//millisecond + public static final int DEFAULT_CONNECTION_POOL_MAX_IDLE_TIME = 3600 ;//second + public static final int DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS = 1000 ;//millisecond 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/java/org/csource/fastdfs/pool/ConnectionFactory.java b/src/main/java/org/csource/fastdfs/pool/ConnectionFactory.java index a7d0738..0a6b663 100644 --- a/src/main/java/org/csource/fastdfs/pool/ConnectionFactory.java +++ b/src/main/java/org/csource/fastdfs/pool/ConnectionFactory.java @@ -23,7 +23,7 @@ public class ConnectionFactory { sock.connect(socketAddress, ClientGlobal.g_connect_timeout); return new Connection(sock, socketAddress); } catch (Exception e) { - throw new MyException("connect to server, " + socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort() + " fail, emsg:" + e.getMessage()); + throw new MyException("connect to server " + socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort() + " fail, emsg:" + e.getMessage()); } } } diff --git a/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java b/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java index 69fe51e..548d2ee 100644 --- a/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java +++ b/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java @@ -35,7 +35,7 @@ public class ConnectionManager { /** * free connections */ - private LinkedList freeConnections = new LinkedList(); + private LinkedList freeConnections = new LinkedList(); private ConnectionManager() {