use of diskCacheV111.vehicles.PnfsGetParentMessage in project dcache by dCache.
the class PnfsManagerV3 method getParent.
private void getParent(PnfsGetParentMessage msg) {
try {
PnfsId pnfsId = populatePnfsId(msg);
checkMask(msg);
_nameSpaceProvider.find(msg.getSubject(), pnfsId).forEach(l -> msg.addLocation(l.getParent(), l.getName()));
} catch (CacheException e) {
LOGGER.warn(e.toString());
msg.setFailed(e.getRc(), e.getMessage());
} catch (RuntimeException e) {
LOGGER.error(e.toString(), e);
msg.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage());
}
}
use of diskCacheV111.vehicles.PnfsGetParentMessage in project dcache by dCache.
the class RemoteNameSpaceProviderTests method shouldSucceedForFindExistingEntry.
@Test
public void shouldSucceedForFindExistingEntry() throws Exception {
givenSuccessfulResponse((Modifier<PnfsGetParentMessage>) (r) -> r.addLocation(ANOTHER_PNFSID, "file"));
Collection<Link> locations = _namespace.find(ROOT, A_PNFSID);
PnfsGetParentMessage sent = getSingleSendAndWaitMessage(PnfsGetParentMessage.class);
assertThat(sent.getReplyRequired(), is(true));
assertThat(sent.getSubject(), is(ROOT));
assertThat(sent.getPnfsId(), is(A_PNFSID));
assertThat(locations.size(), is(1));
Link location = locations.iterator().next();
assertThat(location.getParent(), is(ANOTHER_PNFSID));
assertThat(location.getName(), is("file"));
}
use of diskCacheV111.vehicles.PnfsGetParentMessage in project dcache by dCache.
the class PnfsHandler method find.
public Collection<Link> find(PnfsId pnfsId) throws CacheException {
PnfsGetParentMessage response = request(new PnfsGetParentMessage(pnfsId));
List<PnfsId> parents = response.getParents();
List<String> names = response.getNames();
int count = Math.min(parents.size(), names.size());
List<Link> locations = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
locations.add(new Link(parents.get(i), names.get(i)));
}
return locations;
}
use of diskCacheV111.vehicles.PnfsGetParentMessage in project dcache by dCache.
the class PnfsManagerTest method testAddCacheLocationNonExist.
/*
@Test
public void testGetParentOf() throws ChimeraFsException {
PnfsCreateDirectoryMessage pnfsCreateDirectoryMessage = new PnfsCreateDirectoryMessage("/pnfs/testRoot/testDir", 3750, 1000, 0750);
_pnfsManager.createDirectory(pnfsCreateDirectoryMessage);
FsInode rootInode = _fs.path2inode("/pnfs");
FsInode parentDirInode = _fs.path2inode("/pnfs/testRoot");
FsInode testDirInode = _fs.path2inode("/pnfs/testRoot/testDir");
PnfsId rootDirPnfs = new PnfsId(rootInode.toString());
PnfsId parentDirPnfs = new PnfsId(parentDirInode.toString());
PnfsId testDirPnfs = new PnfsId(testDirInode.toString());
PnfsGetParentMessage pnfsGetParentMessage1 = new PnfsGetParentMessage(testDirPnfs);
_pnfsManager.getParent(pnfsGetParentMessage1);
PnfsId pnfsOfParent1 = pnfsGetParentMessage1.getParent();
assertEquals("ok: pnfsOfParent1=parentDirPnfs", parentDirPnfs.toString(), pnfsOfParent1.toString());
PnfsGetParentMessage pnfsGetParentMessage2 = new PnfsGetParentMessage(parentDirPnfs);
_pnfsManager.getParent(pnfsGetParentMessage2);
PnfsId pnfsOfParent2 = pnfsGetParentMessage2.getParent();
assertEquals("ok: pnfsOfParent2=rootDirPnfs", rootDirPnfs.toString(), pnfsOfParent2.toString());
PnfsGetParentMessage pnfsGetParentMessage3 = new PnfsGetParentMessage(rootDirPnfs);
_pnfsManager.getParent(pnfsGetParentMessage3);
PnfsId pnfsOfParent3 = pnfsGetParentMessage3.getParent();
assertEquals("ok: pnfsOfParent3=000000000000000000000000000000000000","000000000000000000000000000000000000",pnfsOfParent3.toString());
}
@Test
public void testGetParentOfNotExistingResource() throws ChimeraFsException {
PnfsId tmp=new PnfsId("111113333300000000000000000000222222");
PnfsGetParentMessage pnfsGetParentMessage = new PnfsGetParentMessage(tmp);
_pnfsManager.getParent(pnfsGetParentMessage);
assertTrue("get parent of non existing resource should return FILE_NOT_FOUND", pnfsGetParentMessage.getReturnCode() == CacheException.FILE_NOT_FOUND );
}
*/
@Test
@Ignore
public void testAddCacheLocationNonExist() {
PnfsAddCacheLocationMessage pnfsAddCacheLocationMessage = new PnfsAddCacheLocationMessage(new PnfsId(FsInode.generateNewID()), "aPool");
_pnfsManager.addCacheLocation(pnfsAddCacheLocationMessage);
assertTrue("add cache location of non existing file should return FILE_NOT_FOUND", pnfsAddCacheLocationMessage.getReturnCode() == CacheException.FILE_NOT_FOUND);
}
Aggregations