Search in sources :

Example 1 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class MonitoringVfsTest method shouldNotNotifyOnUnsuccessfulSetAcl.

@Test
public void shouldNotNotifyOnUnsuccessfulSetAcl() throws Exception {
    PnfsId parentId = new PnfsId("000000000000000000000000000000000001");
    PnfsId targetId = new PnfsId("000000000000000000000000000000000002");
    Inode parent = anInode().withId(1L).withPnfsId(parentId).build();
    Inode target = anInode().withId(2L).withPnfsId(targetId).withLink(parent, "target").withStat(aStat().withMode(0644).withType(REGULAR)).build();
    nfsace4[] acl = {};
    willThrow(IOException.class).given(inner).setAcl(any(), any());
    try {
        monitor.setAcl(target, acl);
        fail("setAcl unexpectedly succeeded");
    } catch (IOException e) {
    }
    verify(inner).setAcl(target, acl);
    verify(receiver, never()).notifyChildEvent(any(), any(), any(), any());
    verify(receiver, never()).notifySelfEvent(any(), any(), any());
    verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
Also used : org.dcache.nfs.v4.xdr.nfsace4(org.dcache.nfs.v4.xdr.nfsace4) FsInode(org.dcache.chimera.FsInode) Inode(org.dcache.nfs.vfs.Inode) PnfsId(diskCacheV111.util.PnfsId) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class MonitoringVfsTest method shouldNotNotifyOnUnsuccessfulRead.

@Test
public void shouldNotNotifyOnUnsuccessfulRead() throws Exception {
    PnfsId parentId = new PnfsId("000000000000000000000000000000000001");
    PnfsId targetId = new PnfsId("000000000000000000000000000000000002");
    Inode parent = anInode().withId(1L).withPnfsId(parentId).build();
    Inode target = anInode().withId(2L).withPnfsId(targetId).withLink(parent, "target").build();
    willThrow(IOException.class).given(inner).read(any(), any(), anyLong(), anyInt());
    byte[] data = new byte[1024];
    try {
        monitor.read(target, data, 0, 1024);
        fail("read unexpectedly succeeded");
    } catch (IOException e) {
    }
    verify(inner).read(target, data, 0, 1024);
    verify(receiver, never()).notifyChildEvent(any(), any(), any(), any());
    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) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class QoSMessageHandler method messageArrived.

/**
 * Returns whether replica exists, the status of its system sticky flag and whether its state
 * allows for reading and removal.
 */
public Reply messageArrived(ReplicaStatusMessage message) {
    MessageReply<Message> reply = new MessageReply<>();
    executor.execute(() -> {
        PnfsId pnfsId = message.getPnfsId();
        try {
            CacheEntry entry = repository.getEntry(pnfsId);
            message.setExists(true);
            switch(entry.getState()) {
                case FROM_CLIENT:
                case FROM_POOL:
                case FROM_STORE:
                    message.setWaiting(true);
                    break;
                case CACHED:
                    message.setReadable(true);
                    message.setRemovable(true);
                    break;
                case BROKEN:
                    message.setBroken(true);
                    message.setRemovable(true);
                    break;
                case PRECIOUS:
                    message.setReadable(true);
                    message.setPrecious(true);
                    break;
                default:
                    break;
            }
            Collection<StickyRecord> records = entry.getStickyRecords();
            for (StickyRecord record : records) {
                if (record.owner().equals(SYSTEM_OWNER) && record.isNonExpiring()) {
                    message.setSystemSticky(true);
                    break;
                }
            }
            reply.reply(message);
        } catch (FileNotInCacheException e) {
            reply.reply(message);
        } catch (Exception e) {
            reply.fail(message, e);
        }
    });
    return reply;
}
Also used : StickyRecord(org.dcache.pool.repository.StickyRecord) ChangePreciousBitMessage(org.dcache.vehicles.qos.ChangePreciousBitMessage) Message(diskCacheV111.vehicles.Message) ChangeStickyBitMessage(org.dcache.vehicles.qos.ChangeStickyBitMessage) ReplicaStatusMessage(org.dcache.vehicles.qos.ReplicaStatusMessage) MessageReply(org.dcache.cells.MessageReply) PnfsId(diskCacheV111.util.PnfsId) CacheEntry(org.dcache.pool.repository.CacheEntry) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException)

Example 4 with PnfsId

use of diskCacheV111.util.PnfsId in project dcache by dCache.

the class MonitoringVfsTest method shouldNotNotifyOnNoopMove.

@Test
public void shouldNotNotifyOnNoopMove() throws Exception {
    PnfsId sourceDirId = new PnfsId("000000000000000000000000000000000001");
    PnfsId destinationDirId = new PnfsId("000000000000000000000000000000000002");
    PnfsId targetId = new PnfsId("000000000000000000000000000000000003");
    Inode sourceDir = anInode().withId(1L).withPnfsId(sourceDirId).build();
    Inode destinationDir = anInode().withId(2L).withPnfsId(destinationDirId).withStat(aStat().withGeneration(1)).build();
    Inode target = anInode().withId(3L).withPnfsId(targetId).withLink(sourceDir, "target").withStat(aStat().withMode(0644).withType(REGULAR)).build();
    willReturn(false).given(inner).move(sourceDir, "target", destinationDir, "new-name");
    given(inner.lookup(sourceDir, "target")).willReturn(target);
    given(inner.lookup(destinationDir, "new-name")).willReturn(target);
    boolean result = monitor.move(sourceDir, "target", destinationDir, "new-name");
    assertThat(result, is(equalTo(false)));
    verify(receiver, never()).notifyChildEvent(any(), any(), any(), any());
    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 5 with PnfsId

use of diskCacheV111.util.PnfsId 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)

Aggregations

PnfsId (diskCacheV111.util.PnfsId)216 CacheException (diskCacheV111.util.CacheException)124 Test (org.junit.Test)70 FileAttributes (org.dcache.vehicles.FileAttributes)67 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)51 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)45 FileAttribute (org.dcache.namespace.FileAttribute)43 ArrayList (java.util.ArrayList)35 IOException (java.io.IOException)34 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)34 FsInode (org.dcache.chimera.FsInode)31 NotDirCacheException (diskCacheV111.util.NotDirCacheException)30 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)30 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)29 CellPath (dmg.cells.nucleus.CellPath)26 Inode (org.dcache.nfs.vfs.Inode)22 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)21 FileType (org.dcache.namespace.FileType)21 PnfsHandler (diskCacheV111.util.PnfsHandler)20 List (java.util.List)20