mirror of https://github.com/apache/nifi.git
NIFI-4391 Ensuring channel is closed when unable to connect in SocketChannelSender
NIFI-4391 Adding debug logging of client port upon connection Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #2159.
This commit is contained in:
parent
7b07eb0577
commit
a813ae113e
|
@ -24,6 +24,7 @@ import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.SocketAddress;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.StandardSocketOptions;
|
import java.net.StandardSocketOptions;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
|
@ -42,6 +43,7 @@ public class SocketChannelSender extends ChannelSender {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open() throws IOException {
|
public void open() throws IOException {
|
||||||
|
try {
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
channel = SocketChannel.open();
|
channel = SocketChannel.open();
|
||||||
channel.configureBlocking(false);
|
channel.configureBlocking(false);
|
||||||
|
@ -74,9 +76,21 @@ public class SocketChannelSender extends ChannelSender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
final SocketAddress localAddress = channel.getLocalAddress();
|
||||||
|
if (localAddress != null && localAddress instanceof InetSocketAddress) {
|
||||||
|
final InetSocketAddress inetSocketAddress = (InetSocketAddress) localAddress;
|
||||||
|
logger.debug("Connected to local port {}", new Object[] {inetSocketAddress.getPort()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
socketChannelOutput = new SocketChannelOutputStream(channel);
|
socketChannelOutput = new SocketChannelOutputStream(channel);
|
||||||
socketChannelOutput.setTimeout(timeout);
|
socketChannelOutput.setTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
} catch (final IOException e) {
|
||||||
|
IOUtils.closeQuietly(channel);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1305,7 +1305,8 @@ public class ProcessGroupResource extends ApplicationResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void activateControllerServices(final String groupId, final URI originalUri, final VariableRegistryUpdateRequest updateRequest,
|
private void activateControllerServices(final String groupId, final URI originalUri, final VariableRegistryUpdateRequest updateRequest,
|
||||||
final Pause pause, final Collection<AffectedComponentDTO> affectedServices, final ControllerServiceState desiredState, final VariableRegistryUpdateStep updateStep) throws InterruptedException {
|
final Pause pause, final Collection<AffectedComponentDTO> affectedServices, final ControllerServiceState desiredState, final VariableRegistryUpdateStep updateStep)
|
||||||
|
throws InterruptedException {
|
||||||
|
|
||||||
final Set<String> affectedServiceIds = affectedServices.stream()
|
final Set<String> affectedServiceIds = affectedServices.stream()
|
||||||
.map(component -> component.getId())
|
.map(component -> component.getId())
|
||||||
|
|
Loading…
Reference in New Issue