Search in sources :

Example 1 with PnfsCreateEntryMessage

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());
}
Also used : PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) PnfsHandler(diskCacheV111.util.PnfsHandler)

Example 2 with PnfsCreateEntryMessage

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));
}
Also used : PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) FileAttribute(org.dcache.namespace.FileAttribute) Test(org.junit.Test)

Example 3 with PnfsCreateEntryMessage

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());
}
Also used : FsInode(org.dcache.chimera.FsInode) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) Test(org.junit.Test)

Example 4 with PnfsCreateEntryMessage

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));
}
Also used : PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) Test(org.junit.Test)

Example 5 with PnfsCreateEntryMessage

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);
}
Also used : FsInode(org.dcache.chimera.FsInode) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) PnfsRenameMessage(diskCacheV111.vehicles.PnfsRenameMessage) ChimeraNameSpaceProvider(org.dcache.chimera.namespace.ChimeraNameSpaceProvider) Test(org.junit.Test)

Aggregations

PnfsCreateEntryMessage (diskCacheV111.vehicles.PnfsCreateEntryMessage)22 Test (org.junit.Test)15 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)9 StorageInfo (diskCacheV111.vehicles.StorageInfo)5 FileAttributes (org.dcache.vehicles.FileAttributes)5 PnfsSetFileAttributes (org.dcache.vehicles.PnfsSetFileAttributes)5 PnfsHandler (diskCacheV111.util.PnfsHandler)4 URI (java.net.URI)3 FsInode (org.dcache.chimera.FsInode)3 FileAttribute (org.dcache.namespace.FileAttribute)3 PnfsDeleteEntryMessage (diskCacheV111.vehicles.PnfsDeleteEntryMessage)2 CacheException (diskCacheV111.util.CacheException)1 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 FsPath (diskCacheV111.util.FsPath)1 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)1 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)1 NotDirCacheException (diskCacheV111.util.NotDirCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1