Package org.dcache.xrootd.core
Class XrootdRequestHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- org.dcache.xrootd.core.XrootdRequestHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
XrootdAuthenticationHandler,XrootdAuthorizationHandler,XrootdProtocolRequestHandler,XrootdSessionHandler
public class XrootdRequestHandler extends io.netty.channel.ChannelInboundHandlerAdapterA ChannelInboundHandler to dispatch xrootd events to handler methods.Default response to all request messages from a client is kXR_Unsupported. Sub-classes may override handler methods to implement request handling.
Releases the reference to XrootdRequest if the handler method throws an exception or returns a response. If the handler returns null the subclass assumes responsibility to release the request, typically by passing it on the next ChannelHandler in the pipeline.
-
-
Constructor Summary
Constructors Constructor Description XrootdRequestHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelActive(io.netty.channel.ChannelHandlerContext ctx)voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg)protected java.lang.ObjectdoOnAuthentication(io.netty.channel.ChannelHandlerContext ctx, AuthenticationRequest msg)protected java.lang.ObjectdoOnClose(io.netty.channel.ChannelHandlerContext ctx, CloseRequest msg)protected java.lang.ObjectdoOnDirList(io.netty.channel.ChannelHandlerContext ctx, DirListRequest msg)protected java.lang.ObjectdoOnEndSession(io.netty.channel.ChannelHandlerContext ctx, EndSessionRequest request)protected java.lang.ObjectdoOnLocate(io.netty.channel.ChannelHandlerContext ctx, LocateRequest msg)protected java.lang.ObjectdoOnLogin(io.netty.channel.ChannelHandlerContext ctx, LoginRequest msg)protected java.lang.ObjectdoOnMkDir(io.netty.channel.ChannelHandlerContext ctx, MkDirRequest msg)protected java.lang.ObjectdoOnMv(io.netty.channel.ChannelHandlerContext ctx, MvRequest msg)protected java.lang.ObjectdoOnOpen(io.netty.channel.ChannelHandlerContext ctx, OpenRequest msg)protected java.lang.ObjectdoOnPrepare(io.netty.channel.ChannelHandlerContext ctx, PrepareRequest msg)protected java.lang.ObjectdoOnProtocolRequest(io.netty.channel.ChannelHandlerContext ctx, ProtocolRequest msg)protected java.lang.ObjectdoOnQuery(io.netty.channel.ChannelHandlerContext ctx, QueryRequest msg)protected java.lang.ObjectdoOnRead(io.netty.channel.ChannelHandlerContext ctx, ReadRequest msg)protected java.lang.ObjectdoOnReadV(io.netty.channel.ChannelHandlerContext ctx, ReadVRequest msg)protected java.lang.ObjectdoOnRm(io.netty.channel.ChannelHandlerContext ctx, RmRequest msg)protected java.lang.ObjectdoOnRmDir(io.netty.channel.ChannelHandlerContext ctx, RmDirRequest msg)protected java.lang.ObjectdoOnSet(io.netty.channel.ChannelHandlerContext ctx, SetRequest request)protected java.lang.ObjectdoOnStat(io.netty.channel.ChannelHandlerContext ctx, StatRequest msg)protected java.lang.ObjectdoOnStatx(io.netty.channel.ChannelHandlerContext ctx, StatxRequest msg)protected java.lang.ObjectdoOnSync(io.netty.channel.ChannelHandlerContext ctx, SyncRequest msg)protected java.lang.ObjectdoOnWrite(io.netty.channel.ChannelHandlerContext ctx, WriteRequest msg)protected java.net.InetSocketAddressgetDestinationAddress()The socket address the client connected to.protected java.lang.ObjectgetResponse(io.netty.channel.ChannelHandlerContext ctx, XrootdRequest req)protected java.net.InetSocketAddressgetSourceAddress()The socket address the client connected from.protected booleanisHealthCheck()True if this looks like a health check connection from a proxy server.protected voidrequestReceived(io.netty.channel.ChannelHandlerContext ctx, XrootdRequest req)protected io.netty.channel.ChannelFuturerespond(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object response)protected <T extends XrootdRequest>
XrootdResponse<T>unsupported(io.netty.channel.ChannelHandlerContext ctx, T msg)voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt)protected <T extends XrootdRequest>
ErrorResponse<T>withError(io.netty.channel.ChannelHandlerContext ctx, T req, int errorCode, java.lang.String errMsg)protected <T extends XrootdRequest>
OkResponse<T>withOk(T req)-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Method Detail
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
java.lang.Exception
-
channelRead
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg)- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt) throws java.lang.Exception- Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
java.lang.Exception
-
requestReceived
protected void requestReceived(io.netty.channel.ChannelHandlerContext ctx, XrootdRequest req)
-
getResponse
protected java.lang.Object getResponse(io.netty.channel.ChannelHandlerContext ctx, XrootdRequest req) throws java.lang.Exception- Throws:
java.lang.Exception
-
withOk
protected <T extends XrootdRequest> OkResponse<T> withOk(T req)
-
withError
protected <T extends XrootdRequest> ErrorResponse<T> withError(io.netty.channel.ChannelHandlerContext ctx, T req, int errorCode, java.lang.String errMsg)
-
respond
protected io.netty.channel.ChannelFuture respond(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object response)
-
unsupported
protected <T extends XrootdRequest> XrootdResponse<T> unsupported(io.netty.channel.ChannelHandlerContext ctx, T msg) throws XrootdException
- Throws:
XrootdException
-
doOnLogin
protected java.lang.Object doOnLogin(io.netty.channel.ChannelHandlerContext ctx, LoginRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnAuthentication
protected java.lang.Object doOnAuthentication(io.netty.channel.ChannelHandlerContext ctx, AuthenticationRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnOpen
protected java.lang.Object doOnOpen(io.netty.channel.ChannelHandlerContext ctx, OpenRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnStat
protected java.lang.Object doOnStat(io.netty.channel.ChannelHandlerContext ctx, StatRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnStatx
protected java.lang.Object doOnStatx(io.netty.channel.ChannelHandlerContext ctx, StatxRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnRead
protected java.lang.Object doOnRead(io.netty.channel.ChannelHandlerContext ctx, ReadRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnReadV
protected java.lang.Object doOnReadV(io.netty.channel.ChannelHandlerContext ctx, ReadVRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnWrite
protected java.lang.Object doOnWrite(io.netty.channel.ChannelHandlerContext ctx, WriteRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnSync
protected java.lang.Object doOnSync(io.netty.channel.ChannelHandlerContext ctx, SyncRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnClose
protected java.lang.Object doOnClose(io.netty.channel.ChannelHandlerContext ctx, CloseRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnProtocolRequest
protected java.lang.Object doOnProtocolRequest(io.netty.channel.ChannelHandlerContext ctx, ProtocolRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnRm
protected java.lang.Object doOnRm(io.netty.channel.ChannelHandlerContext ctx, RmRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnRmDir
protected java.lang.Object doOnRmDir(io.netty.channel.ChannelHandlerContext ctx, RmDirRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnMkDir
protected java.lang.Object doOnMkDir(io.netty.channel.ChannelHandlerContext ctx, MkDirRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnMv
protected java.lang.Object doOnMv(io.netty.channel.ChannelHandlerContext ctx, MvRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnDirList
protected java.lang.Object doOnDirList(io.netty.channel.ChannelHandlerContext ctx, DirListRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnPrepare
protected java.lang.Object doOnPrepare(io.netty.channel.ChannelHandlerContext ctx, PrepareRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnLocate
protected java.lang.Object doOnLocate(io.netty.channel.ChannelHandlerContext ctx, LocateRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnQuery
protected java.lang.Object doOnQuery(io.netty.channel.ChannelHandlerContext ctx, QueryRequest msg) throws XrootdException- Throws:
XrootdException
-
doOnSet
protected java.lang.Object doOnSet(io.netty.channel.ChannelHandlerContext ctx, SetRequest request) throws XrootdException- Throws:
XrootdException
-
doOnEndSession
protected java.lang.Object doOnEndSession(io.netty.channel.ChannelHandlerContext ctx, EndSessionRequest request) throws XrootdException- Throws:
XrootdException
-
getDestinationAddress
protected java.net.InetSocketAddress getDestinationAddress()
The socket address the client connected to. May be the local address of the channel, but could also be an address on a proxy server between the client and the server.
-
getSourceAddress
protected java.net.InetSocketAddress getSourceAddress()
The socket address the client connected from. May be the remote address of the channel, but in case a proxy is in between the client and the server, the source address will be a different from the remote address.
-
isHealthCheck
protected boolean isHealthCheck()
True if this looks like a health check connection from a proxy server.
-
-