Search in sources :

Example 1 with PnfsListDirectoryMessage

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

the class XrootdDoor method listPath.

/**
 * List the contents of a path, usually a directory. In order to make fragmented responses, as
 * supported by the xroot protocol, possible and not block the processing thread in the door,
 * this will register the passed callback along with the UUID of the message that is sent to
 * PNFS-manager.
 * <p>
 * Once PNFS-manager replies to the message, that callback is retrieved and the response is
 * processed by the callback.
 *
 * @param path        The path that is listed
 * @param restriction The Restriction in effect
 * @param subject     Representation of user that request listing
 * @param callback    The callback that will process the response
 */
public void listPath(FsPath path, Subject subject, Restriction restriction, MessageCallback<PnfsListDirectoryMessage> callback, EnumSet<FileAttribute> attributes) {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
    PnfsListDirectoryMessage msg = new PnfsListDirectoryMessage(path.toString(), null, Range.<Integer>all(), attributes);
    UUID uuid = msg.getUUID();
    try {
        DirlistRequestHandler requestHandler = new DirlistRequestHandler(uuid, pnfsHandler.getPnfsTimeout(), callback);
        _requestHandlers.put(uuid, requestHandler);
        pnfsHandler.send(msg);
        requestHandler.resetTimeout();
    } catch (RejectedExecutionException ree) {
        _requestHandlers.remove(uuid);
        callback.failure(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, ree.getMessage());
    }
}
Also used : PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) PnfsHandler(diskCacheV111.util.PnfsHandler) UUID(java.util.UUID) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with PnfsListDirectoryMessage

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

the class ListDirectoryHandler method list.

/**
 * Sends a directory list request to PnfsManager. The result is provided as a stream of
 * directory entries.
 * <p>
 * The method blocks until the first set of directory entries have been received from the
 * server.  Hence errors like FILE_NOT_FOUND are thrown by the call to the list method rather
 * than while iterating over the stream.
 * <p>
 * Note that supplied subject and restriction values will be overwritten if {@link
 * PnfsHandler#setSubject} or {@link PnfsHandler#setRestriction} have been called on the
 * underlying PnfsHandler instance.
 */
@Override
public DirectoryStream list(Subject subject, Restriction restriction, FsPath path, Glob pattern, Range<Integer> range, Set<FileAttribute> attributes) throws InterruptedException, CacheException {
    String dir = path.toString();
    PnfsListDirectoryMessage msg = new PnfsListDirectoryMessage(dir, pattern, range, attributes);
    UUID uuid = msg.getUUID();
    boolean success = false;
    Stream stream = new Stream(dir, uuid);
    try {
        msg.setSubject(subject);
        msg.setRestriction(restriction);
        _replies.put(uuid, stream);
        _pnfs.send(msg);
        stream.waitForMoreEntries();
        success = true;
        return stream;
    } finally {
        if (!success) {
            _replies.remove(uuid);
        }
    }
}
Also used : PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) UUID(java.util.UUID)

Example 3 with PnfsListDirectoryMessage

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

the class RemoteNameSpaceProviderTests method buildMessages.

private List<PnfsListDirectoryMessage> buildMessages(final CellMessage request, final Collection<DirectoryEntry>... replies) {
    List<PnfsListDirectoryMessage> messages = Lists.newArrayListWithExpectedSize(replies.length);
    for (int i = 0; i < replies.length; i++) {
        Collection<DirectoryEntry> entries = replies[i];
        boolean isLast = i == (replies.length - 1);
        CellMessage reply = buildListReply(request, entries, isLast, replies.length);
        messages.add((PnfsListDirectoryMessage) reply.getMessageObject());
    }
    return messages;
}
Also used : CellMessage(dmg.cells.nucleus.CellMessage) PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) DirectoryEntry(org.dcache.util.list.DirectoryEntry) CellEndpoint(dmg.cells.nucleus.CellEndpoint)

Example 4 with PnfsListDirectoryMessage

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

the class ListDirectoryHandler method listVirtualDirectory.

/**
 * Sends a virtual directory list request to PnfsManager. The result is
 * provided as a stream of files having the label value equale to the value of path param.
 * <p>
 * The method blocks until the first set of  entries have
 * been received from the server.  Hence errors like
 * FILE_NOT_FOUND are thrown by the call to the list method rather
 * than while iterating over the stream.
 * <p>
 * Note that supplied subject and restriction values will be overwritten if
 * {@link PnfsHandler#setSubject} or {@link PnfsHandler#setRestriction} have
 * been called on the underlying PnfsHandler instance.
 */
@Override
public DirectoryStream listVirtualDirectory(Subject subject, Restriction restriction, FsPath path, Range<Integer> range, Set<FileAttribute> attributes) throws InterruptedException, CacheException {
    String dir = path.toString();
    PnfsListDirectoryMessage msg = new PnfsListDirectoryMessage(dir, null, range, attributes);
    UUID uuid = msg.getUUID();
    boolean success = false;
    Stream stream = new Stream(dir, uuid);
    try {
        msg.setPathType(PnfsListDirectoryMessage.PathType.LABEL);
        msg.setSubject(subject);
        msg.setRestriction(restriction);
        _replies.put(uuid, stream);
        _pnfs.send(msg);
        stream.waitForMoreEntries();
        success = true;
        return stream;
    } finally {
        if (!success) {
            _replies.remove(uuid);
        }
    }
}
Also used : PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) UUID(java.util.UUID)

Aggregations

PnfsListDirectoryMessage (org.dcache.vehicles.PnfsListDirectoryMessage)4 UUID (java.util.UUID)3 PnfsHandler (diskCacheV111.util.PnfsHandler)1 CellEndpoint (dmg.cells.nucleus.CellEndpoint)1 CellMessage (dmg.cells.nucleus.CellMessage)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 DirectoryEntry (org.dcache.util.list.DirectoryEntry)1