NIFI-1301: Ensure that when creating site-to-site connection, if remote instance is applying backpressure that we do not block indefinitely waiting for the connection to be made

Signed-off-by: joewitt <joewitt@apache.org>
This commit is contained in:
Mark Payne 2015-12-17 15:40:00 -05:00 committed by joewitt
parent 608287f9fe
commit bef3fc8b40

View File

@ -250,6 +250,8 @@ public class EndpointConnectionPool {
EndpointConnection connection;
Peer peer = null;
do {
final List<EndpointConnection> addBack = new ArrayList<>();
logger.debug("{} getting next peer status", this);
final PeerStatus peerStatus = getNextPeerStatus(direction);
logger.debug("{} next peer status = {}", this, peerStatus);
@ -267,9 +269,7 @@ public class EndpointConnectionPool {
}
}
final List<EndpointConnection> addBack = new ArrayList<>();
try {
do {
connection = connectionQueue.poll();
logger.debug("{} Connection State for {} = {}", this, clusterUrl, connection);
final String portId = getPortIdentifier(direction);
@ -387,7 +387,6 @@ public class EndpointConnectionPool {
protocol = connection.getSocketClientProtocol();
}
}
} while (connection == null || codec == null || commsSession == null || protocol == null);
} catch (final Throwable t) {
if (commsSession != null) {
try {
@ -400,9 +399,12 @@ public class EndpointConnectionPool {
} finally {
if (!addBack.isEmpty()) {
connectionQueue.addAll(addBack);
addBack.clear();
}
}
} while (connection == null || codec == null || commsSession == null || protocol == null);
activeConnections.add(connection);
return connection;
}
@ -773,7 +775,7 @@ public class EndpointConnectionPool {
final StringBuilder distributionDescription = new StringBuilder();
distributionDescription.append("New Weighted Distribution of Nodes:");
for (final Map.Entry<NodeInformation, Integer> entry : entryCountMap.entrySet()) {
final double percentage = entry.getValue() * 100D / (double) destinations.size();
final double percentage = entry.getValue() * 100D / destinations.size();
distributionDescription.append("\n").append(entry.getKey()).append(" will receive ").append(percentage).append("% of data");
}
logger.info(distributionDescription.toString());