Search in sources :

Example 1 with PnfsMapPathMessage

use of diskCacheV111.vehicles.PnfsMapPathMessage in project dcache by dCache.

the class PnfsManagerV3 method mapPath.

public void mapPath(PnfsMapPathMessage pnfsMessage) {
    PnfsId pnfsId = pnfsMessage.getPnfsId();
    Subject subject = pnfsMessage.getSubject();
    if (pnfsId == null) {
        pnfsMessage.setFailed(5, "Illegal Arguments : need pnfsid");
        return;
    }
    try {
        LOGGER.info("map:  id2path for {}", pnfsId);
        String path = pathfinder(subject, pnfsId);
        checkRestriction(pnfsMessage, READ_METADATA, FsPath.create(path));
        pnfsMessage.setGlobalPath(path);
        checkMask(pnfsMessage);
    } catch (FileNotFoundCacheException fnf) {
        pnfsMessage.setFailed(CacheException.FILE_NOT_FOUND, fnf.getMessage());
    } catch (CacheException ce) {
        pnfsMessage.setFailed(ce.getRc(), ce.getMessage());
        LOGGER.warn("mapPath: {}", ce.getMessage());
    } catch (RuntimeException e) {
        LOGGER.error("Exception in mapPath (pathfinder) " + e, e);
        pnfsMessage.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
    }
}
Also used : MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsId(diskCacheV111.util.PnfsId) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) Subject(javax.security.auth.Subject)

Example 2 with PnfsMapPathMessage

use of diskCacheV111.vehicles.PnfsMapPathMessage in project dcache by dCache.

the class RemoteNameSpaceProviderTests method shouldSucceedForPnfsidToPathWithKnownPnfsId.

@Test
public void shouldSucceedForPnfsidToPathWithKnownPnfsId() throws Exception {
    givenSuccessfulResponse((Modifier<PnfsMapPathMessage>) (m) -> m.setGlobalPath("/path/to/entry"));
    String path = _namespace.pnfsidToPath(ROOT, A_PNFSID);
    PnfsMapPathMessage sent = getSingleSendAndWaitMessage(PnfsMapPathMessage.class);
    assertThat(sent.getReplyRequired(), is(true));
    assertThat(sent.getSubject(), is(ROOT));
    assertThat(sent.getGlobalPath(), nullValue());
    assertThat(sent.getPnfsId(), is(A_PNFSID));
    assertThat(path, is("/path/to/entry"));
}
Also used : FILE_NOT_FOUND(diskCacheV111.util.CacheException.FILE_NOT_FOUND) ListDirectoryHandler(org.dcache.util.list.ListDirectoryHandler) Link(diskCacheV111.namespace.NameSpaceProvider.Link) CellMessage(dmg.cells.nucleus.CellMessage) ChecksumType(org.dcache.util.ChecksumType) FILE_EXISTS(diskCacheV111.util.CacheException.FILE_EXISTS) PnfsHandler(diskCacheV111.util.PnfsHandler) BDDMockito.verify(org.mockito.BDDMockito.verify) FlagOperation(diskCacheV111.vehicles.PnfsFlagMessage.FlagOperation) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) SIZE(org.dcache.namespace.FileAttribute.SIZE) EnumSet(java.util.EnumSet) FileAttributes(org.dcache.vehicles.FileAttributes) FileAttributesBuilder.fileAttributes(org.dcache.util.FileAttributesBuilder.fileAttributes) PnfsGetParentMessage(diskCacheV111.vehicles.PnfsGetParentMessage) BDDMockito.never(org.mockito.BDDMockito.never) Collection(java.util.Collection) Range(com.google.common.collect.Range) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) PnfsGetCacheLocationsMessage(diskCacheV111.vehicles.PnfsGetCacheLocationsMessage) Preconditions.checkState(com.google.common.base.Preconditions.checkState) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage) SerializationHandler(dmg.cells.nucleus.SerializationHandler) List(java.util.List) DirectoryEntry(org.dcache.util.list.DirectoryEntry) CellMessageAnswerable(dmg.cells.nucleus.CellMessageAnswerable) Matchers.is(org.hamcrest.Matchers.is) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) CellPath(dmg.cells.nucleus.CellPath) PnfsClearCacheLocationMessage(diskCacheV111.vehicles.PnfsClearCacheLocationMessage) PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage) PnfsMessage(diskCacheV111.vehicles.PnfsMessage) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) NOT_FILE(diskCacheV111.util.CacheException.NOT_FILE) HashMap(java.util.HashMap) CellEndpoint(dmg.cells.nucleus.CellEndpoint) SerializationException(dmg.cells.nucleus.SerializationException) Answer(org.mockito.stubbing.Answer) BDDMockito.any(org.mockito.BDDMockito.any) BDDMockito.anyLong(org.mockito.BDDMockito.anyLong) Lists(com.google.common.collect.Lists) CacheException(diskCacheV111.util.CacheException) CellStub(org.dcache.cells.CellStub) ArgumentCaptor(org.mockito.ArgumentCaptor) TYPE(org.dcache.namespace.FileAttribute.TYPE) PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) ListHandler(org.dcache.namespace.ListHandler) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileType(org.dcache.namespace.FileType) Before(org.junit.Before) PnfsId(diskCacheV111.util.PnfsId) ROOT(org.dcache.auth.Subjects.ROOT) BDDMockito.doAnswer(org.mockito.BDDMockito.doAnswer) Executor(java.util.concurrent.Executor) REGULAR(org.dcache.namespace.FileType.REGULAR) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) Test(org.junit.Test) NotFileCacheException(diskCacheV111.util.NotFileCacheException) BDDMockito.willAnswer(org.mockito.BDDMockito.willAnswer) PnfsRemoveChecksumMessage(org.dcache.vehicles.PnfsRemoveChecksumMessage) Matchers.hasItem(org.hamcrest.Matchers.hasItem) PnfsAddCacheLocationMessage(diskCacheV111.vehicles.PnfsAddCacheLocationMessage) FileAttribute(org.dcache.namespace.FileAttribute) BDDMockito.mock(org.mockito.BDDMockito.mock) Collections(java.util.Collections) PnfsMapPathMessage(diskCacheV111.vehicles.PnfsMapPathMessage) PnfsMapPathMessage(diskCacheV111.vehicles.PnfsMapPathMessage) Test(org.junit.Test)

Aggregations

CacheException (diskCacheV111.util.CacheException)2 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)2 PnfsId (diskCacheV111.util.PnfsId)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Lists (com.google.common.collect.Lists)1 Range (com.google.common.collect.Range)1 Link (diskCacheV111.namespace.NameSpaceProvider.Link)1 FILE_EXISTS (diskCacheV111.util.CacheException.FILE_EXISTS)1 FILE_NOT_FOUND (diskCacheV111.util.CacheException.FILE_NOT_FOUND)1 NOT_FILE (diskCacheV111.util.CacheException.NOT_FILE)1 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)1 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)1 NotDirCacheException (diskCacheV111.util.NotDirCacheException)1 NotFileCacheException (diskCacheV111.util.NotFileCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1 PnfsHandler (diskCacheV111.util.PnfsHandler)1 PnfsAddCacheLocationMessage (diskCacheV111.vehicles.PnfsAddCacheLocationMessage)1 PnfsClearCacheLocationMessage (diskCacheV111.vehicles.PnfsClearCacheLocationMessage)1 PnfsCreateEntryMessage (diskCacheV111.vehicles.PnfsCreateEntryMessage)1