From b7739178c983e3107bfa54098d7ad1a5f73a723f Mon Sep 17 00:00:00 2001 From: tanyawen Date: Mon, 30 Dec 2019 19:15:12 +0800 Subject: [PATCH] fxi --- .../java/org/csource/fastdfs/pool/ConnectionFactory.java | 5 +++-- .../java/org/csource/fastdfs/pool/ConnectionManager.java | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/csource/fastdfs/pool/ConnectionFactory.java b/src/main/java/org/csource/fastdfs/pool/ConnectionFactory.java index 5cb1ffc..3d026ed 100644 --- a/src/main/java/org/csource/fastdfs/pool/ConnectionFactory.java +++ b/src/main/java/org/csource/fastdfs/pool/ConnectionFactory.java @@ -6,9 +6,11 @@ import org.csource.fastdfs.ClientGlobal; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; + public class ConnectionFactory { /** * create from InetSocketAddress + * * @param socketAddress * @return * @throws IOException @@ -21,8 +23,7 @@ public class ConnectionFactory { sock.connect(socketAddress, ClientGlobal.g_connect_timeout); return new Connection(sock, socketAddress); } catch (Exception e) { - System.err.println("get connection error , emsg:" + e.getMessage()); - throw new MyException("get connection error , emsg:" + e.getMessage()); + throw new MyException("get connection error, ip:host = " + socketAddress.getHostName() + ":" + socketAddress.getPort() + ", 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 7e840d3..0b1b251 100644 --- a/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java +++ b/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java @@ -6,7 +6,6 @@ import org.csource.fastdfs.ClientGlobal; import java.io.IOException; import java.net.InetSocketAddress; import java.util.LinkedList; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Condition; @@ -36,7 +35,7 @@ public class ConnectionManager { /** * free connections */ - private volatile LinkedList freeConnections = new LinkedList(); + private LinkedList freeConnections = new LinkedList(); private ConnectionManager() { @@ -67,10 +66,10 @@ public class ConnectionManager { //wait single success continue; } - throw new MyException("get connection fail, wait_time greater than " + ClientGlobal.g_connection_pool_max_wait_time_in_ms + "ms"); + throw new MyException("get connection fail,ip:port = " + inetSocketAddress.getHostName() + ":" + inetSocketAddress.getPort() + " ,wait_time > " + ClientGlobal.g_connection_pool_max_wait_time_in_ms + "ms"); } catch (InterruptedException e) { e.printStackTrace(); - throw new MyException("get connection fail, emsg:" + e.getMessage()); + throw new MyException("get connection fail, ip:port = " + inetSocketAddress.getHostName() + ":" + inetSocketAddress.getPort() + ", emsg:" + e.getMessage()); } } return connection; @@ -103,7 +102,7 @@ public class ConnectionManager { connection.closeDirectly(); } } catch (IOException e) { - System.err.println("close socket error , msg:" + e.getMessage()); + System.err.println("close socket error,ip:port = " + inetSocketAddress.getHostName() + ":" + inetSocketAddress.getPort() + ",emsg:" + e.getMessage()); e.printStackTrace(); } }