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