Search in sources :

Example 1 with Link

use of diskCacheV111.namespace.NameSpaceProvider.Link in project dcache by dCache.

the class MonitoringVfsTest method shouldNotifyOnLink.

@Test
public void shouldNotifyOnLink() throws Exception {
    PnfsId parentId = new PnfsId("000000000000000000000000000000000001");
    Inode parent = anInode().withId(1L).withPnfsId(parentId).build();
    Inode existingFile = anInode().withId(2L).build();
    Inode newLink = anInode().withId(3L).build();
    given(inner.link(eq(parent), eq(existingFile), eq("new-link"), any())).willReturn(newLink);
    Inode result = monitor.link(parent, existingFile, "new-link", TEST_USER);
    assertThat(result, is(equalTo(newLink)));
    verify(inner).link(parent, existingFile, "new-link", TEST_USER);
    verify(receiver).notifyChildEvent(EventType.IN_CREATE, parentId, "new-link", FileType.REGULAR);
    verify(receiver, never()).notifySelfEvent(any(), any(), any());
    verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
Also used : FsInode(org.dcache.chimera.FsInode) Inode(org.dcache.nfs.vfs.Inode) PnfsId(diskCacheV111.util.PnfsId) Test(org.junit.Test)

Example 2 with Link

use of diskCacheV111.namespace.NameSpaceProvider.Link in project dcache by dCache.

the class DcacheResourceFactory method deleteFile.

/**
 * Deletes a file.
 */
public void deleteFile(FileAttributes attributes, FsPath path) throws CacheException {
    PnfsHandler pnfs = roleAwarePnfsHandler();
    pnfs.deletePnfsEntry(attributes.getPnfsId(), path.toString(), EnumSet.of(REGULAR, LINK), EnumSet.noneOf(FileAttribute.class));
    sendRemoveInfoToBilling(attributes, path);
}
Also used : PnfsHandler(diskCacheV111.util.PnfsHandler) FileAttribute(org.dcache.namespace.FileAttribute)

Example 3 with Link

use of diskCacheV111.namespace.NameSpaceProvider.Link in project dcache by dCache.

the class FileOperationHandler method handleMakeOneCopy.

/**
 * <p>Wraps the creation of a migration {@link Task}.  The task is given
 * a static single pool list and a degenerate selection strategy, since the target has already
 * been selected by this handler.</p>
 */
public Task handleMakeOneCopy(FileAttributes attributes) {
    PnfsId pnfsId = attributes.getPnfsId();
    FileOperation operation = fileOpMap.getOperation(pnfsId);
    LOGGER.trace("Configuring migration task for {}.", pnfsId);
    StaticSinglePoolList list;
    try {
        list = new StaticSinglePoolList(poolInfoMap.getPoolManagerInfo(operation.getTarget()));
    } catch (NoSuchElementException e) {
        CacheException exception = CacheExceptionUtils.getCacheException(CacheException.NO_POOL_CONFIGURED, "Copy %s, could not get PoolManager info for %s: %s.", pnfsId, Type.COPY, poolInfoMap.getPool(operation.getTarget()), e);
        completionHandler.taskFailed(pnfsId, exception);
        return null;
    }
    String source = poolInfoMap.getPool(operation.getSource());
    TaskParameters taskParameters = new TaskParameters(pools, // PnfsManager cell stub not used
    null, pinManager, migrationTaskService, taskSelectionStrategy, list, // eager; update should not happen
    false, // isMetaOnly; just move the metadata
    false, // compute checksum on update; should not happen
    false, // force copy even if pool not readable
    false, // maintain atime
    true, 1);
    Task task = new Task(taskParameters, completionHandler, source, pnfsId, ReplicaState.CACHED, ONLINE_STICKY_RECORD, Collections.EMPTY_LIST, attributes, attributes.getAccessTime());
    if (ACTIVITY_LOGGER.isInfoEnabled()) {
        List<String> allPools = list.getPools().stream().map(PoolManagerPoolInformation::getName).collect(Collectors.toList());
        ACTIVITY_LOGGER.info("Initiating replication of {} from {} to" + " pools: {}, offline: {}", pnfsId, source, allPools, list.getOfflinePools());
    }
    LOGGER.trace("Created migration task for {}: source {}, list {}.", pnfsId, source, list);
    return task;
}
Also used : ResilientFileTask(org.dcache.resilience.util.ResilientFileTask) Task(org.dcache.pool.migration.Task) CacheException(diskCacheV111.util.CacheException) StaticSinglePoolList(org.dcache.resilience.util.StaticSinglePoolList) TaskParameters(org.dcache.pool.migration.TaskParameters) PnfsId(diskCacheV111.util.PnfsId) FileOperation(org.dcache.resilience.data.FileOperation) NoSuchElementException(java.util.NoSuchElementException)

Example 4 with Link

use of diskCacheV111.namespace.NameSpaceProvider.Link in project dcache by dCache.

the class FileOperationHandler method handleRemoveOneCopy.

/**
 * <p>Calls {@link #removeTarget(PnfsId, String)} and then reports
 * success or failure to the completion handler.</p>
 */
public void handleRemoveOneCopy(FileAttributes attributes) {
    PnfsId pnfsId = attributes.getPnfsId();
    FileOperation operation = fileOpMap.getOperation(pnfsId);
    try {
        String target = poolInfoMap.getPool(operation.getTarget());
        LOGGER.trace("handleRemoveOneCopy {}, removing {}.", pnfsId, target);
        removeTarget(pnfsId, target);
    } catch (CacheException e) {
        completionHandler.taskFailed(pnfsId, e);
    }
    completionHandler.taskCompleted(pnfsId);
}
Also used : CacheException(diskCacheV111.util.CacheException) PnfsId(diskCacheV111.util.PnfsId) FileOperation(org.dcache.resilience.data.FileOperation)

Example 5 with Link

use of diskCacheV111.namespace.NameSpaceProvider.Link in project dcache by dCache.

the class DCacheAwareJdbcFs method getFileLocality.

/**
 * Callout to get pool monitor and check for live (network) status of a file instead of simply
 * its status as recorded in the Chimera database.
 */
private String getFileLocality(PnfsId pnfsId) throws ChimeraFsException {
    FileLocality locality = FileLocality.UNAVAILABLE;
    try {
        Set<FileAttribute> requestedAttributes = EnumSet.of(FileAttribute.TYPE, FileAttribute.SIZE, FileAttribute.STORAGEINFO, FileAttribute.LOCATIONS);
        Set<AccessMask> accessMask = EnumSet.of(AccessMask.READ_DATA);
        FileAttributes attributes = pnfsHandler.getFileAttributes(pnfsId, requestedAttributes, accessMask, false);
        /*
             * TODO improve code to pass in the actual InetAddress of the
             * client so that link net masks do not interfere; note that SRM uses
             * "localhost", so it is not a deviation from existing behavior.
             */
        locality = poolMonitor.getFileLocality(attributes, "localhost");
    } catch (CacheException t) {
        throw new ChimeraFsException("getFileLocality", t);
    }
    return locality.toString();
}
Also used : CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) AccessMask(org.dcache.acl.enums.AccessMask) FileLocality(diskCacheV111.util.FileLocality) FileAttributes(org.dcache.vehicles.FileAttributes) FileAttribute(org.dcache.namespace.FileAttribute)

Aggregations

FileAttributes (org.dcache.vehicles.FileAttributes)22 Test (org.junit.Test)17 CacheException (diskCacheV111.util.CacheException)16 PoolPreferenceLevel (diskCacheV111.poolManager.PoolPreferenceLevel)15 PnfsId (diskCacheV111.util.PnfsId)13 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)9 Args (org.dcache.util.Args)9 FileAttribute (org.dcache.namespace.FileAttribute)7 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)6 StorageInfo (diskCacheV111.vehicles.StorageInfo)6 FsPath (diskCacheV111.util.FsPath)5 ArrayList (java.util.ArrayList)5 PoolV2Mode (diskCacheV111.pools.PoolV2Mode)4 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)4 CommandInterpreter (dmg.util.CommandInterpreter)4 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)3 NotDirCacheException (diskCacheV111.util.NotDirCacheException)3 NotFileCacheException (diskCacheV111.util.NotFileCacheException)3 CellEndpoint (dmg.cells.nucleus.CellEndpoint)3 File (java.io.File)3