diff --git a/xrootd4j-standalone/src/main/java/org/dcache/xrootd/standalone/DataServerHandler.java b/xrootd4j-standalone/src/main/java/org/dcache/xrootd/standalone/DataServerHandler.java index fe08bb27..7ba78b59 100644 --- a/xrootd4j-standalone/src/main/java/org/dcache/xrootd/standalone/DataServerHandler.java +++ b/xrootd4j-standalone/src/main/java/org/dcache/xrootd/standalone/DataServerHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2011-2024 dCache.org + * Copyright (C) 2011-2026 dCache.org * * This file is part of xrootd4j. * @@ -63,6 +63,8 @@ import org.dcache.xrootd.protocol.messages.OkResponse; import org.dcache.xrootd.protocol.messages.OpenRequest; import org.dcache.xrootd.protocol.messages.OpenResponse; +import org.dcache.xrootd.protocol.messages.PingRequest; +import org.dcache.xrootd.protocol.messages.PingResponse; import org.dcache.xrootd.protocol.messages.PrepareRequest; import org.dcache.xrootd.protocol.messages.PrepareResponse; import org.dcache.xrootd.protocol.messages.QueryRequest; @@ -281,6 +283,12 @@ protected DirListResponse doOnDirList(ChannelHandlerContext context, } } + @Override + protected PingResponse doOnPing(ChannelHandlerContext ctx, + PingRequest msg) throws XrootdException { + return new PingResponse(msg, kXR_ok); + } + @Override protected PrepareResponse doOnPrepare(ChannelHandlerContext ctx, PrepareRequest msg) throws XrootdException { diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/core/AbstractXrootdDecoder.java b/xrootd4j/src/main/java/org/dcache/xrootd/core/AbstractXrootdDecoder.java index 79d1b7ad..b1d5f128 100644 --- a/xrootd4j/src/main/java/org/dcache/xrootd/core/AbstractXrootdDecoder.java +++ b/xrootd4j/src/main/java/org/dcache/xrootd/core/AbstractXrootdDecoder.java @@ -1,16 +1,16 @@ /** - * Copyright (C) 2011-2023 dCache.org - * + * Copyright (C) 2011-2026 dCache.org + * * This file is part of xrootd4j. - * + * * xrootd4j is free software: you can redistribute it and/or modify it under the terms of the GNU * Lesser General Public License as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * xrootd4j is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License along with xrootd4j. If * not, see http://www.gnu.org/licenses/. */ @@ -28,6 +28,7 @@ import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_mkdir; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_mv; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_open; +import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_ping; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_prepare; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_protocol; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_query; @@ -58,6 +59,7 @@ import org.dcache.xrootd.protocol.messages.MkDirRequest; import org.dcache.xrootd.protocol.messages.MvRequest; import org.dcache.xrootd.protocol.messages.OpenRequest; +import org.dcache.xrootd.protocol.messages.PingRequest; import org.dcache.xrootd.protocol.messages.PrepareRequest; import org.dcache.xrootd.protocol.messages.ProtocolRequest; import org.dcache.xrootd.protocol.messages.QueryRequest; @@ -132,6 +134,8 @@ protected XrootdRequest getRequest(ByteBuf frame) { LoginRequest request = new LoginRequest(frame); sessionToken = request.getToken(); return request; + case kXR_ping: + return new PingRequest(frame); case kXR_prepare: return new PrepareRequest(frame); case kXR_open: diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/core/XrootdAuthorizationHandler.java b/xrootd4j/src/main/java/org/dcache/xrootd/core/XrootdAuthorizationHandler.java index a6db383f..109783b9 100644 --- a/xrootd4j/src/main/java/org/dcache/xrootd/core/XrootdAuthorizationHandler.java +++ b/xrootd4j/src/main/java/org/dcache/xrootd/core/XrootdAuthorizationHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2011-2023 dCache.org + * Copyright (C) 2011-2026 dCache.org * * This file is part of xrootd4j. * @@ -36,6 +36,7 @@ import org.dcache.xrootd.protocol.messages.MvRequest; import org.dcache.xrootd.protocol.messages.OpenRequest; import org.dcache.xrootd.protocol.messages.PathRequest; +import org.dcache.xrootd.protocol.messages.PingRequest; import org.dcache.xrootd.protocol.messages.PrepareRequest; import org.dcache.xrootd.protocol.messages.ProtocolRequest; import org.dcache.xrootd.protocol.messages.QueryRequest; @@ -175,6 +176,12 @@ protected Void doOnDirList(ChannelHandlerContext ctx, DirListRequest request) return null; } + @Override + protected Void doOnPing(ChannelHandlerContext ctx, PingRequest msg) { + ctx.fireChannelRead(msg); + return null; + } + @Override protected Void doOnPrepare(ChannelHandlerContext ctx, PrepareRequest msg) { ctx.fireChannelRead(msg); diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/core/XrootdRequestHandler.java b/xrootd4j/src/main/java/org/dcache/xrootd/core/XrootdRequestHandler.java index 397abe7f..7653a60f 100644 --- a/xrootd4j/src/main/java/org/dcache/xrootd/core/XrootdRequestHandler.java +++ b/xrootd4j/src/main/java/org/dcache/xrootd/core/XrootdRequestHandler.java @@ -29,6 +29,7 @@ import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_mkdir; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_mv; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_open; +import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_ping; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_prepare; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_protocol; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_query; @@ -67,6 +68,7 @@ import org.dcache.xrootd.protocol.messages.MvRequest; import org.dcache.xrootd.protocol.messages.OkResponse; import org.dcache.xrootd.protocol.messages.OpenRequest; +import org.dcache.xrootd.protocol.messages.PingRequest; import org.dcache.xrootd.protocol.messages.PrepareRequest; import org.dcache.xrootd.protocol.messages.ProtocolRequest; import org.dcache.xrootd.protocol.messages.QueryRequest; @@ -237,6 +239,8 @@ protected Object getResponse(ChannelHandlerContext ctx, XrootdRequest req) return doOnMv(ctx, (MvRequest) req); case kXR_dirlist: return doOnDirList(ctx, (DirListRequest) req); + case kXR_ping: + return doOnPing(ctx, (PingRequest) req); case kXR_prepare: return doOnPrepare(ctx, (PrepareRequest) req); case kXR_locate: @@ -378,6 +382,12 @@ protected Object doOnDirList(ChannelHandlerContext ctx, return unsupported(ctx, msg); } + protected Object doOnPing(ChannelHandlerContext ctx, + PingRequest msg) + throws XrootdException { + return unsupported(ctx, msg); + } + protected Object doOnPrepare(ChannelHandlerContext ctx, PrepareRequest msg) throws XrootdException { diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/PingRequest.java b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/PingRequest.java new file mode 100644 index 00000000..d87cc2f1 --- /dev/null +++ b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/PingRequest.java @@ -0,0 +1,76 @@ +/* +COPYRIGHT STATUS: +Dec 1st 2001, Fermi National Accelerator Laboratory (FNAL) documents and +software are sponsored by the U.S. Department of Energy under Contract No. +DE-AC02-76CH03000. Therefore, the U.S. Government retains a world-wide +non-exclusive, royalty-free license to publish or reproduce these documents +and software for U.S. Government purposes. All documents and software +available from this server are protected under the U.S. and Foreign +Copyright Laws, and FNAL reserves all rights. + +Distribution of the software available from this server is free of +charge subject to the user following the terms of the Fermitools +Software Legal Information. + +Redistribution and/or modification of the software shall be accompanied +by the Fermitools Software Legal Information (including the copyright +notice). + +The user is asked to feed back problems, benefits, and/or suggestions +about the software to the Fermilab Software Providers. + +Neither the name of Fermilab, the URA, nor the names of the contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +DISCLAIMER OF LIABILITY (BSD): + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FERMILAB, +OR THE URA, OR THE U.S. DEPARTMENT of ENERGY, OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Liabilities of the Government: + +This software is provided by URA, independent from its Prime Contract +with the U.S. Department of Energy. URA is acting independently from +the Government and in its own private capacity and is not acting on +behalf of the U.S. Government, nor as its contractor nor its agent. +Correspondingly, it is understood and agreed that the U.S. Government +has no connection to this software and in no manner whatsoever shall +be liable for nor assume any responsibility or obligation for any claim, +cost, or damages arising out of or resulting from the use of the software +available from this server. + +Export Control: + +All documents and software available from this server are subject to U.S. +export control laws. Anyone downloading information from this server is +obligated to secure any necessary Government licenses before exporting +documents or software obtained from this server. +*/ +package org.dcache.xrootd.protocol.messages; + +import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_ping; + +import io.netty.buffer.ByteBuf; + +public class PingRequest extends AbstractXrootdRequest { + + public PingRequest(ByteBuf buffer) { + super(buffer, kXR_ping); + } + + @Override + public String toString() { + return String.format("ping[%d,%d]", getStreamId(), getRequestId()); + } +} diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/PingResponse.java b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/PingResponse.java new file mode 100644 index 00000000..ca750221 --- /dev/null +++ b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/PingResponse.java @@ -0,0 +1,79 @@ +/* +COPYRIGHT STATUS: +Dec 1st 2001, Fermi National Accelerator Laboratory (FNAL) documents and +software are sponsored by the U.S. Department of Energy under Contract No. +DE-AC02-76CH03000. Therefore, the U.S. Government retains a world-wide +non-exclusive, royalty-free license to publish or reproduce these documents +and software for U.S. Government purposes. All documents and software +available from this server are protected under the U.S. and Foreign +Copyright Laws, and FNAL reserves all rights. + +Distribution of the software available from this server is free of +charge subject to the user following the terms of the Fermitools +Software Legal Information. + +Redistribution and/or modification of the software shall be accompanied +by the Fermitools Software Legal Information (including the copyright +notice). + +The user is asked to feed back problems, benefits, and/or suggestions +about the software to the Fermilab Software Providers. + +Neither the name of Fermilab, the URA, nor the names of the contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +DISCLAIMER OF LIABILITY (BSD): + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FERMILAB, +OR THE URA, OR THE U.S. DEPARTMENT of ENERGY, OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Liabilities of the Government: + +This software is provided by URA, independent from its Prime Contract +with the U.S. Department of Energy. URA is acting independently from +the Government and in its own private capacity and is not acting on +behalf of the U.S. Government, nor as its contractor nor its agent. +Correspondingly, it is understood and agreed that the U.S. Government +has no connection to this software and in no manner whatsoever shall +be liable for nor assume any responsibility or obligation for any claim, +cost, or damages arising out of or resulting from the use of the software +available from this server. + +Export Control: + +All documents and software available from this server are subject to U.S. +export control laws. Anyone downloading information from this server is +obligated to secure any necessary Government licenses before exporting +documents or software obtained from this server. +*/ +package org.dcache.xrootd.protocol.messages; + +import io.netty.buffer.ByteBuf; + +public class PingResponse extends AbstractXrootdResponse { + + final int response = 0; + public PingResponse(PingRequest request, int status) { + super(request, status); + } + + @Override + public int getDataLength() { + return 1; + } + @Override + protected void getBytes(ByteBuf buffer) { + buffer.writeInt(response); + } +}