Search in sources :

Example 6 with PnfsId

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

the class MonitoringVfsTest method shouldNotNotifyOnUnsuccessfulSetattr.

@Test
public void shouldNotNotifyOnUnsuccessfulSetattr() 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();
    Stat stat = aStat().withAtime(42L).build();
    willThrow(IOException.class).given(inner).setattr(any(), any());
    try {
        monitor.setattr(target, stat);
        fail("setattr unexpectedly succeeded");
    } catch (IOException e) {
    }
    verify(inner).setattr(target, stat);
    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) Stat(org.dcache.nfs.vfs.Stat) PnfsId(diskCacheV111.util.PnfsId) IOException(java.io.IOException) Test(org.junit.Test)

Example 7 with PnfsId

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

the class MonitoringVfsTest method shouldNotNotifyOnUnsuccessfulList.

@Test
public void shouldNotNotifyOnUnsuccessfulList() throws Exception {
    PnfsId parentDirId = new PnfsId("000000000000000000000000000000000001");
    PnfsId targetDirId = new PnfsId("000000000000000000000000000000000002");
    Inode parentDir = anInode().withId(1L).withPnfsId(parentDirId).build();
    Inode targetDir = anInode().withId(2L).withPnfsId(targetDirId).withLink(parentDir, "target").build();
    byte[] verifier = {};
    given(inner.list(targetDir, verifier, 0)).willThrow(IOException.class);
    try {
        monitor.list(targetDir, verifier, 0);
        fail("list unexpectedly succeeded");
    } catch (IOException e) {
    }
    verify(inner).list(targetDir, verifier, 0);
    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 8 with PnfsId

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

the class MonitoringVfsTest method shouldNotifyOnSetattr.

@Test
public void shouldNotifyOnSetattr() 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();
    Stat stat = aStat().withAtime(42L).build();
    monitor.setattr(target, stat);
    verify(inner).setattr(target, stat);
    verify(receiver).notifyChildEvent(EventType.IN_ATTRIB, parentId, "target", FileType.REGULAR);
    verify(receiver).notifySelfEvent(EventType.IN_ATTRIB, targetId, FileType.REGULAR);
    verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
Also used : FsInode(org.dcache.chimera.FsInode) Inode(org.dcache.nfs.vfs.Inode) Stat(org.dcache.nfs.vfs.Stat) PnfsId(diskCacheV111.util.PnfsId) Test(org.junit.Test)

Example 9 with PnfsId

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

the class MonitoringVfsTest method shouldNotifyOnWrite.

@Test
public void shouldNotifyOnWrite() 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();
    given(inner.write(eq(target), any(), anyLong(), anyInt(), any())).willReturn(aWriteResult().withBytesWritten(100).withStabilityLevel(UNSTABLE).build());
    byte[] data = new byte[1024];
    WriteResult result = monitor.write(target, data, 0, 1024, UNSTABLE);
    verify(inner).write(target, data, 0, 1024, UNSTABLE);
    assertThat(result.getBytesWritten(), is(equalTo(100)));
    assertThat(result.getStabilityLevel(), is(equalTo(UNSTABLE)));
    InOrder childEvents = inOrder(receiver);
    childEvents.verify(receiver).notifyChildEvent(EventType.IN_OPEN, parentId, "target", FileType.REGULAR);
    childEvents.verify(receiver).notifyChildEvent(EventType.IN_MODIFY, parentId, "target", FileType.REGULAR);
    childEvents.verify(receiver).notifyChildEvent(EventType.IN_CLOSE_WRITE, parentId, "target", FileType.REGULAR);
    InOrder targetEvents = inOrder(receiver);
    targetEvents.verify(receiver).notifySelfEvent(EventType.IN_OPEN, targetId, FileType.REGULAR);
    targetEvents.verify(receiver).notifySelfEvent(EventType.IN_MODIFY, targetId, FileType.REGULAR);
    targetEvents.verify(receiver).notifySelfEvent(EventType.IN_CLOSE_WRITE, targetId, FileType.REGULAR);
    verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
Also used : FsInode(org.dcache.chimera.FsInode) Inode(org.dcache.nfs.vfs.Inode) WriteResult(org.dcache.nfs.vfs.VirtualFileSystem.WriteResult) InOrder(org.mockito.InOrder) PnfsId(diskCacheV111.util.PnfsId) Test(org.junit.Test)

Example 10 with PnfsId

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

the class NearlineStorageHandler method flush.

/**
 * Flushes a set of files to nearline storage.
 *
 * @param hsmType  type of nearline storage
 * @param files    files to flush
 * @param callback callback notified for every file flushed
 */
public void flush(String hsmType, Iterable<PnfsId> files, CompletionHandler<Void, PnfsId> callback) {
    try {
        NearlineStorage nearlineStorage = hsmSet.getNearlineStorageByType(hsmType);
        checkArgument(nearlineStorage != null, "No such nearline storage: " + hsmType);
        flushRequests.addAll(nearlineStorage, files, callback);
    } catch (RuntimeException e) {
        for (PnfsId pnfsId : files) {
            callback.failed(e, pnfsId);
        }
    }
}
Also used : NearlineStorage(org.dcache.pool.nearline.spi.NearlineStorage) PnfsId(diskCacheV111.util.PnfsId)

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