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