use of org.dcache.namespace.FileAttribute in project dcache by dCache.
the class XrootdDoor method getMultipleFileStatuses.
public int[] getMultipleFileStatuses(FsPath[] allPaths, Subject subject, Restriction restriction) throws CacheException {
PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
int[] flags = new int[allPaths.length];
// TODO: Use SpreadAndWait
for (int i = 0; i < allPaths.length; i++) {
try {
Set<FileAttribute> requestedAttributes = EnumSet.of(TYPE);
requestedAttributes.addAll(_pdp.getRequiredAttributes());
FileAttributes attributes = pnfsHandler.getFileAttributes(allPaths[i].toString(), requestedAttributes);
flags[i] = getFileStatusFlags(subject, restriction, allPaths[i], attributes);
} catch (CacheException e) {
if (e.getRc() != CacheException.FILE_NOT_FOUND) {
throw e;
}
flags[i] = kXR_other;
}
}
return flags;
}
use of org.dcache.namespace.FileAttribute in project dcache by dCache.
the class MonitoringNameSpaceProviderTest method shouldNotifyOnCommitUpload.
@Test
public void shouldNotifyOnCommitUpload() throws Exception {
PnfsId parent = new PnfsId("000000000000000000000000000000000001");
PnfsId target = new PnfsId("000000000000000000000000000000000002");
FsPath uploadPath = FsPath.create("/uploads/1/update-1/file-1");
FsPath targetPath = FsPath.create("/data/file-1");
given(inner.find(any(), eq(target))).willReturn(singleLink(parent, "file-1"));
given(inner.commitUpload(any(), eq(uploadPath), eq(targetPath), any(), any())).willReturn(FileAttributes.of().accessTime(42L).pnfsId(target).build());
FileAttributes result = monitor.commitUpload(TEST_USER, uploadPath, targetPath, EnumSet.noneOf(CreateOption.class), EnumSet.of(FileAttribute.ACCESS_TIME));
verify(inner).commitUpload(eq(TEST_USER), eq(uploadPath), eq(targetPath), eq(EnumSet.noneOf(CreateOption.class)), (Set<FileAttribute>) argThat(hasItem(FileAttribute.ACCESS_TIME)));
assertThat(result.getAccessTime(), is(equalTo(42L)));
verify(receiver).notifyMovedEvent(eq(EventType.IN_MOVED_TO), eq(parent), eq("file-1"), argThat(not(emptyOrNullString())), eq(FileType.REGULAR));
}
use of org.dcache.namespace.FileAttribute in project dcache by dCache.
the class MonitoringNameSpaceProviderTest method shouldNotifyOnCreateFile.
@Test
public void shouldNotifyOnCreateFile() throws Exception {
PnfsId parentDir = new PnfsId("000000000000000000000000000000000001");
PnfsId target = new PnfsId("000000000000000000000000000000000002");
FileAttributes newFileAttrs = FileAttributes.ofMode(0755);
given(inner.createFile(any(), eq("/foo"), any(), any())).willReturn(FileAttributes.of().pnfsId(target).accessTime(42).build());
given(inner.find(any(), eq(target))).willReturn(singleLink(parentDir, "foo"));
FileAttributes result = monitor.createFile(TEST_USER, "/foo", newFileAttrs, EnumSet.of(FileAttribute.ACCESS_TIME));
assertThat(result.getAccessTime(), is(equalTo(42L)));
verify(inner).createFile(eq(TEST_USER), eq("/foo"), eq(newFileAttrs), (Set<FileAttribute>) argThat(hasItem(FileAttribute.ACCESS_TIME)));
verify(receiver).notifyChildEvent(EventType.IN_CREATE, parentDir, "foo", FileType.REGULAR);
verify(receiver, never()).notifySelfEvent(any(), any(), any());
verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
use of org.dcache.namespace.FileAttribute 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();
}
use of org.dcache.namespace.FileAttribute in project dcache by dCache.
the class UserAdminShell method getFileAttributes.
/**
* Queries the pnfs id and file locations of a file. Used by the {@literal \sl} command.
*/
private FileAttributes getFileAttributes(String file) throws CacheException, InterruptedException, NoRouteToCellException {
/* Lookup file in name space */
PnfsGetFileAttributes request;
EnumSet<FileAttribute> attributeSet = EnumSet.of(FileAttribute.LOCATIONS, FileAttribute.PNFSID);
if (PnfsId.isValid(file)) {
request = new PnfsGetFileAttributes(new PnfsId(file), attributeSet);
} else {
request = new PnfsGetFileAttributes(file, attributeSet);
}
return _pnfsManager.sendAndWait(request).getFileAttributes();
}
Aggregations