cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/object_store to fe3b01e
Date Wed, 17 Apr 2013 18:41:18 GMT
Updated Branches:
  refs/heads/object_store c74969fcb -> fe3b01ece


Update DataObjectInStore interface and unify implementation of
ImageDataFactory, VolumeDataFactory and SnapshotDataFactory
implementations.

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fe3b01ec
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fe3b01ec
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fe3b01ec

Branch: refs/heads/object_store
Commit: fe3b01ece1efd193ecc74dc31b1f6a469a7b451c
Parents: c74969f
Author: Min Chen <min.chen@citrix.com>
Authored: Wed Apr 17 11:40:57 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Wed Apr 17 11:40:57 2013 -0700

----------------------------------------------------------------------
 core/src/com/cloud/storage/VMTemplateHostVO.java   |   73 +++++----
 .../com/cloud/storage/VMTemplateStoragePoolVO.java |   58 ++++---
 core/src/com/cloud/storage/VolumeHostVO.java       |  119 ++++++++-------
 .../subsystem/api/storage/DataObjectInStore.java   |    2 +
 .../storage/datastore/db/SnapshotDataStoreDao.java |    8 +
 .../storage/datastore/db/SnapshotDataStoreVO.java  |    7 +
 .../storage/datastore/db/TemplateDataStoreVO.java  |    8 +
 .../storage/datastore/db/VolumeDataStoreDao.java   |    6 +-
 .../storage/datastore/db/VolumeDataStoreVO.java    |    7 +
 .../storage/image/ImageDataFactoryImpl.java        |   14 +-
 .../storage/snapshot/SnapshotDataFactoryImpl.java  |   18 +-
 .../datastore/ObjectInDataStoreManagerImpl.java    |   31 ++---
 .../cloudstack/storage/db/ObjectInDataStoreVO.java |   48 +++---
 .../storage/image/db/SnapshotDataStoreDaoImpl.java |   50 ++++++
 .../storage/image/db/VolumeDataStoreDaoImpl.java   |   21 +++-
 .../storage/volume/VolumeDataFactoryImpl.java      |   18 ++-
 .../storage/volume/VolumeServiceImpl.java          |    2 +-
 17 files changed, 313 insertions(+), 177 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/core/src/com/cloud/storage/VMTemplateHostVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/VMTemplateHostVO.java b/core/src/com/cloud/storage/VMTemplateHostVO.java
index b8dfc41..8b25759 100755
--- a/core/src/com/cloud/storage/VMTemplateHostVO.java
+++ b/core/src/com/cloud/storage/VMTemplateHostVO.java
@@ -44,66 +44,66 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc,
DataObj
 	@Id
 	@GeneratedValue(strategy=GenerationType.IDENTITY)
 	Long id;
-	
+
 	@Column(name="host_id")
 	private long hostId;
-	
+
 	@Column(name="template_id")
 	private long templateId;
-	
+
 	@Column(name=GenericDaoBase.CREATED_COLUMN)
 	private Date created = null;
-	
+
 	@Column(name="last_updated")
 	@Temporal(value=TemporalType.TIMESTAMP)
 	private Date lastUpdated = null;
-	
+
 	@Column (name="download_pct")
 	private int downloadPercent;
-	
+
 	@Column (name="size")
 	private long size;
-	
+
 	@Column (name="physical_size")
 	private long physicalSize;
-	
+
 	@Column (name="download_state")
 	@Enumerated(EnumType.STRING)
 	private Status downloadState;
-	
+
 	@Column (name="local_path")
 	private String localDownloadPath;
-	
+
 	@Column (name="error_str")
 	private String errorString;
-	
+
 	@Column (name="job_id")
-	private String jobId;	
-	
+	private String jobId;
+
 	@Column (name="install_path")
     private String installPath;
-	
+
 	@Column (name="url")
 	private String downloadUrl;
 
 	@Column(name="is_copy")
 	private boolean isCopy = false;
-    
+
     @Column(name="destroyed")
     boolean destroyed = false;
-    
+
     @Column(name="update_count", updatable = true, nullable=false)
     protected long updatedCount;
-    
+
     @Column(name = "updated")
     @Temporal(value = TemporalType.TIMESTAMP)
     Date updated;
-    
+
     @Column(name = "state")
     @Enumerated(EnumType.STRING)
     ObjectInDataStoreStateMachine.State state;
-    
-    
+
+
 	@Override
     public String getInstallPath() {
 		return installPath;
@@ -156,12 +156,12 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc,
DataObj
     public Date getLastUpdated() {
 		return lastUpdated;
 	}
-	
+
 	@Override
     public void setLastUpdated(Date date) {
 	    lastUpdated = date;
 	}
-	
+
 	@Override
     public void setInstallPath(String installPath) {
 	    this.installPath = installPath;
@@ -197,7 +197,7 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc,
DataObj
 	}
 
 	protected VMTemplateHostVO() {
-		
+
 	}
 
 	@Override
@@ -234,7 +234,7 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc,
DataObj
 	public boolean equals(Object obj) {
 		if (obj instanceof VMTemplateHostVO) {
 			VMTemplateHostVO other = (VMTemplateHostVO)obj;
-			return (this.templateId==other.getTemplateId() && this.hostId==other.getHostId());
	   
+			return (this.templateId==other.getTemplateId() && this.hostId==other.getHostId());
 		}
 		return false;
 	}
@@ -253,8 +253,8 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc,
DataObj
     public long getSize() {
         return size;
     }
-	
-    
+
+
     public void setPhysicalSize(long physicalSize) {
         this.physicalSize = physicalSize;
     }
@@ -286,12 +286,12 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc,
DataObj
 	public boolean isCopy() {
 		return isCopy;
 	}
-	
+
 	@Override
     public long getTemplateSize() {
 	    return -1;
 	}
-	
+
 	@Override
     public String toString() {
 	    return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(hostId).append(installPath).append("]").toString();
@@ -302,11 +302,11 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc,
DataObj
         // TODO Auto-generated method stub
         return this.state;
     }
-    
+
     public long getUpdatedCount() {
         return this.updatedCount;
     }
-    
+
     public void incrUpdatedCount() {
         this.updatedCount++;
     }
@@ -314,9 +314,20 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc,
DataObj
     public void decrUpdatedCount() {
         this.updatedCount--;
     }
-    
+
     public Date getUpdated() {
         return updated;
     }
 
+    @Override
+    public long getObjectId() {
+        return this.getTemplateId();
+    }
+
+    @Override
+    public long getDataStoreId() {
+        return this.getHostId();
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/core/src/com/cloud/storage/VMTemplateStoragePoolVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/VMTemplateStoragePoolVO.java b/core/src/com/cloud/storage/VMTemplateStoragePoolVO.java
index 9b76176..638ddd0 100644
--- a/core/src/com/cloud/storage/VMTemplateStoragePoolVO.java
+++ b/core/src/com/cloud/storage/VMTemplateStoragePoolVO.java
@@ -45,32 +45,32 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
 	@Id
 	@GeneratedValue(strategy=GenerationType.IDENTITY)
 	long id;
-	
+
 	@Column(name="pool_id")
 	private long poolId;
-	
+
 	@Column(name="template_id") long templateId;
-	
+
 	@Column(name=GenericDaoBase.CREATED_COLUMN) Date created = null;
-	
+
 	@Column(name="last_updated")
 	@Temporal(value=TemporalType.TIMESTAMP) Date lastUpdated = null;
-	
+
 	@Column (name="download_pct") int downloadPercent;
-	
+
 	@Column (name="download_state")
 	@Enumerated(EnumType.STRING) Status downloadState;
-	
+
 	@Column (name="local_path") String localDownloadPath;
-	
+
 	@Column (name="error_str") String errorString;
-	
+
 	@Column (name="job_id") String jobId;
-	
+
 	@Column (name="install_path") String installPath;
-	
+
 	@Column (name="template_size") long templateSize;
-	
+
 	@Column (name="marked_for_gc") boolean markedForGC;
 
 	@Column(name="update_count", updatable = true, nullable=false)
@@ -88,7 +88,7 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
     public String getInstallPath() {
 		return installPath;
 	}
-	
+
 	@Override
     public long getTemplateSize() {
 		return templateSize;
@@ -141,12 +141,12 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
     public Date getLastUpdated() {
 		return lastUpdated;
 	}
-	
+
 	@Override
     public void setLastUpdated(Date date) {
 	    lastUpdated = date;
 	}
-	
+
 	@Override
     public void setInstallPath(String installPath) {
 	    this.installPath = installPath;
@@ -184,7 +184,7 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
 	}
 
 	protected VMTemplateStoragePoolVO() {
-		
+
 	}
 
 	@Override
@@ -216,15 +216,15 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
     public String getJobId() {
 		return jobId;
 	}
-	
+
 	public void setTemplateSize(long templateSize) {
 		this.templateSize = templateSize;
 	}
-	
+
 	public boolean getMarkedForGC() {
 		return markedForGC;
 	}
-	
+
 	public void setMarkedForGC(boolean markedForGC) {
 		this.markedForGC = markedForGC;
 	}
@@ -244,7 +244,7 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
 		Long hid = new Long(poolId);
 		return tid.hashCode()+hid.hashCode();
 	}
-	
+
 	@Override
     public String toString() {
 	    return new StringBuilder("TmplPool[").append(id).append("-").append(templateId).append("-").append("poolId").append("-").append(installPath).append("]").toString();
@@ -254,11 +254,11 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
     public State getState() {
         return this.state;
     }
-    
+
     public long getUpdatedCount() {
         return this.updatedCount;
     }
-    
+
     public void incrUpdatedCount() {
         this.updatedCount++;
     }
@@ -266,10 +266,20 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
     public void decrUpdatedCount() {
         this.updatedCount--;
     }
-    
+
     public Date getUpdated() {
         return updated;
     }
-    
+
+    @Override
+    public long getObjectId() {
+        return this.getTemplateId();
+    }
+
+    @Override
+    public long getDataStoreId() {
+        return this.getPoolId();
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/core/src/com/cloud/storage/VolumeHostVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/VolumeHostVO.java b/core/src/com/cloud/storage/VolumeHostVO.java
index 40bae49..63b1091 100755
--- a/core/src/com/cloud/storage/VolumeHostVO.java
+++ b/core/src/com/cloud/storage/VolumeHostVO.java
@@ -47,71 +47,71 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
 	@Id
 	@GeneratedValue(strategy=GenerationType.IDENTITY)
 	Long id;
-	
+
 	@Column(name="host_id")
 	private long hostId;
-	
+
 	@Column(name="volume_id")
 	private long volumeId;
-	
+
 	@Column(name="zone_id")
 	private long zoneId;
-	
+
 	@Column(name=GenericDaoBase.CREATED_COLUMN)
 	private Date created = null;
-	
+
 	@Column(name="last_updated")
 	@Temporal(value=TemporalType.TIMESTAMP)
 	private Date lastUpdated = null;
-	
+
 	@Column (name="download_pct")
 	private int downloadPercent;
-	
+
 	@Column (name="size")
 	private long size;
-	
+
 	@Column (name="physical_size")
 	private long physicalSize;
-	
+
 	@Column (name="download_state")
 	@Enumerated(EnumType.STRING)
 	private Status downloadState;
-	
+
     @Column(name="checksum")
     private String checksum;
-	
+
 	@Column (name="local_path")
 	private String localDownloadPath;
-	
+
 	@Column (name="error_str")
 	private String errorString;
-	
+
 	@Column (name="job_id")
-	private String jobId;	
-	
+	private String jobId;
+
 	@Column (name="install_path")
     private String installPath;
-	
+
 	@Column (name="url")
 	private String downloadUrl;
-	
+
 	@Column(name="format")
     private Storage.ImageFormat format;
-    
+
     @Column(name="destroyed")
     boolean destroyed = false;
-    
+
     @Column(name="update_count", updatable = true, nullable=false)
     protected long updatedCount;
-    
+
     @Column(name = "updated")
     @Temporal(value = TemporalType.TIMESTAMP)
     Date updated;
-    
+
     @Column(name = "state")
     @Enumerated(EnumType.STRING)
     ObjectInDataStoreStateMachine.State state;
-	
+
     public String getInstallPath() {
 		return installPath;
 	}
@@ -124,17 +124,17 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
 		this.hostId = hostId;
 	}
 
-	
+
     public long getVolumeId() {
 		return volumeId;
 	}
 
-	
+
     public void setVolumeId(long volumeId) {
 		this.volumeId = volumeId;
 	}
 
-	
+
     public long getZoneId() {
 		return zoneId;
 	}
@@ -147,42 +147,42 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
 		return downloadPercent;
 	}
 
-	
+
     public void setDownloadPercent(int downloadPercent) {
 		this.downloadPercent = downloadPercent;
 	}
 
-	
+
     public void setDownloadState(Status downloadState) {
 		this.downloadState = downloadState;
 	}
 
-	
+
     public long getId() {
 		return id;
 	}
 
-	
+
     public Date getCreated() {
 		return created;
 	}
 
-	
+
     public Date getLastUpdated() {
 		return lastUpdated;
 	}
-	
-	
+
+
     public void setLastUpdated(Date date) {
 	    lastUpdated = date;
 	}
-	
-	
+
+
     public void setInstallPath(String installPath) {
 	    this.installPath = installPath;
 	}
 
-	
+
     public Status getDownloadState() {
 		return downloadState;
 	}
@@ -223,49 +223,49 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
 	}
 
 	protected VolumeHostVO() {
-		
+
 	}
 
-	
+
     public void setLocalDownloadPath(String localPath) {
 		this.localDownloadPath = localPath;
 	}
 
-	
+
     public String getLocalDownloadPath() {
 		return localDownloadPath;
 	}
 
-	
+
     public void setErrorString(String errorString) {
 		this.errorString = errorString;
 	}
 
-	
+
     public String getErrorString() {
 		return errorString;
 	}
 
-	
+
     public void setJobId(String jobId) {
 		this.jobId = jobId;
 	}
 
-	
+
     public String getJobId() {
 		return jobId;
 	}
 
-	
+
 	public boolean equals(Object obj) {
 		if (obj instanceof VolumeHostVO) {
 			VolumeHostVO other = (VolumeHostVO)obj;
-			return (this.volumeId==other.getVolumeId() && this.hostId==other.getHostId());
	   
+			return (this.volumeId==other.getVolumeId() && this.hostId==other.getHostId());
 		}
 		return false;
 	}
 
-	
+
 	public int hashCode() {
 		Long tid = new Long(volumeId);
 		Long hid = new Long(hostId);
@@ -279,8 +279,8 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
     public long getSize() {
         return size;
     }
-	
-    
+
+
     public void setPhysicalSize(long physicalSize) {
         this.physicalSize = physicalSize;
     }
@@ -303,8 +303,8 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
 
 	public String getDownloadUrl() {
 		return downloadUrl;
-	}	
-	
+	}
+
     public Storage.ImageFormat getFormat() {
 		return format;
 	}
@@ -316,16 +316,16 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
 	public long getVolumeSize() {
 	    return -1;
 	}
-	
-	
+
+
     public String toString() {
 	    return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(hostId).append(installPath).append("]").toString();
 	}
-    
+
     public long getUpdatedCount() {
         return this.updatedCount;
     }
-    
+
     public void incrUpdatedCount() {
         this.updatedCount++;
     }
@@ -333,7 +333,7 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
     public void decrUpdatedCount() {
         this.updatedCount--;
     }
-    
+
     public Date getUpdated() {
         return updated;
     }
@@ -344,4 +344,15 @@ public class VolumeHostVO implements InternalIdentity, DataObjectInStore
{
         return this.state;
     }
 
+    @Override
+    public long getObjectId() {
+        return this.getVolumeId();
+    }
+
+    @Override
+    public long getDataStoreId() {
+        return this.getHostId();
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectInStore.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectInStore.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectInStore.java
index 32ea996..ded2640 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectInStore.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectInStore.java
@@ -24,4 +24,6 @@ import com.cloud.utils.fsm.StateObject;
 public interface DataObjectInStore extends StateObject<ObjectInDataStoreStateMachine.State>
{
     public String getInstallPath();
     public void setInstallPath(String path);
+    public long getObjectId();
+    public long getDataStoreId();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
b/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
index 271ff41..b4e5022 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
@@ -31,4 +31,12 @@ public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO,
Lo
     public List<SnapshotDataStoreVO> listByStoreId(long id);
 
     public void deletePrimaryRecordsForStore(long id);
+
+    public SnapshotDataStoreVO findByStoreSnapshot(long storeId, long snapshotId);
+
+    public SnapshotDataStoreVO findByStoreSnapshot(long storeId, long snapshotId, boolean
lock);
+
+    public SnapshotDataStoreVO findBySnapshot(long snapshotId);
+
+    public List<SnapshotDataStoreVO> listDestroyed(long storeId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
b/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
index c257fb5..e4c4942 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
@@ -95,6 +95,7 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
 		return installPath;
 	}
 
+    @Override
 	public long getDataStoreId() {
 		return dataStoreId;
 	}
@@ -239,4 +240,10 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
         return this.state;
     }
 
+    @Override
+    public long getObjectId() {
+        return this.getSnapshotId();
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
b/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
index d7c8443..f1ca62b 100755
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
@@ -113,6 +113,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
 	}
 
 
+	@Override
 	public long getDataStoreId() {
 		return dataStoreId;
 	}
@@ -313,4 +314,11 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
         return updated;
     }
 
+
+    @Override
+    public long getObjectId() {
+        return this.getTemplateId();
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
b/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
index fb5bcc5..16877b8 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
@@ -32,7 +32,11 @@ public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO,
Long>,
 
     public void deletePrimaryRecordsForStore(long id);
 
-    public VolumeDataStoreVO findByVolumeId(long volumeId);
+    public VolumeDataStoreVO findByVolume(long volumeId);
 
     public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId);
+
+    public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock);
+
+    public List<VolumeDataStoreVO> listDestroyed(long storeId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
b/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
index a7134ea..d589b5c 100755
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
@@ -117,6 +117,7 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
 		return installPath;
 	}
 
+    @Override
 	public long getDataStoreId() {
 		return dataStoreId;
 	}
@@ -345,4 +346,10 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
         return this.state;
     }
 
+    @Override
+    public long getObjectId() {
+        return this.getVolumeId();
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java
index d2c2520..2c091cc 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java
@@ -21,13 +21,10 @@ package org.apache.cloudstack.storage.image;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
-import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.image.store.TemplateObject;
@@ -47,8 +44,6 @@ public class ImageDataFactoryImpl implements ImageDataFactory {
     @Inject
     VMTemplateDao imageDataDao;
     @Inject
-    ObjectInDataStoreManager objMap;
-    @Inject
     DataStoreManager storeMgr;
     @Inject
     VMTemplatePoolDao templatePoolDao;
@@ -61,6 +56,7 @@ public class ImageDataFactoryImpl implements ImageDataFactory {
             TemplateObject tmpl =  TemplateObject.getTemplate(templ, null);
             return tmpl;
         }
+        // verify if the given input parameters are consistent with our db data.
         boolean found = false;
         if (store.getRole() == DataStoreRole.Primary) {
             VMTemplateStoragePoolVO templatePoolVO = templatePoolDao.findByPoolTemplate(store.getId(),
templateId);
@@ -68,8 +64,8 @@ public class ImageDataFactoryImpl implements ImageDataFactory {
                 found = true;
             }
         } else {
-            DataObjectInStore obj = objMap.findObject(templ.getId(), DataObjectType.TEMPLATE,
store.getId(), store.getRole());
-            if (obj != null) {
+            TemplateDataStoreVO templateStoreVO = templateStoreDao.findByStoreTemplate(store.getId(),
templateId);
+            if (templateStoreVO != null) {
                 found = true;
             }
         }
@@ -82,8 +78,9 @@ public class ImageDataFactoryImpl implements ImageDataFactory {
         return tmpl;
     }
 
+    // NOTE that this method can only be used for get template information stored in secondary
storage
     //TODO: this method is problematic, since one template can be stored in multiple image
stores.
-    // need to see if we can get rid of this method or change to plural format.
+    // need to see if we can get rid of this method or change to plural format, or restrict
to 1:1 mapping
     @Override
     public TemplateInfo getTemplate(long templateId) {
         VMTemplateVO templ = imageDataDao.findById(templateId);
@@ -94,6 +91,7 @@ public class ImageDataFactoryImpl implements ImageDataFactory {
         }
         return this.getTemplate(templateId, store);
     }
+
     @Override
     public TemplateInfo getTemplate(DataObject obj, DataStore store) {
         return this.getTemplate(obj.getId(), store);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
index ff96a19..a647715 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
@@ -21,15 +21,14 @@ package org.apache.cloudstack.storage.snapshot;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
+import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
 import org.springframework.stereotype.Component;
 
 import com.cloud.storage.DataStoreRole;
@@ -43,7 +42,7 @@ public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
     @Inject
     SnapshotDao snapshotDao;
     @Inject
-    ObjectInDataStoreManager objMap;
+    SnapshotDataStoreDao snapshotStoreDao;
     @Inject
     DataStoreManager storeMgr;
     @Inject
@@ -51,19 +50,20 @@ public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
     @Override
     public SnapshotInfo getSnapshot(long snapshotId, DataStore store) {
         SnapshotVO snapshot = snapshotDao.findByIdIncludingRemoved(snapshotId);
-        DataObjectInStore obj = objMap.findObject(snapshot.getId(), DataObjectType.SNAPSHOT,
store.getId(), store.getRole());
-        if (obj == null) {
-            return null;
-        }
         SnapshotObject so =  SnapshotObject.getSnapshotObject(snapshot, store);
         return so;
     }
+
     @Override
     public SnapshotInfo getSnapshot(long snapshotId) {
     	SnapshotVO snapshot = snapshotDao.findByIdIncludingRemoved(snapshotId);
     	SnapshotObject so = null;
     	if (snapshot.getState() == Snapshot.State.BackedUp) {
-    		DataStore store = objMap.findStore(snapshot.getId(), DataObjectType.SNAPSHOT, DataStoreRole.Image);
+    	    DataStore store = null;
+    	    SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshotId);
+    	    if ( snapshotStore != null ){
+    	        store = this.storeMgr.getDataStore(snapshotStore.getDataStoreId(), DataStoreRole.Image);
+    	    }
     		so =  SnapshotObject.getSnapshotObject(snapshot, store);
     	} else {
     		VolumeInfo volume = this.volumeFactory.getVolume(snapshot.getVolumeId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
index 69db872..6e12678 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
@@ -218,20 +218,11 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager
{
         if (role == DataStoreRole.Image) {
             switch (type){
             case TEMPLATE:
-                SearchCriteria<TemplateDataStoreVO> ts =  templateDataStoreDao.createSearchCriteria();
-                ts.addAnd("templateId", SearchCriteria.Op.EQ, objId);
-                ts.addAnd("dataStoreId", SearchCriteria.Op.EQ, dataStoreId);
-                vo =  templateDataStoreDao.findOneBy(ts);
+                vo = templateDataStoreDao.findByStoreTemplate(dataStoreId, objId);
             case SNAPSHOT:
-                SearchCriteria<SnapshotDataStoreVO> ss =  snapshotDataStoreDao.createSearchCriteria();
-                ss.addAnd("snapshotId", SearchCriteria.Op.EQ, objId);
-                ss.addAnd("dataStoreId", SearchCriteria.Op.EQ, objId);
-                vo =  snapshotDataStoreDao.findOneBy(ss);
+                vo = snapshotDataStoreDao.findByStoreSnapshot(dataStoreId, objId);
             case VOLUME:
-                SearchCriteria<VolumeDataStoreVO> vs =  volumeDataStoreDao.createSearchCriteria();
-                vs.addAnd("volumeId", SearchCriteria.Op.EQ, objId);
-                vs.addAnd("dataStoreId", SearchCriteria.Op.EQ, objId);
-                vo =  volumeDataStoreDao.findOneBy(vs);
+                vo = volumeDataStoreDao.findByStoreVolume(dataStoreId, objId);
             }
         } else if (type == DataObjectType.TEMPLATE && role == DataStoreRole.Primary)
{
             vo = templatePoolDao.findByPoolTemplate(dataStoreId, objId);
@@ -255,13 +246,17 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager
{
     public DataStore findStore(long objId, DataObjectType type,  DataStoreRole role) {
         DataStore store = null;
         if (role == DataStoreRole.Image) {
-            SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2.create(ObjectInDataStoreVO.class);
-            sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, role);
-            sc.addAnd(sc.getEntity().getObjectId(), Op.EQ, objId);
-            sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, type);
-            ObjectInDataStoreVO vo = sc.find();
+            DataObjectInStore vo = null;
+            switch (type){
+            case TEMPLATE:
+                vo = templateDataStoreDao.findByTemplate(objId);
+            case SNAPSHOT:
+                vo = snapshotDataStoreDao.findBySnapshot(objId);
+            case VOLUME:
+                vo = volumeDataStoreDao.findByVolume(objId);
+            }
             if (vo != null) {
-                store = this.storeMgr.getDataStore(vo.getDataStoreId(), vo.getDataStoreRole());
+                store = this.storeMgr.getDataStore(vo.getDataStoreId(), DataStoreRole.Image);
             }
         }
         return store;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreVO.java
b/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreVO.java
index fb8c93c..44b9174 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreVO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreVO.java
@@ -48,14 +48,14 @@ public class ObjectInDataStoreVO implements StateObject<ObjectInDataStoreStateMa
 
     @Column(name = "datastore_id")
     private long dataStoreId;
-    
+
     @Column(name = "datastore_role")
     @Enumerated(EnumType.STRING)
     private DataStoreRole dataStoreRole;
 
     @Column(name = "object_id")
     long objectId;
-    
+
     @Column(name = "object_type")
     @Enumerated(EnumType.STRING)
     DataObjectType objectType;
@@ -76,13 +76,13 @@ public class ObjectInDataStoreVO implements StateObject<ObjectInDataStoreStateMa
 
     @Column(name = "local_path")
     String localDownloadPath;
-    
+
     @Column (name="url")
     private String downloadUrl;
-    
+
     @Column(name="format")
     private Storage.ImageFormat format;
-    
+
     @Column(name="checksum")
     private String checksum;
 
@@ -97,46 +97,47 @@ public class ObjectInDataStoreVO implements StateObject<ObjectInDataStoreStateMa
 
     @Column(name = "size")
     Long size;
-    
+
     @Column(name = "state")
     @Enumerated(EnumType.STRING)
     ObjectInDataStoreStateMachine.State state;
 
     @Column(name="update_count", updatable = true, nullable=false)
     protected long updatedCount;
-    
+
     @Column(name = "updated")
     @Temporal(value = TemporalType.TIMESTAMP)
     Date updated;
-    
+
     public ObjectInDataStoreVO() {
         this.state = ObjectInDataStoreStateMachine.State.Allocated;
     }
-    
+
     public long getId() {
         return this.id;
     }
-    
+
     public DataStoreRole getDataStoreRole() {
         return this.dataStoreRole;
     }
-    
+
     public void setDataStoreRole(DataStoreRole role) {
         this.dataStoreRole = role;
     }
-    
+
+    @Override
     public long getObjectId() {
         return this.objectId;
     }
-    
+
     public void setObjectId(long id) {
         this.objectId = id;
     }
-    
+
     public DataObjectType getObjectType() {
         return this.objectType;
     }
-    
+
     public void setObjectType(DataObjectType type) {
         this.objectType = type;
     }
@@ -145,27 +146,27 @@ public class ObjectInDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     public ObjectInDataStoreStateMachine.State getState() {
         return this.state;
     }
-    
+
     public void setInstallPath(String path) {
         this.installPath = path;
     }
-    
+
     public String getInstallPath() {
         return this.installPath;
     }
-    
+
     public void setSize(Long size) {
         this.size = size;
     }
-    
+
     public Long getSize() {
         return this.size;
     }
-    
+
     public long getUpdatedCount() {
         return this.updatedCount;
     }
-    
+
     public void incrUpdatedCount() {
         this.updatedCount++;
     }
@@ -173,15 +174,16 @@ public class ObjectInDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     public void decrUpdatedCount() {
         this.updatedCount--;
     }
-    
+
     public Date getUpdated() {
         return updated;
     }
-    
+
     public void setUpdated(Date updated) {
         this.updated = updated;
     }
 
+    @Override
 	public long getDataStoreId() {
 		return dataStoreId;
 	}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
index c9ade1a..92e7d28 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
@@ -26,6 +26,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreState
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -42,6 +43,8 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
     private static final Logger s_logger = Logger.getLogger(SnapshotDataStoreDaoImpl.class);
     private SearchBuilder<SnapshotDataStoreVO> updateStateSearch;
     private SearchBuilder<SnapshotDataStoreVO> storeSearch;
+    private SearchBuilder<SnapshotDataStoreVO> snapshotSearch;
+    private SearchBuilder<SnapshotDataStoreVO> storeSnapshotSearch;
 
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
@@ -57,6 +60,18 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
         updateStateSearch.and("state", updateStateSearch.entity().getState(), Op.EQ);
         updateStateSearch.and("updatedCount", updateStateSearch.entity().getUpdatedCount(),
Op.EQ);
         updateStateSearch.done();
+
+        snapshotSearch = createSearchBuilder();
+        snapshotSearch.and("snapshot_id", snapshotSearch.entity().getSnapshotId(), SearchCriteria.Op.EQ);
+        snapshotSearch.and("destroyed", snapshotSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
+        snapshotSearch.done();
+
+        storeSnapshotSearch = createSearchBuilder();
+        storeSnapshotSearch.and("snapshot_id", storeSnapshotSearch.entity().getSnapshotId(),
SearchCriteria.Op.EQ);
+        storeSnapshotSearch.and("store_id", storeSnapshotSearch.entity().getDataStoreId(),
SearchCriteria.Op.EQ);
+        storeSnapshotSearch.and("destroyed", storeSnapshotSearch.entity().getDestroyed(),
SearchCriteria.Op.EQ);
+        storeSnapshotSearch.done();
+
         return true;
     }
 
@@ -116,6 +131,41 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
         txn.commit();
     }
 
+    @Override
+    public SnapshotDataStoreVO findByStoreSnapshot(long storeId, long snapshotId) {
+        SearchCriteria<SnapshotDataStoreVO> sc = storeSnapshotSearch.create();
+        sc.setParameters("store_id", storeId);
+        sc.setParameters("snapshot_id", snapshotId);
+        sc.setParameters("destroyed", false);
+        return findOneIncludingRemovedBy(sc);
+    }
+
 
+    @Override
+    public SnapshotDataStoreVO findByStoreSnapshot(long storeId, long snapshotId, boolean
lock) {
+        SearchCriteria<SnapshotDataStoreVO> sc = storeSnapshotSearch.create();
+        sc.setParameters("store_id", storeId);
+        sc.setParameters("snapshot_id", snapshotId);
+        sc.setParameters("destroyed", false);
+        if (!lock)
+            return findOneIncludingRemovedBy(sc);
+        else
+            return lockOneRandomRow(sc, true);
+    }
 
+    @Override
+    public SnapshotDataStoreVO findBySnapshot(long snapshotId) {
+        SearchCriteria<SnapshotDataStoreVO> sc = snapshotSearch.create();
+        sc.setParameters("snapshot_id", snapshotId);
+        sc.setParameters("destroyed", false);
+        return findOneIncludingRemovedBy(sc);
+    }
+
+    @Override
+    public List<SnapshotDataStoreVO> listDestroyed(long id) {
+        SearchCriteria<SnapshotDataStoreVO> sc = storeSearch.create();
+        sc.setParameters("store_id", id);
+        sc.setParameters("destroyed", true);
+        return listIncludingRemovedBy(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
index dc6c235..c144b36 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
@@ -133,12 +133,13 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO,
Lo
 
 
     @Override
-    public VolumeDataStoreVO findByVolumeId(long volumeId) {
+    public VolumeDataStoreVO findByVolume(long volumeId) {
         SearchCriteria<VolumeDataStoreVO> sc = volumeSearch.create();
         sc.setParameters("volume_id", volumeId);
         sc.setParameters("destroyed", false);
         return findOneBy(sc);
     }
+
     @Override
     public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId) {
         SearchCriteria<VolumeDataStoreVO> sc = storeVolumeSearch.create();
@@ -148,5 +149,23 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO,
Lo
         return findOneBy(sc);
     }
 
+    @Override
+    public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock)
{
+        SearchCriteria<VolumeDataStoreVO> sc = storeVolumeSearch.create();
+        sc.setParameters("store_id", storeId);
+        sc.setParameters("volume_id", volumeId);
+        sc.setParameters("destroyed", false);
+        if (!lock)
+            return findOneIncludingRemovedBy(sc);
+        else
+            return lockOneRandomRow(sc, true);
+    }
 
+    @Override
+    public List<VolumeDataStoreVO> listDestroyed(long id) {
+        SearchCriteria<VolumeDataStoreVO> sc = storeSearch.create();
+        sc.setParameters("store_id", id);
+        sc.setParameters("destroyed", true);
+        return listIncludingRemovedBy(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java
index 2929d38..e7a42de 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeDataFactoryImpl.java
@@ -21,12 +21,12 @@ package org.apache.cloudstack.storage.volume;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
+import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
 import org.springframework.stereotype.Component;
 
 import com.cloud.storage.DataStoreRole;
@@ -38,24 +38,28 @@ public class VolumeDataFactoryImpl implements VolumeDataFactory {
     @Inject
     VolumeDao volumeDao;
     @Inject
-    ObjectInDataStoreManager objMap;
+    VolumeDataStoreDao volumeStoreDao;
     @Inject
     DataStoreManager storeMgr;
     @Override
     public VolumeInfo getVolume(long volumeId, DataStore store) {
         VolumeVO volumeVO = volumeDao.findById(volumeId);
-       
+
         VolumeObject vol = VolumeObject.getVolumeObject(store, volumeVO);
-     
+
         return vol;
     }
-    
+
     @Override
     public VolumeInfo getVolume(long volumeId) {
         VolumeVO volumeVO = volumeDao.findById(volumeId);
         VolumeObject vol = null;
         if (volumeVO.getPoolId() == null) {
-            DataStore store = objMap.findStore(volumeVO.getId(), DataObjectType.VOLUME, DataStoreRole.Image);
+            DataStore store = null;
+            VolumeDataStoreVO volumeStore = volumeStoreDao.findByVolume(volumeId);
+            if ( volumeStore != null ){
+                store = this.storeMgr.getDataStore(volumeStore.getDataStoreId(), DataStoreRole.Image);
+            }
             vol = VolumeObject.getVolumeObject(store, volumeVO);
         } else {
             DataStore store = this.storeMgr.getDataStore(volumeVO.getPoolId(), DataStoreRole.Primary);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe3b01ec/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 2232095..d4087ed 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -774,7 +774,7 @@ public class VolumeServiceImpl implements VolumeService {
 
                     if (volInfo.getSize() > 0) {
                         try {
-                            String url = _volumeStoreDao.findByVolumeId(volume.getId()).getDownloadUrl();
+                            String url = _volumeStoreDao.findByVolume(volume.getId()).getDownloadUrl();
                             _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(volume.getAccountId()),
                                     com.cloud.configuration.Resource.ResourceType.secondary_storage,
                                     volInfo.getSize() - UriUtils.getRemoteSize(url));


Mime
View raw message