Search in sources :

Example 21 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class XrootdDoor method deleteFile.

/**
 * Delete the file denoted by path from the namespace
 *
 * @param path The path of the file that is going to be deleted
 * @throws CacheException                 Deletion of the file failed
 * @throws PermissionDeniedCacheException Caller does not have permission to delete the file
 */
public void deleteFile(FsPath path, Subject subject, Restriction restriction) throws PermissionDeniedCacheException, CacheException {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
    if (!isWriteAllowed(path)) {
        throw new PermissionDeniedCacheException("Write permission denied");
    }
    Set<FileType> allowedSet = EnumSet.of(FileType.REGULAR);
    PnfsId pnfsId = pnfsHandler.deletePnfsEntry(path.toString(), allowedSet);
    sendRemoveInfoToBilling(pnfsId, path, subject);
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileType(org.dcache.namespace.FileType) PnfsId(diskCacheV111.util.PnfsId) PnfsHandler(diskCacheV111.util.PnfsHandler)

Example 22 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class DcacheResourceFactory method deleteDirectory.

/**
 * Deletes a directory.
 */
public void deleteDirectory(PnfsId pnfsid, FsPath path) throws CacheException {
    PnfsHandler pnfs = roleAwarePnfsHandler();
    pnfs.deletePnfsEntry(pnfsid, path.toString(), EnumSet.of(DIR), EnumSet.noneOf(FileAttribute.class));
}
Also used : PnfsHandler(diskCacheV111.util.PnfsHandler) FileAttribute(org.dcache.namespace.FileAttribute)

Example 23 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class DefaultInaccessibleFileHandler method handleNoLocationsForFile.

@Override
protected Type handleNoLocationsForFile(FileOperation operation) {
    PnfsId pnfsId = operation.getPnfsId();
    LOGGER.error(AlarmMarkerFactory.getMarker(PredefinedAlarm.LOST_RESILIENT_FILE, pnfsId.toString()), MISSING_LOCATIONS_MESSAGE, pnfsId);
    String error = String.format("%s has no locations.", pnfsId);
    CacheException exception = CacheExceptionUtils.getCacheException(CacheException.PANIC, FileTaskCompletionHandler.VERIFY_FAILURE_MESSAGE, pnfsId, Type.VOID, error, null);
    completionHandler.taskFailed(pnfsId, exception);
    return Type.VOID;
}
Also used : CacheException(diskCacheV111.util.CacheException) PnfsId(diskCacheV111.util.PnfsId)

Example 24 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class FileOperationHandler method handleStaging.

/**
 * <p>Called when there are no available replicas, but the file
 * can be retrieved from an HSM.</p>
 *
 * <p>Issues a fire and forget request.  Task is considered complete at
 * that point.</p>
 *
 * <p>When staging actually completes on the PoolManager end, the new
 * cache location message should be processed by Resilience as a new FileOperation.</p>
 *
 * <p>Should staging not complete before the pool is once again scanned,
 * PoolManager should collapse the repeated staging request.</p>
 */
public void handleStaging(PnfsId pnfsId, ResilientFileTask task) {
    try {
        FileOperation operation = fileOpMap.getOperation(pnfsId);
        FileAttributes attributes = namespace.getRequiredAttributesForStaging(pnfsId);
        String poolGroup = poolInfoMap.getGroup(operation.getPoolGroup());
        LOGGER.trace("handleStaging {}, pool group {}.", pnfsId, poolGroup);
        migrationTaskService.schedule(() -> {
            try {
                PoolMgrSelectReadPoolMsg msg = new PoolMgrSelectReadPoolMsg(attributes, getProtocolInfo(), null);
                msg.setSubject(Subjects.ROOT);
                msg.setPoolGroup(poolGroup);
                CellMessage cellMessage = new CellMessage(new CellPath(poolManagerAddress), msg);
                ACTIVITY_LOGGER.info("Staging {}", pnfsId);
                endpoint.sendMessage(cellMessage);
                LOGGER.trace("handleStaging, sent select read pool message " + "for {} to poolManager.", pnfsId);
                completionHandler.taskCompleted(pnfsId);
            } catch (URISyntaxException e) {
                completionHandler.taskFailed(pnfsId, CacheExceptionUtils.getCacheException(CacheException.INVALID_ARGS, "could not construct HTTP protocol: %s.", pnfsId, Type.WAIT_FOR_STAGE, e.getMessage(), null));
            }
        }, 0, TimeUnit.MILLISECONDS);
    } catch (CacheException ce) {
        completionHandler.taskFailed(pnfsId, ce);
    }
}
Also used : PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellMessage(dmg.cells.nucleus.CellMessage) CellPath(dmg.cells.nucleus.CellPath) CacheException(diskCacheV111.util.CacheException) FileOperation(org.dcache.resilience.data.FileOperation) URISyntaxException(java.net.URISyntaxException) FileAttributes(org.dcache.vehicles.FileAttributes)

Example 25 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class FileOperationHandler method handleStagingReply.

/**
 * <p>If the reply from the Pool Manager indicates that the file has
 * been staged to a pool outside the pool group, resend the message with refreshed attributes to
 * trigger a p2p by the Pool Manager to a readable resilient pool in the correct group.
 * Otherwise, discard the message.</p>
 */
public void handleStagingReply(PoolMgrSelectReadPoolMsg reply) {
    PnfsId pnfsId = reply.getPnfsId();
    try {
        if (reply.getReturnCode() == CacheException.OUT_OF_DATE) {
            FileAttributes attributes = namespace.getRequiredAttributesForStaging(pnfsId);
            /*
                 *  Check to see if one of the new locations is not resilient.
                 */
            Collection<String> locations = attributes.getLocations();
            List<String> valid = poolInfoMap.getReadableLocations(locations).stream().filter(poolInfoMap::isResilientPool).collect(Collectors.toList());
            LOGGER.trace("{}, handleStagingReply, readable resilience " + "locations are now {}.", valid);
            if (valid.size() == 0) {
                LOGGER.trace("{}, handleStagingReply, " + "PoolManager staged to" + " a non-resilient pool, " + "requesting p2p.", pnfsId);
                /*
                     *  Figure out on which pool group this should be.
                     *
                     *  It's possible that the file was "resilient" when the
                     *  stage request was sent and a subsequently configuration
                     *  change has resulted in the file no longer being
                     *  "resilient".  If this happens, the file may have no
                     *  corresponding resilient pool group.
                     *
                     *  Another possibility is the lack of resilient pool group
                     *  is due to a bug somewhere.
                     */
                Integer gIndex = null;
                for (String loc : locations) {
                    Integer pIndex = poolInfoMap.getPoolIndex(loc);
                    gIndex = poolInfoMap.getResilientPoolGroup(pIndex);
                    if (gIndex != null) {
                        break;
                    }
                }
                if (gIndex == null) {
                    LOGGER.warn("{}, handleStagingReply, file no longer" + " hosted on resilient pool group", pnfsId);
                    return;
                }
                final String poolGroup = poolInfoMap.getGroup(gIndex);
                LOGGER.trace("{}, handleStagingReply, resilient pool group " + "for p2p request: {}.", pnfsId, poolGroup);
                migrationTaskService.schedule(() -> {
                    PoolMgrSelectReadPoolMsg msg = new PoolMgrSelectReadPoolMsg(attributes, reply.getProtocolInfo(), reply.getContext(), reply.getAllowedStates());
                    msg.setSubject(reply.getSubject());
                    msg.setPoolGroup(poolGroup);
                    CellMessage cellMessage = new CellMessage(new CellPath(poolManagerAddress), msg);
                    ACTIVITY_LOGGER.info("Selecting read pool for file {}" + " staged to a non-resilient pool", pnfsId);
                    endpoint.sendMessage(cellMessage);
                    LOGGER.trace("handleStagingReply, resent select read pool " + "message for {} to poolManager.", pnfsId);
                }, 0, TimeUnit.MILLISECONDS);
                return;
            }
        }
        LOGGER.trace("{} handleStagingReply {}, nothing to do.", pnfsId, reply);
    } catch (CacheException ce) {
        LOGGER.error("handleStagingReply failed: {}.", ce.toString());
    }
}
Also used : PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellMessage(dmg.cells.nucleus.CellMessage) CellPath(dmg.cells.nucleus.CellPath) CacheException(diskCacheV111.util.CacheException) PnfsId(diskCacheV111.util.PnfsId) FileAttributes(org.dcache.vehicles.FileAttributes)

Aggregations

PnfsId (diskCacheV111.util.PnfsId)216 CacheException (diskCacheV111.util.CacheException)124 Test (org.junit.Test)70 FileAttributes (org.dcache.vehicles.FileAttributes)67 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)51 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)45 FileAttribute (org.dcache.namespace.FileAttribute)43 ArrayList (java.util.ArrayList)35 IOException (java.io.IOException)34 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)34 FsInode (org.dcache.chimera.FsInode)31 NotDirCacheException (diskCacheV111.util.NotDirCacheException)30 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)30 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)29 CellPath (dmg.cells.nucleus.CellPath)26 Inode (org.dcache.nfs.vfs.Inode)22 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)21 FileType (org.dcache.namespace.FileType)21 PnfsHandler (diskCacheV111.util.PnfsHandler)20 List (java.util.List)20