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