use of diskCacheV111.vehicles.PnfsCreateEntryMessage in project dcache by dCache.
the class DcacheResourceFactory method makeDirectory.
/**
* Create a new directory.
*/
public DcacheDirectoryResource makeDirectory(FileAttributes parent, FsPath path) throws CacheException {
PnfsHandler pnfs = new PnfsHandler(_pnfs, getSubject(), getRestriction());
PnfsCreateEntryMessage reply = pnfs.createPnfsDirectory(path.toString(), REQUIRED_ATTRIBUTES);
return new DcacheDirectoryResource(this, path, reply.getFileAttributes());
}
use of diskCacheV111.vehicles.PnfsCreateEntryMessage in project dcache by dCache.
the class RemoteNameSpaceProviderTests method shouldSucceedWhenCreatingFile.
@Test
public void shouldSucceedWhenCreatingFile() throws Exception {
givenSuccessfulResponse();
_namespace.createFile(ROOT, "/path/to/file", FileAttributes.of().uid(100).gid(200).mode(0644).build(), EnumSet.noneOf(FileAttribute.class));
PnfsCreateEntryMessage sent = getSingleSendAndWaitMessage(PnfsCreateEntryMessage.class);
assertThat(sent.getReplyRequired(), is(true));
assertThat(sent.getSubject(), is(ROOT));
assertThat(sent.getPnfsPath(), is("/path/to/file"));
assertThat(sent.getFileAttributes().getOwner(), is(100));
assertThat(sent.getFileAttributes().getGroup(), is(200));
assertThat(sent.getFileAttributes().getMode(), is(0644));
}
use of diskCacheV111.vehicles.PnfsCreateEntryMessage in project dcache by dCache.
the class PnfsManagerTest method testDefaultALandRP.
@Test
public void testDefaultALandRP() throws ChimeraFsException {
/*
* this test relays on the fact that default values in PnfsManager
* is CUSTODIAL/NEARLINE
*/
// use back door to create the tag
FsInode dirInode = _fs.path2inode("/pnfs/testRoot");
_fs.createTag(dirInode, "AccessLatency");
_fs.createTag(dirInode, "RetentionPolicy");
String al = "ONLINE";
String rp = "OUTPUT";
_fs.setTag(dirInode, "AccessLatency", al.getBytes(), 0, al.getBytes().length);
_fs.setTag(dirInode, "RetentionPolicy", rp.getBytes(), 0, rp.getBytes().length);
PnfsCreateEntryMessage pnfsCreateEntryMessage = new PnfsCreateEntryMessage("/pnfs/testRoot/testDefaultALandRP", FileAttributes.ofFileType(REGULAR));
_pnfsManager.createEntry(pnfsCreateEntryMessage);
FileAttributes fileAttributes = pnfsCreateEntryMessage.getFileAttributes();
assertEquals("AccessLatensy is not taken from the parent directory", AccessLatency.ONLINE, fileAttributes.getAccessLatency());
assertEquals("RetentionPolicy is not taken from the parent directory", RetentionPolicy.OUTPUT, fileAttributes.getRetentionPolicy());
}
use of diskCacheV111.vehicles.PnfsCreateEntryMessage in project dcache by dCache.
the class PnfsManagerTest method testGetAlAndRpWhenMissing.
@Test
public void testGetAlAndRpWhenMissing() {
PnfsCreateEntryMessage pnfsCreateEntryMessage = new PnfsCreateEntryMessage("/pnfs/testRoot/testGetAlAndRpWhenMissing", FileAttributes.ofFileType(REGULAR));
_pnfsManager.createEntry(pnfsCreateEntryMessage);
assertTrue("failed to create an entry", pnfsCreateEntryMessage.getReturnCode() == 0);
PnfsGetFileAttributes request = new PnfsGetFileAttributes(pnfsCreateEntryMessage.getPnfsId(), EnumSet.of(FileAttribute.ACCESS_LATENCY, FileAttribute.RETENTION_POLICY));
_pnfsManager.getFileAttributes(request);
assertThat(request.getReturnCode(), is(0));
assertThat(request.getFileAttributes().getAccessLatency(), is(AccessLatency.NEARLINE));
assertThat(request.getFileAttributes().getRetentionPolicy(), is(RetentionPolicy.CUSTODIAL));
}
use of diskCacheV111.vehicles.PnfsCreateEntryMessage in project dcache by dCache.
the class PnfsManagerTest method testMoveEntry.
@Test
public void testMoveEntry() throws Exception {
PnfsCreateEntryMessage message = new PnfsCreateEntryMessage("/pnfs/testRoot/testMoveEntry", FileAttributes.ofFileType(DIR));
_pnfsManager.createEntry(message);
assertTrue("failed to create a directory", message.getReturnCode() == 0);
FsInode srcInode = _fs.mkdir("/pnfs/testRoot/testMoveEntry/sourceDirectory");
byte[] srcTagData = "foo".getBytes();
_fs.setTag(srcInode, "sGroup", srcTagData, 0, srcTagData.length);
FsInode dstInode = _fs.mkdir("/pnfs/testRoot/testMoveEntry/destinationDirectory");
byte[] dstTagData = "bar".getBytes();
_fs.setTag(dstInode, "sGroup", dstTagData, 0, dstTagData.length);
message = new PnfsCreateEntryMessage("/pnfs/testRoot/testMoveEntry/sourceDirectory/sourceFile", FileAttributes.ofFileType(REGULAR));
_pnfsManager.createEntry(message);
assertTrue("failed to create an entry", message.getReturnCode() == 0);
PnfsRenameMessage pnfsRenameMessage = new PnfsRenameMessage("/pnfs/testRoot/testMoveEntry/sourceDirectory/sourceFile", "/pnfs/testRoot/testMoveEntry/destinationDirectory/destinationFile", false);
_pnfsManager.rename(pnfsRenameMessage);
assertTrue("failed to move file to directory", pnfsRenameMessage.getReturnCode() == 0);
ChimeraNameSpaceProvider provider = (ChimeraNameSpaceProvider) _pnfsManager.getNameSpaceProvider();
provider.setAllowMoveToDirectoryWithDifferentStorageClass(false);
pnfsRenameMessage = new PnfsRenameMessage("/pnfs/testRoot/testMoveEntry/destinationDirectory/destinationFile", "/pnfs/testRoot/testMoveEntry/sourceDirectory/sourceFile", false);
_pnfsManager.rename(pnfsRenameMessage);
assertTrue("succeeded to move file to directory with different tag, a failure", pnfsRenameMessage.getReturnCode() != 0);
pnfsRenameMessage = new PnfsRenameMessage("/pnfs/testRoot/testMoveEntry/destinationDirectory", "/pnfs/testRoot/testMoveEntry/sourceDirectory/destinationDirectory", false);
_pnfsManager.rename(pnfsRenameMessage);
assertTrue("succeeded to move directory to directory with different tag, a failure", pnfsRenameMessage.getReturnCode() != 0);
}
Aggregations