Search in sources :

Example 1 with XrootdProtocolInfo

use of org.dcache.vehicles.XrootdProtocolInfo in project dcache by dCache.

the class XrootdDoor method messageArrived.

public void messageArrived(DoorTransferFinishedMessage msg) {
    if ((msg.getProtocolInfo() instanceof XrootdProtocolInfo)) {
        XrootdProtocolInfo info = (XrootdProtocolInfo) msg.getProtocolInfo();
        XrootdTransfer transfer = _transfers.get(info.getXrootdFileHandle());
        if (transfer != null) {
            transfer.finished(msg);
        }
    } else {
        _log.warn("Ignoring unknown protocol info {} from pool {}", msg.getProtocolInfo(), msg.getPoolName());
    }
}
Also used : XrootdProtocolInfo(org.dcache.vehicles.XrootdProtocolInfo)

Example 2 with XrootdProtocolInfo

use of org.dcache.vehicles.XrootdProtocolInfo in project dcache by dCache.

the class XrootdTransfer method getProtocolInfoForPool.

@Override
protected ProtocolInfo getProtocolInfoForPool() {
    XrootdProtocolInfo info = createXrootdProtocolInfo();
    info.setDelegatedCredential(_delegatedCredential);
    info.setRestriction(restriction);
    /*
         * In order to conform with xroot unix protocol if (a) we do TPC from a dCache source
         * (b) signed hash verification is on rather than TLS.
         */
    info.setTpcUid(tpcInfo.getUid());
    info.setTpcGid(tpcInfo.getGid());
    info.setOverwriteAllowed(_isOverwriteAllowed);
    return info;
}
Also used : XrootdProtocolInfo(org.dcache.vehicles.XrootdProtocolInfo)

Example 3 with XrootdProtocolInfo

use of org.dcache.vehicles.XrootdProtocolInfo in project dcache by dCache.

the class XrootdPoolRequestHandler method doOnOpen.

/**
 * Obtains the right mover channel using an opaque token in the request. The mover channel is
 * wrapped by a file descriptor. The file descriptor is stored for subsequent access.
 * <p>
 * In the case that this is a write request as destination in a third party copy, a third-party
 * client is started.  The client issues login, open and read requests to the source server, and
 * writes the responses to the file descriptor.
 * <p>
 * The third-party client also sends a sync response back to the client when the transfer has
 * completed.
 */
@Override
protected XrootdResponse<OpenRequest> doOnOpen(ChannelHandlerContext ctx, OpenRequest msg) throws XrootdException {
    try {
        Map<String, String> opaqueMap = getOpaqueMap(msg.getOpaque());
        UUID uuid = getUuid(opaqueMap);
        if (uuid == null) {
            _log.info("Request to open {} contains no UUID.", msg.getPath());
            throw new XrootdException(kXR_NotAuthorized, "Request lacks the " + UUID_PREFIX + " property.");
        }
        enforceClientTlsIfDestinationRequiresItForTpc(opaqueMap);
        NettyTransferService<XrootdProtocolInfo>.NettyMoverChannel file = _server.openFile(uuid, false);
        if (file == null) {
            _log.info("No mover found for {} with UUID {}.", msg.getPath(), uuid);
            return redirectToDoor(ctx, msg, () -> {
                throw new XrootdException(kXR_NotAuthorized, UUID_PREFIX + " is no longer valid.");
            });
        }
        /*
             *  Stop any timer in case this is a reconnect.
             */
        _server.cancelReconnectTimeoutForMover(uuid);
        _log.debug("doOnOpen, called cancel on reconnect timers for {}", uuid);
        XrootdProtocolInfo protocolInfo = file.getProtocolInfo();
        try {
            FileDescriptor descriptor;
            boolean isWrite = file.getIoMode().contains(StandardOpenOption.WRITE);
            if (msg.isNew() && !isWrite) {
                throw new XrootdException(kXR_FileNotOpen, "File exists.");
            } else if (msg.isDelete() && !isWrite) {
                throw new XrootdException(kXR_Unsupported, "File exists.");
            /*
                     *  Some clients express only kXR_delete when then intend to write
                     *  so we need to consider delete as a write request here.
                     */
            } else if ((msg.isNew() || msg.isReadWrite() || msg.isDelete()) && isWrite) {
                boolean posc = (msg.getOptions() & kXR_posc) == kXR_posc || protocolInfo.getFlags().contains(XrootdProtocolInfo.Flags.POSC);
                if (opaqueMap.containsKey("tpc.src")) {
                    _log.debug("Request to open {} is as third-party destination.", msg);
                    XrootdTpcInfo tpcInfo = new XrootdTpcInfo(opaqueMap);
                    tpcInfo.setDelegatedProxy(protocolInfo.getDelegatedCredential());
                    tpcInfo.setUid(protocolInfo.getTpcUid());
                    tpcInfo.setGid(protocolInfo.getTpcGid());
                    descriptor = new TpcWriteDescriptor(file, posc, ctx, _server, opaqueMap.get("org.dcache.xrootd.client"), tpcInfo, tlsSessionInfo);
                } else {
                    descriptor = new WriteDescriptor(file, posc);
                }
            } else {
                descriptor = new ReadDescriptor(file);
            }
            FileStatus stat = msg.isRetStat() ? stat(file) : null;
            int fd = addDescriptor(descriptor);
            _redirectingDoor = protocolInfo.getDoorAddress();
            file = null;
            _hasOpenedFiles = true;
            return new OpenResponse(msg, fd, null, null, stat);
        } finally {
            if (file != null) {
                file.release();
            }
        }
    } catch (ParseException e) {
        throw new XrootdException(kXR_ArgInvalid, e.getMessage());
    } catch (IOException e) {
        throw new XrootdException(kXR_IOError, e.getMessage());
    }
}
Also used : NettyTransferService(org.dcache.pool.movers.NettyTransferService) FileStatus(org.dcache.xrootd.util.FileStatus) XrootdProtocolInfo(org.dcache.vehicles.XrootdProtocolInfo) IOException(java.io.IOException) TpcWriteDescriptor(org.dcache.xrootd.tpc.TpcWriteDescriptor) XrootdTpcInfo(org.dcache.xrootd.tpc.XrootdTpcInfo) OpenResponse(org.dcache.xrootd.protocol.messages.OpenResponse) ParseException(org.dcache.xrootd.util.ParseException) UUID(java.util.UUID) XrootdException(org.dcache.xrootd.core.XrootdException) TpcWriteDescriptor(org.dcache.xrootd.tpc.TpcWriteDescriptor)

Example 4 with XrootdProtocolInfo

use of org.dcache.vehicles.XrootdProtocolInfo in project dcache by dCache.

the class XrootdTransferService method sendAddressToDoor.

/**
 * Sends our address to the door. Copied from the old xrootd mover.
 */
@Override
protected void sendAddressToDoor(NettyMover<XrootdProtocolInfo> mover, int port) throws SocketException, CacheException {
    XrootdProtocolInfo protocolInfo = mover.getProtocolInfo();
    InetAddress localIP = NetworkUtils.getLocalAddress(protocolInfo.getSocketAddress().getAddress());
    CellPath cellpath = protocolInfo.getXrootdDoorCellPath();
    XrootdDoorAdressInfoMessage doorMsg = new XrootdDoorAdressInfoMessage(protocolInfo.getXrootdFileHandle(), new InetSocketAddress(localIP, port));
    doorStub.notify(cellpath, doorMsg);
    LOGGER.debug("sending redirect {} to Xrootd-door {}", localIP, cellpath);
}
Also used : CellPath(dmg.cells.nucleus.CellPath) XrootdDoorAdressInfoMessage(org.dcache.vehicles.XrootdDoorAdressInfoMessage) InetSocketAddress(java.net.InetSocketAddress) XrootdProtocolInfo(org.dcache.vehicles.XrootdProtocolInfo) InetAddress(java.net.InetAddress)

Aggregations

XrootdProtocolInfo (org.dcache.vehicles.XrootdProtocolInfo)4 CellPath (dmg.cells.nucleus.CellPath)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 UUID (java.util.UUID)1 NettyTransferService (org.dcache.pool.movers.NettyTransferService)1 XrootdDoorAdressInfoMessage (org.dcache.vehicles.XrootdDoorAdressInfoMessage)1 XrootdException (org.dcache.xrootd.core.XrootdException)1 OpenResponse (org.dcache.xrootd.protocol.messages.OpenResponse)1 TpcWriteDescriptor (org.dcache.xrootd.tpc.TpcWriteDescriptor)1 XrootdTpcInfo (org.dcache.xrootd.tpc.XrootdTpcInfo)1 FileStatus (org.dcache.xrootd.util.FileStatus)1 ParseException (org.dcache.xrootd.util.ParseException)1