Permalink
Browse files

Merge branch 'team/storage/EUCA-5128' of git.eucalyptus-systems.com:e…

…ucalyptus into maint/3.2/testing
  • Loading branch information...
2 parents d6d042c + 2c01278 commit 0494469a64bdb8c366a5247e2055bf378f2090fc Neil Soman committed Mar 2, 2013
@@ -491,6 +491,7 @@ private void cacheImage(String bucketName, String manifestKey, Account account,
if(!icInfo.getInCache()) {
decryptedImageKey = icInfo.getImageName();
} else {
+ LOG.info("Image found in cache: " + bucketName + "/" + manifestKey);
db.commit();
return;
}
@@ -1082,6 +1083,7 @@ public GetDecryptedImageResponseType getDecryptedImage(GetDecryptedImageType req
(!storageManager.objectExists(bucketName, imageCacheInfo.getImageName()))) {
db2.delete(imageCacheInfo);
db2.commit();
+ LOG.info("Deleted cache entry: " + bucketName + "/" + objectKey);
db2 = EntityWrapper.get(ImageCacheInfo.class);
foundImageCacheInfos = db2.queryEscape(searchImageCacheInfo);
}
@@ -1090,7 +1092,7 @@ public GetDecryptedImageResponseType getDecryptedImage(GetDecryptedImageType req
(!imageCachers.containsKey(bucketName + objectKey))) {
db2.commit();
//issue a cache request
- LOG.info("Image " + bucketName + "/" + objectKey + " not found in cache. Issuing cache request (might take a while...)");
+ LOG.info("Checking if image " + bucketName + "/" + objectKey + " should be cached...");
cacheImage(bucketName, objectKey, account, ctx.hasAdministrativePrivileges());
//query db again
db2 = EntityWrapper.get(ImageCacheInfo.class);
@@ -1110,6 +1112,7 @@ public GetDecryptedImageResponseType getDecryptedImage(GetDecryptedImageType req
int number_of_tries = 0;
do {
LOG.info("Waiting " + WalrusProperties.CACHE_PROGRESS_TIMEOUT + "ms for image to cache (" + number_of_tries + " out of " + WalrusProperties.IMAGE_CACHE_RETRY_LIMIT + ")");
+ //testy
monitor.wait(WalrusProperties.CACHE_PROGRESS_TIMEOUT);
if(isCached(bucketName, objectKey)) {
cached = true;
@@ -1137,7 +1140,19 @@ public GetDecryptedImageResponseType getDecryptedImage(GetDecryptedImageType req
LOG.error("Tired of waiting to cache image: " + bucketName + "/" + objectKey + " giving up");
imageMessenger.removeMonitor(bucketName + "/" + objectKey);
semaphore.release();
- throw new WalrusException("caching failure");
+ if(!imageCachers.containsKey(bucketName + objectKey)) {
+ //caching not in progress. delete image cache row.
+ LOG.info("Deleting Image Cache Info: " + bucketName + "/" + objectKey);
+ db2 = EntityWrapper.get(ImageCacheInfo.class);
+ foundImageCacheInfos = db2.queryEscape(searchImageCacheInfo);
+ if(foundImageCacheInfos.size() > 0) {
+ db2.delete(foundImageCacheInfos.get(0));
+ }
+ db2.commit();
+ } else {
+ LOG.info("Caching in progress: " + bucketName + "/" + objectKey + " . Try run instances request again in a while...");
+ }
+ throw new NoSuchEntityException("Caching failure: " + bucketName + "/" + objectKey);
}
//caching may have modified the db. repeat the query
db2 = EntityWrapper.get(ImageCacheInfo.class);
@@ -1258,10 +1273,19 @@ public CacheImageResponseType cacheImage(CacheImageType request) throws Eucalypt
EntityWrapper<ImageCacheInfo> db2 = EntityWrapper.get(ImageCacheInfo.class);
ImageCacheInfo searchImageCacheInfo = new ImageCacheInfo(bucketName, manifestKey);
List<ImageCacheInfo> foundImageCacheInfos = db2.queryEscape(searchImageCacheInfo);
- db2.commit();
- if((foundImageCacheInfos.size() == 0) || (!imageCachers.containsKey(bucketName + manifestKey))) {
+ if(!imageCachers.containsKey(bucketName + manifestKey)) {
+ if(foundImageCacheInfos.size() > 0) {
+ ImageCacheInfo cacheInfo = foundImageCacheInfos.get(0);
+ if(!cacheInfo.getInCache()) {
+ //try again
+ db2.delete(cacheInfo);
+ }
+ }
+ db2.commit();
cacheImage(bucketName, manifestKey, account, Contexts.lookup( ).hasAdministrativePrivileges( ));
reply.setSuccess(true);
+ } else {
+ db2.rollback();
}
db.commit( );
return reply;

0 comments on commit 0494469

Please sign in to comment.