Search in sources :

Example 1 with FlushRequest

use of org.dcache.pool.nearline.spi.FlushRequest in project dcache by dCache.

the class AbstractBlockingNearlineStorage method flush.

@Override
public void flush(Iterable<FlushRequest> requests) {
    for (FlushRequest request : requests) {
        Task<FlushRequest, Set<URI>> task = new Task<FlushRequest, Set<URI>>(request) {

            @Override
            public Set<URI> call() throws Exception {
                FileAttributes fileAttributes = request.getFileAttributes();
                NDC.push(fileAttributes.getPnfsId().toString());
                try {
                    return flush(request);
                } finally {
                    NDC.pop();
                }
            }

            @Override
            protected void execute() {
                getFlushExecutor().execute(this);
            }
        };
        task.execute();
    }
}
Also used : Set(java.util.Set) FlushRequest(org.dcache.pool.nearline.spi.FlushRequest) URI(java.net.URI) FileAttributes(org.dcache.vehicles.FileAttributes)

Example 2 with FlushRequest

use of org.dcache.pool.nearline.spi.FlushRequest in project dcache-cta by dCache.

the class DataServerHandler method doOnOpen.

/**
 * Obtains the right mover instance using an opaque token in the request and instruct the mover
 * to open the file in the request. Associates the mover with the file-handle that is produced
 * during processing
 */
@Override
protected OpenResponse doOnOpen(ChannelHandlerContext ctx, OpenRequest msg) throws XrootdException {
    try {
        var pr = getIORequest(msg.getPath());
        var r = pr.getRequest();
        var file = getFile(r);
        LOGGER.info("Request {} scheduling time: {}", file, TimeUtils.describe(Duration.between(Instant.now(), pr.getSubmissionTime()).abs()).orElse("-"));
        RandomAccessFile raf;
        if (msg.isReadWrite() || msg.isNew() || msg.isDelete()) {
            if (!(r instanceof StageRequest)) {
                throw new XrootdException(kXR_ArgInvalid, "An attempt to open-for-read for stage requests");
            }
            LOGGER.info("Opening {} for writing", file);
            raf = new RandomAccessFile(file, "rw");
            if (msg.isDelete()) {
                raf.setLength(0);
            }
        } else {
            if (!(r instanceof FlushRequest)) {
                throw new XrootdException(kXR_ArgInvalid, "An attempt to open-for-write for flush requests");
            }
            LOGGER.info("Opening {} for reading.", file);
            raf = new RandomAccessFile(file, "r");
        }
        FileStatus stat = null;
        if (msg.isRetStat()) {
            stat = statusByFile(file);
        }
        var migrationRequest = new MigrationRequest(r, raf);
        int fd = addOpenFile(migrationRequest);
        return new OpenResponse(msg, fd, null, null, stat);
    } catch (FileNotFoundException e) {
        throw new XrootdException(kXR_NotFound, e.getMessage());
    } catch (IOException e) {
        throw new XrootdException(kXR_IOError, e.getMessage());
    }
}
Also used : FileStatus(org.dcache.xrootd.util.FileStatus) RandomAccessFile(java.io.RandomAccessFile) StageRequest(org.dcache.pool.nearline.spi.StageRequest) FlushRequest(org.dcache.pool.nearline.spi.FlushRequest) OpenResponse(org.dcache.xrootd.protocol.messages.OpenResponse) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) XrootdException(org.dcache.xrootd.core.XrootdException)

Aggregations

FlushRequest (org.dcache.pool.nearline.spi.FlushRequest)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 URI (java.net.URI)1 Set (java.util.Set)1 StageRequest (org.dcache.pool.nearline.spi.StageRequest)1 FileAttributes (org.dcache.vehicles.FileAttributes)1 XrootdException (org.dcache.xrootd.core.XrootdException)1 OpenResponse (org.dcache.xrootd.protocol.messages.OpenResponse)1 FileStatus (org.dcache.xrootd.util.FileStatus)1