Search in sources :

Example 1 with OperationFailureException

use of com.sleepycat.je.OperationFailureException in project dcache by dCache.

the class CacheRepositoryEntryImpl method setFileAttributes.

private Void setFileAttributes(FileAttributes attributes) throws CacheException {
    try {
        String id = _pnfsId.toString();
        // invalidate cached value
        _storageInfoCache.clear();
        // TODO to check the case when STORAGEINFO size=0
        if (attributes.isDefined(FileAttribute.STORAGEINFO)) {
            _repository.getStorageInfoMap().put(id, StorageInfos.extractFrom(attributes));
        } else {
            _repository.getStorageInfoMap().remove(id);
        }
        // TODO check should there be separate methods
        if (attributes.isDefined(FileAttribute.ACCESS_TIME) && attributes.isDefined(FileAttribute.CREATION_TIME)) {
            AccessTimeInfo accessTimeInfo = new AccessTimeInfo();
            accessTimeInfo.setLastAccessTime(attributes.getAccessTime());
            accessTimeInfo.setCreationTime(attributes.getCreationTime());
            _repository.getAccessTimeInfo().put(id, accessTimeInfo);
        } else {
            _repository.getAccessTimeInfo().remove(id);
        }
    } catch (EnvironmentFailureException e) {
        if (!_repository.isValid()) {
            throw new DiskErrorCacheException("Meta data update failed and a pool restart is required: " + e.getMessage(), e);
        }
        throw new CacheException("Meta data update failed: " + e.getMessage(), e);
    } catch (OperationFailureException e) {
        throw new CacheException("Meta data update failed: " + e.getMessage(), e);
    }
    return null;
}
Also used : DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException) CacheException(diskCacheV111.util.CacheException) EnvironmentFailureException(com.sleepycat.je.EnvironmentFailureException) OperationFailureException(com.sleepycat.je.OperationFailureException) DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException)

Example 2 with OperationFailureException

use of com.sleepycat.je.OperationFailureException in project dcache by dCache.

the class BerkeleyDBMetaDataRepository method index.

@Override
public Set<PnfsId> index(IndexOption... options) throws CacheException {
    try {
        List<IndexOption> indexOptions = asList(options);
        if (indexOptions.contains(IndexOption.META_ONLY)) {
            return views.collectKeys(Collectors.mapping(PnfsId::new, Collectors.toSet()));
        }
        Stopwatch watch = Stopwatch.createStarted();
        Set<PnfsId> files = _fileStore.index();
        LOGGER.info("Indexed {} entries in {} in {}.", files.size(), _fileStore, watch);
        if (indexOptions.contains(IndexOption.ALLOW_REPAIR)) {
            watch.reset().start();
            Set<String> records = views.collectKeys(Collectors.toSet());
            LOGGER.info("Indexed {} entries in {} in {}.", records.size(), dir, watch);
            for (String id : records) {
                if (!files.contains(new PnfsId(id))) {
                    LOGGER.warn("Removing redundant meta data for {}.", id);
                    views.getStorageInfoMap().remove(id);
                    views.getStateMap().remove(id);
                    views.getAccessTimeInfo().remove(id);
                }
            }
        }
        return files;
    } catch (EnvironmentFailureException e) {
        if (!isValid()) {
            throw new DiskErrorCacheException("Meta data lookup failed and a pool restart is required: " + e.getMessage(), e);
        }
        throw new CacheException("Meta data lookup failed: " + e.getMessage(), e);
    } catch (OperationFailureException e) {
        throw new CacheException("Meta data lookup failed: " + e.getMessage(), e);
    } catch (IOException e) {
        throw new DiskErrorCacheException("Meta data lookup failed and a pool restart is required: " + messageOrClassName(e), e);
    }
}
Also used : DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException) CacheException(diskCacheV111.util.CacheException) EnvironmentFailureException(com.sleepycat.je.EnvironmentFailureException) PnfsId(diskCacheV111.util.PnfsId) Stopwatch(com.google.common.base.Stopwatch) OperationFailureException(com.sleepycat.je.OperationFailureException) IOException(java.io.IOException) DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException)

Example 3 with OperationFailureException

use of com.sleepycat.je.OperationFailureException in project dcache by dCache.

the class BerkeleyDBMetaDataRepository method remove.

@Override
public void remove(PnfsId id) throws CacheException {
    try {
        _fileStore.remove(id);
    } catch (IOException e) {
        throw new DiskErrorCacheException("Failed to delete " + id + ": " + messageOrClassName(e), e);
    }
    try {
        views.getStorageInfoMap().remove(id.toString());
        views.getStateMap().remove(id.toString());
        views.getAccessTimeInfo().remove(id.toString());
    } catch (EnvironmentFailureException e) {
        if (!isValid()) {
            throw new DiskErrorCacheException("Meta data update failed and a pool restart is required: " + e.getMessage(), e);
        }
        throw new CacheException("Meta data update failed: " + e.getMessage(), e);
    } catch (OperationFailureException e) {
        throw new CacheException("Meta data update failed: " + e.getMessage(), e);
    }
}
Also used : DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException) CacheException(diskCacheV111.util.CacheException) EnvironmentFailureException(com.sleepycat.je.EnvironmentFailureException) IOException(java.io.IOException) OperationFailureException(com.sleepycat.je.OperationFailureException) DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException)

Example 4 with OperationFailureException

use of com.sleepycat.je.OperationFailureException in project dcache by dCache.

the class CacheRepositoryEntryImpl method getFileAttributes.

@Override
public synchronized FileAttributes getFileAttributes() throws CacheException {
    try {
        FileAttributes attributes = FileAttributes.ofPnfsId(_pnfsId);
        StorageInfo storageInfo = getStorageInfo();
        if (storageInfo != null) {
            StorageInfos.injectInto(storageInfo, attributes);
        }
        return attributes;
    } catch (EnvironmentFailureException e) {
        if (!_repository.isValid()) {
            throw new DiskErrorCacheException("Meta data lookup failed and a pool restart is required: " + e.getMessage(), e);
        }
        throw new CacheException("Meta data lookup failed: " + e.getMessage(), e);
    } catch (OperationFailureException e) {
        throw new CacheException("Meta data lookup failed: " + e.getMessage(), e);
    }
}
Also used : DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException) CacheException(diskCacheV111.util.CacheException) EnvironmentFailureException(com.sleepycat.je.EnvironmentFailureException) StorageInfo(diskCacheV111.vehicles.StorageInfo) OperationFailureException(com.sleepycat.je.OperationFailureException) FileAttributes(org.dcache.vehicles.FileAttributes) DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException)

Aggregations

EnvironmentFailureException (com.sleepycat.je.EnvironmentFailureException)4 OperationFailureException (com.sleepycat.je.OperationFailureException)4 CacheException (diskCacheV111.util.CacheException)4 DiskErrorCacheException (diskCacheV111.util.DiskErrorCacheException)4 IOException (java.io.IOException)2 Stopwatch (com.google.common.base.Stopwatch)1 PnfsId (diskCacheV111.util.PnfsId)1 StorageInfo (diskCacheV111.vehicles.StorageInfo)1 FileAttributes (org.dcache.vehicles.FileAttributes)1