use of diskCacheV111.util.CacheException.FILE_NOT_FOUND 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);
}
use of diskCacheV111.util.CacheException.FILE_NOT_FOUND in project dcache by dCache.
the class PnfsManagerTest method testGetCombinedAttributesNonExist.
@Test
public void testGetCombinedAttributesNonExist() {
PnfsGetFileAttributes message = new PnfsGetFileAttributes(new PnfsId(FsInode.generateNewID()), EnumSet.noneOf(FileAttribute.class));
_pnfsManager.getFileAttributes(message);
assertEquals("Get attributes for non existing file have to return FILE_NOT_FOUND", CacheException.FILE_NOT_FOUND, message.getReturnCode());
}
use of diskCacheV111.util.CacheException.FILE_NOT_FOUND in project dcache by dCache.
the class WriteHandleImpl method commit.
@Override
public synchronized void commit() throws IllegalStateException, InterruptedException, CacheException {
if (_state != HandleState.OPEN) {
throw new IllegalStateException("Handle is closed");
}
try {
_entry.setLastAccessTime((_atime == null) ? System.currentTimeMillis() : _atime);
_fileAttributes.setCreationTime(System.currentTimeMillis());
_fileAttributes.setAccessTime(System.currentTimeMillis());
long length = _entry.getReplicaSize();
verifyFileSize(length);
_fileAttributes.setSize(length);
boolean namespaceUpdated = false;
do {
/*
* We may run into timeout if PnfsManager or network is down.
* (NOTICE, that PnfsHandler converts NoRouteToCell into Timeout exception)
* In such situations we should re-try the request. If timeout exception
* is propagated, then file will be stored in error state, to recover it
* during the next restart.
*/
try {
registerFileAttributesInNameSpace();
namespaceUpdated = true;
} catch (TimeoutCacheException e) {
LOGGER.warn("Failed to update namespace: {}. Retrying in 15 s", e.getMessage());
TimeUnit.SECONDS.sleep(15);
}
} while (!namespaceUpdated);
_entry.update("Committing new file", r -> {
r.setFileAttributes(_fileAttributes);
/* In several situations, dCache requests a CACHED file
* without having any sticky flags on it. Such files are
* subject to immediate garbage collection if we are short on
* disk space. Thus to give other clients time to access the
* file, we mark it sticky for a short amount of time.
*/
if (_targetState == ReplicaState.CACHED && _stickyRecords.isEmpty()) {
long now = System.currentTimeMillis();
r.setSticky("self", now + HOLD_TIME, false);
}
/* Move entry to target state.
*/
for (StickyRecord record : _stickyRecords) {
r.setSticky(record.owner(), record.expire(), false);
}
return r.setState(_targetState);
});
setState(HandleState.COMMITTED);
} catch (CacheException e) {
/* If any of the PNFS operations return FILE_NOT_FOUND,
* then we change the target state and the close method
* will take care of removing the file.
*/
if (e.getRc() == CacheException.FILE_NOT_FOUND) {
_targetState = ReplicaState.REMOVED;
}
throw e;
}
}
use of diskCacheV111.util.CacheException.FILE_NOT_FOUND in project dcache by dCache.
the class PnfsManagerTest method testAddChecksumNonExist.
@Test
public void testAddChecksumNonExist() {
FileAttributes attr = FileAttributes.ofChecksum(new Checksum(ChecksumType.ADLER32, "12345678"));
PnfsSetFileAttributes pnfsSetAttributesMessage = new PnfsSetFileAttributes(new PnfsId(FsInode.generateNewID()), attr);
pnfsSetAttributesMessage.setReplyRequired(false);
_pnfsManager.processPnfsMessage(null, pnfsSetAttributesMessage);
assertEquals("Set checksum for non existing file must return FILE_NOT_FOUND", CacheException.FILE_NOT_FOUND, pnfsSetAttributesMessage.getReturnCode());
}
use of diskCacheV111.util.CacheException.FILE_NOT_FOUND 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