use of org.ovirt.engine.core.utils.transaction.TransactionMethod in project ovirt-engine by oVirt.
the class IsoDomainListSynchronizer method refreshIsoFileListMetaData.
private boolean refreshIsoFileListMetaData(final Guid repoStorageDomainId, final Map<String, Map<String, Object>> fileStats, final ImageFileType imageType) {
Lock syncObject = getSyncObject(repoStorageDomainId, imageType);
try {
syncObject.lock();
return (Boolean) TransactionSupport.executeInScope(TransactionScopeOption.RequiresNew, new TransactionMethod<Object>() {
@Override
public Object runInTransaction() {
long currentTime = System.currentTimeMillis();
repoFileMetaDataDao.removeRepoDomainFileList(repoStorageDomainId, imageType);
for (Map.Entry<String, Map<String, Object>> entry : fileStats.entrySet()) {
repoFileMetaDataDao.addRepoFileMap(newRepoImage(currentTime, entry));
}
return true;
}
public RepoImage newRepoImage(long currentTime, Map.Entry<String, Map<String, Object>> entry) {
RepoImage repo_md = new RepoImage();
repo_md.setLastRefreshed(currentTime);
repo_md.setSize(retrieveIsoFileSize(entry));
repo_md.setRepoDomainId(repoStorageDomainId);
repo_md.setDateCreated(null);
repo_md.setRepoImageId(entry.getKey());
repo_md.setRepoImageName(null);
repo_md.setFileType(imageType);
return repo_md;
}
});
} catch (Exception e) {
log.warn("Updating repository content to DB failed for repoStorageDomainId={}, imageType={}: {}", repoStorageDomainId, imageType, e.getMessage());
log.debug("Exception", e);
return false;
} finally {
syncObject.unlock();
}
}
Aggregations