|
25 | 25 | import java.util.concurrent.ArrayBlockingQueue; |
26 | 26 | import java.util.concurrent.Callable; |
27 | 27 | import java.util.concurrent.ConcurrentHashMap; |
| 28 | +import java.util.concurrent.ConcurrentMap; |
28 | 29 | import java.util.concurrent.ExecutionException; |
29 | 30 | import java.util.concurrent.FutureTask; |
30 | 31 | import java.util.concurrent.RejectedExecutionException; |
|
51 | 52 | public class DefaultConnectionManager extends AbstractLifeCycle implements ConnectionManager, |
52 | 53 | Scannable, LifeCycle { |
53 | 54 |
|
54 | | - private static final Logger logger = BoltLoggerFactory |
55 | | - .getLogger("CommonDefault"); |
| 55 | + private static final Logger logger = BoltLoggerFactory |
| 56 | + .getLogger("CommonDefault"); |
56 | 57 |
|
57 | 58 | /** |
58 | 59 | * executor to create connections in async way |
59 | 60 | */ |
60 | | - private ThreadPoolExecutor asyncCreateConnectionExecutor; |
| 61 | + private ThreadPoolExecutor asyncCreateConnectionExecutor; |
61 | 62 |
|
62 | 63 | /** |
63 | 64 | * connection pool initialize tasks |
64 | 65 | */ |
65 | | - protected ConcurrentHashMap<String, RunStateRecordedFutureTask<ConnectionPool>> connTasks; |
| 66 | + protected ConcurrentMap<String, RunStateRecordedFutureTask<ConnectionPool>> connTasks; |
66 | 67 |
|
67 | 68 | /** |
68 | 69 | * heal connection tasks |
69 | 70 | */ |
70 | | - protected ConcurrentHashMap<String, FutureTask<Integer>> healTasks; |
| 71 | + protected ConcurrentMap<String, FutureTask<Integer>> healTasks; |
71 | 72 |
|
72 | 73 | /** |
73 | 74 | * connection pool select strategy |
74 | 75 | */ |
75 | | - protected ConnectionSelectStrategy connectionSelectStrategy; |
| 76 | + protected ConnectionSelectStrategy connectionSelectStrategy; |
76 | 77 |
|
77 | 78 | /** |
78 | 79 | * address parser |
79 | 80 | */ |
80 | | - protected RemotingAddressParser addressParser; |
| 81 | + protected RemotingAddressParser addressParser; |
81 | 82 |
|
82 | 83 | /** |
83 | 84 | * connection factory |
84 | 85 | */ |
85 | | - protected ConnectionFactory connectionFactory; |
| 86 | + protected ConnectionFactory connectionFactory; |
86 | 87 |
|
87 | 88 | /** |
88 | 89 | * connection event handler |
89 | 90 | */ |
90 | | - protected ConnectionEventHandler connectionEventHandler; |
| 91 | + protected ConnectionEventHandler connectionEventHandler; |
91 | 92 |
|
92 | 93 | /** |
93 | 94 | * connection event listener |
94 | 95 | */ |
95 | | - protected ConnectionEventListener connectionEventListener; |
| 96 | + protected ConnectionEventListener connectionEventListener; |
96 | 97 |
|
97 | 98 | /** |
98 | 99 | * Construct with parameters. |
@@ -710,6 +711,7 @@ public ConnectionPool call() throws Exception { |
710 | 711 | syncCreateNumWhenNotWarmup); |
711 | 712 | } catch (Exception e) { |
712 | 713 | pool.removeAllAndTryClose(); |
| 714 | + connTasks.remove(url.getUniqueKey()); |
713 | 715 | throw e; |
714 | 716 | } |
715 | 717 | } |
@@ -914,7 +916,7 @@ public void setConnectionEventListener(ConnectionEventListener connectionEventLi |
914 | 916 | * |
915 | 917 | * @return property value of connPools |
916 | 918 | */ |
917 | | - public ConcurrentHashMap<String, RunStateRecordedFutureTask<ConnectionPool>> getConnPools() { |
| 919 | + public ConcurrentMap<String, RunStateRecordedFutureTask<ConnectionPool>> getConnPools() { |
918 | 920 | return this.connTasks; |
919 | 921 | } |
920 | 922 | } |
0 commit comments