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;
}
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);
}
}
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);
}
}
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);
}
}
Aggregations