Search in sources :

Example 1 with PnfsGetFileAttributes

use of org.dcache.vehicles.PnfsGetFileAttributes in project dcache by dCache.

the class RemoteNameSpaceProviderTests method shouldSucceedForPathToPnfsidWithKnownPathAndResolvingSymlinks.

@Test
public void shouldSucceedForPathToPnfsidWithKnownPathAndResolvingSymlinks() throws Exception {
    givenSuccessfulResponse((Modifier<PnfsGetFileAttributes>) (m) -> m.setFileAttributes(FileAttributes.ofPnfsId(A_PNFSID)));
    PnfsId id = _namespace.pathToPnfsid(ROOT, "/path/to/entry", true);
    PnfsGetFileAttributes sent = getSingleSendAndWaitMessage(PnfsGetFileAttributes.class);
    assertThat(sent.getReplyRequired(), is(true));
    assertThat(sent.getSubject(), is(ROOT));
    assertThat(sent.getPnfsPath(), is("/path/to/entry"));
    assertThat(sent.getPnfsId(), nullValue());
    assertThat(sent.isFollowSymlink(), is(true));
    assertThat(id, is(A_PNFSID));
}
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) PnfsId(diskCacheV111.util.PnfsId) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) Test(org.junit.Test)

Example 2 with PnfsGetFileAttributes

use of org.dcache.vehicles.PnfsGetFileAttributes in project dcache by dCache.

the class RemoteNameSpaceProviderTests method shouldSucceedForPathToPnfsidWithKnownPathAndNotResolvingSymlinks.

@Test
public void shouldSucceedForPathToPnfsidWithKnownPathAndNotResolvingSymlinks() throws Exception {
    givenSuccessfulResponse((Modifier<PnfsGetFileAttributes>) (m) -> m.setFileAttributes(FileAttributes.ofPnfsId(A_PNFSID)));
    PnfsId id = _namespace.pathToPnfsid(ROOT, "/path/to/entry", false);
    PnfsGetFileAttributes sent = getSingleSendAndWaitMessage(PnfsGetFileAttributes.class);
    assertThat(sent.getReplyRequired(), is(true));
    assertThat(sent.getSubject(), is(ROOT));
    assertThat(sent.getPnfsPath(), is("/path/to/entry"));
    assertThat(sent.getPnfsId(), nullValue());
    assertThat(sent.isFollowSymlink(), is(false));
    assertThat(id, is(A_PNFSID));
}
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) PnfsId(diskCacheV111.util.PnfsId) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) Test(org.junit.Test)

Example 3 with PnfsGetFileAttributes

use of org.dcache.vehicles.PnfsGetFileAttributes in project dcache by dCache.

the class PnfsManagerTest method testGetAlAndRpWhenMissing.

@Test
public void testGetAlAndRpWhenMissing() {
    PnfsCreateEntryMessage pnfsCreateEntryMessage = new PnfsCreateEntryMessage("/pnfs/testRoot/testGetAlAndRpWhenMissing", FileAttributes.ofFileType(REGULAR));
    _pnfsManager.createEntry(pnfsCreateEntryMessage);
    assertTrue("failed to create an entry", pnfsCreateEntryMessage.getReturnCode() == 0);
    PnfsGetFileAttributes request = new PnfsGetFileAttributes(pnfsCreateEntryMessage.getPnfsId(), EnumSet.of(FileAttribute.ACCESS_LATENCY, FileAttribute.RETENTION_POLICY));
    _pnfsManager.getFileAttributes(request);
    assertThat(request.getReturnCode(), is(0));
    assertThat(request.getFileAttributes().getAccessLatency(), is(AccessLatency.NEARLINE));
    assertThat(request.getFileAttributes().getRetentionPolicy(), is(RetentionPolicy.CUSTODIAL));
}
Also used : PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) Test(org.junit.Test)

Example 4 with PnfsGetFileAttributes

use of org.dcache.vehicles.PnfsGetFileAttributes in project dcache by dCache.

the class PnfsManagerTest method testNoAtimeUpdateOnGetFileAttributesNegativeGap.

@Test
public void testNoAtimeUpdateOnGetFileAttributesNegativeGap() throws ChimeraFsException {
    FsInode inode = _fs.createFile("/file1");
    Stat stat_before = inode.stat();
    _pnfsManager.setAtimeGap(-1);
    PnfsGetFileAttributes message = new PnfsGetFileAttributes(new PnfsId(inode.getId()), SOME_ATTRIBUTES);
    message.setUpdateAtime(true);
    _pnfsManager.getFileAttributes(message);
    Stat stat_after = inode.stat();
    assertTrue("atime is updated, but shouldn't", stat_after.getATime() == stat_before.getATime());
}
Also used : Stat(org.dcache.chimera.posix.Stat) FsInode(org.dcache.chimera.FsInode) PnfsId(diskCacheV111.util.PnfsId) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) Test(org.junit.Test)

Example 5 with PnfsGetFileAttributes

use of org.dcache.vehicles.PnfsGetFileAttributes in project dcache by dCache.

the class PnfsManagerTest method testGetFileAttributesNonExist.

@Test
public void testGetFileAttributesNonExist() {
    PnfsGetFileAttributes message = new PnfsGetFileAttributes(new PnfsId(FsInode.generateNewID()), EnumSet.noneOf(FileAttribute.class));
    _pnfsManager.getFileAttributes(message);
    assertTrue("get storageInfo of non existing file should return FILE_NOT_FOUND", message.getReturnCode() == CacheException.FILE_NOT_FOUND);
}
Also used : PnfsId(diskCacheV111.util.PnfsId) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttribute(org.dcache.namespace.FileAttribute) Test(org.junit.Test)

Aggregations

PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)35 PnfsId (diskCacheV111.util.PnfsId)23 Test (org.junit.Test)18 FileAttribute (org.dcache.namespace.FileAttribute)15 FileAttributes (org.dcache.vehicles.FileAttributes)12 CacheException (diskCacheV111.util.CacheException)11 PnfsCreateEntryMessage (diskCacheV111.vehicles.PnfsCreateEntryMessage)9 CellMessage (dmg.cells.nucleus.CellMessage)8 CellPath (dmg.cells.nucleus.CellPath)8 SerializationException (dmg.cells.nucleus.SerializationException)8 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)7 PnfsFlagMessage (diskCacheV111.vehicles.PnfsFlagMessage)6 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)6 URI (java.net.URI)6 PnfsSetFileAttributes (org.dcache.vehicles.PnfsSetFileAttributes)6 PnfsDeleteEntryMessage (diskCacheV111.vehicles.PnfsDeleteEntryMessage)5 PnfsGetCacheLocationsMessage (diskCacheV111.vehicles.PnfsGetCacheLocationsMessage)5 ArrayList (java.util.ArrayList)5 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)4 PoolV2Mode (diskCacheV111.pools.PoolV2Mode)4