From effabfe73794b3f29b50d3906febeb1512fbc81d Mon Sep 17 00:00:00 2001 From: Tigran Mkrtchyan Date: Mon, 11 Sep 2023 10:31:47 +0200 Subject: [PATCH] pool: report dcap local endpoint Motivation: make all movers to provide the same information Result: dcache mover will report local endpoint address Acked-by: Paul Millar Target: master Require-book: no Require-notes: yes --- .../java/org/dcache/pool/movers/DCapProtocol_3_nio.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/dcache-dcap/src/main/java/org/dcache/pool/movers/DCapProtocol_3_nio.java b/modules/dcache-dcap/src/main/java/org/dcache/pool/movers/DCapProtocol_3_nio.java index bb7f14720b9..aa93f307ed2 100644 --- a/modules/dcache-dcap/src/main/java/org/dcache/pool/movers/DCapProtocol_3_nio.java +++ b/modules/dcache-dcap/src/main/java/org/dcache/pool/movers/DCapProtocol_3_nio.java @@ -25,6 +25,7 @@ import java.nio.channels.SocketChannel; import java.nio.file.OpenOption; import java.nio.file.StandardOpenOption; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.function.Consumer; @@ -72,6 +73,7 @@ public class DCapProtocol_3_nio implements MoverProtocol, ChecksumMover, CellArg private Consumer _integrityChecker; + private volatile InetSocketAddress _localEndpoint; // bind passive dcap to port defined as org.dcache.dcap.port private static ProtocolConnectionPoolFactory factory; @@ -294,6 +296,7 @@ public void runIO(FileAttributes fileAttributes, } Socket socket = socketChannel.socket(); + _localEndpoint = new InetSocketAddress(socket.getLocalAddress(), socket.getLocalPort()); socket.setKeepAlive(true); socket.setTcpNoDelay(true); if (bufferSize.getSendBufferSize() > 0) { @@ -1025,4 +1028,9 @@ public long getTransferTime() { System.currentTimeMillis() - _transferStarted : _transferTime; } + + @Override + public Optional getLocalEndpoint() { + return Optional.ofNullable(_localEndpoint); + } }