timoninmaxim commented on a change in pull request #8206:
URL: https://github.com/apache/ignite/pull/8206#discussion_r497490000
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
##########
@@ -519,29 +689,44 @@ private boolean applyReconnectionThrottling() {
/**
* Get or create channel.
*/
- private synchronized ClientChannel getOrCreateChannel()
+ private ClientChannel getOrCreateChannel()
throws ClientConnectionException, ClientAuthenticationException,
ClientProtocolError {
return getOrCreateChannel(false);
}
/**
* Get or create channel.
*/
- private synchronized ClientChannel getOrCreateChannel(boolean
ignoreThrottling)
+ private ClientChannel getOrCreateChannel(boolean ignoreThrottling)
throws ClientConnectionException, ClientAuthenticationException,
ClientProtocolError {
- if (ch == null) {
- if (!ignoreThrottling && applyReconnectionThrottling())
- throw new ClientConnectionException("Reconnect is not
allowed due to applied throttling");
+ if (ch == null && !close) {
+ synchronized (this) {
+ if (close)
+ return null;
+
+ if (ch != null)
+ return ch;
- ch = chFactory.apply(chCfg);
+ if (!ignoreThrottling && applyReconnectionThrottling())
+ throw new ClientConnectionException("Reconnect is not
allowed due to applied throttling");
- if (ch.serverNodeId() != null) {
-
ch.addTopologyChangeListener(ReliableChannel.this::onTopologyChanged);
- ch.addNotificationListener(ReliableChannel.this);
+ ClientChannel channel = chFactory.apply(chCfg);
- nodeChannels.values().remove(this);
+ if (channel.serverNodeId() != null) {
+
channel.addTopologyChangeListener(ReliableChannel.this::onTopologyChanged);
+ channel.addNotificationListener(ReliableChannel.this);
- nodeChannels.putIfAbsent(ch.serverNodeId(), this);
+ if (serverNodeId == null)
+ serverNodeId = channel.serverNodeId();
+
+ if (serverNodeId != null && serverNodeId !=
channel.serverNodeId())
+ nodeChannels.remove(serverNodeId);
Review comment:
fixed.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
##########
@@ -561,5 +746,24 @@ private synchronized void closeChannel() {
ch = null;
}
}
+
+ /** Close holder. */
+ void close() {
+ close = true;
+ if (serverNodeId != null)
+ nodeChannels.remove(serverNodeId);
Review comment:
fixed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]