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());
}
}
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;
}
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());
}
}
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);
}
Aggregations