Skip to content

Commit

Permalink
pool: report dcap local endpoint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kofemann committed Sep 11, 2023
1 parent 52602da commit effabfe
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,6 +73,7 @@ public class DCapProtocol_3_nio implements MoverProtocol, ChecksumMover, CellArg

private Consumer<Checksum> _integrityChecker;

private volatile InetSocketAddress _localEndpoint;

// bind passive dcap to port defined as org.dcache.dcap.port
private static ProtocolConnectionPoolFactory factory;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1025,4 +1028,9 @@ public long getTransferTime() {
System.currentTimeMillis() - _transferStarted :
_transferTime;
}

@Override
public Optional<InetSocketAddress> getLocalEndpoint() {
return Optional.ofNullable(_localEndpoint);
}
}

0 comments on commit effabfe

Please sign in to comment.