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());
}
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());
}
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());
}
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());
}
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);
}
}
}
Aggregations