You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/06/15 01:11:16 UTC

[1/3] clean up storage related code, and add lru replacement algorithm for cache storage

Updated Branches:
  refs/heads/object_store 0acce2c51 -> a715eb812


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotVO.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotVO.java
deleted file mode 100644
index 43ec609..0000000
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotVO.java
+++ /dev/null
@@ -1,296 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.snapshot.db;
-
-import java.util.Date;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.Snapshot.State;
-import com.cloud.storage.Snapshot.Type;
-import com.cloud.utils.db.GenericDao;
-import com.google.gson.annotations.Expose;
-
-@Entity
-@Table(name = "snapshots")
-public class SnapshotVO {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name = "id")
-    private final long id = -1;
-
-    @Column(name = "data_center_id")
-    long dataCenterId;
-
-    @Column(name = "account_id")
-    long accountId;
-
-    @Column(name = "domain_id")
-    long domainId;
-
-    @Column(name = "volume_id")
-    Long volumeId;
-
-    @Column(name = "disk_offering_id")
-    Long diskOfferingId;
-
-    @Expose
-    @Column(name = "path")
-    String path;
-
-    @Expose
-    @Column(name = "name")
-    String name;
-
-    @Expose
-    @Column(name = "status", updatable = true, nullable = false)
-    @Enumerated(value = EnumType.STRING)
-    private State status;
-
-    @Column(name = "snapshot_type")
-    short snapshotType;
-
-    @Column(name = "type_description")
-    String typeDescription;
-
-    @Column(name = "size")
-    long size;
-
-    @Column(name = GenericDao.CREATED_COLUMN)
-    Date created;
-
-    @Column(name = GenericDao.REMOVED_COLUMN)
-    Date removed;
-
-    @Column(name = "backup_snap_id")
-    String backupSnapshotId;
-
-    @Column(name = "swift_id")
-    Long swiftId;
-
-    @Column(name = "s3_id")
-    Long s3Id;
-
-    @Column(name = "sechost_id")
-    Long secHostId;
-
-    @Column(name = "prev_snap_id")
-    long prevSnapshotId;
-
-    @Column(name = "hypervisor_type")
-    @Enumerated(value = EnumType.STRING)
-    HypervisorType hypervisorType;
-
-    @Expose
-    @Column(name = "version")
-    String version;
-
-    @Column(name = "uuid")
-    String uuid;
-
-    public SnapshotVO() {
-        this.uuid = UUID.randomUUID().toString();
-    }
-
-    public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String path,
-            String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType) {
-        this.dataCenterId = dcId;
-        this.accountId = accountId;
-        this.domainId = domainId;
-        this.volumeId = volumeId;
-        this.diskOfferingId = diskOfferingId;
-        this.path = path;
-        this.name = name;
-        this.snapshotType = snapshotType;
-        this.typeDescription = typeDescription;
-        this.size = size;
-        this.status = State.Creating;
-        this.prevSnapshotId = 0;
-        this.hypervisorType = hypervisorType;
-        this.version = "2.2";
-        this.uuid = UUID.randomUUID().toString();
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public long getDataCenterId() {
-        return dataCenterId;
-    }
-
-    public long getAccountId() {
-        return accountId;
-    }
-
-    public long getDomainId() {
-        return domainId;
-    }
-
-    public long getVolumeId() {
-        return volumeId;
-    }
-
-    public long getDiskOfferingId() {
-        return diskOfferingId;
-    }
-
-    public void setVolumeId(Long volumeId) {
-        this.volumeId = volumeId;
-    }
-
-    public String getPath() {
-        return path;
-    }
-
-    public void setPath(String path) {
-        this.path = path;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public short getsnapshotType() {
-        return snapshotType;
-    }
-
-    public Type getType() {
-        if (snapshotType < 0 || snapshotType >= Type.values().length) {
-            return null;
-        }
-        return Type.values()[snapshotType];
-    }
-
-    public Long getSwiftId() {
-        return swiftId;
-    }
-
-    public void setSwiftId(Long swiftId) {
-        this.swiftId = swiftId;
-    }
-
-    public Long getSecHostId() {
-        return secHostId;
-    }
-
-    public void setSecHostId(Long secHostId) {
-        this.secHostId = secHostId;
-    }
-
-    public HypervisorType getHypervisorType() {
-        return hypervisorType;
-    }
-
-    public void setSnapshotType(short snapshotType) {
-        this.snapshotType = snapshotType;
-    }
-
-    public boolean isRecursive() {
-        if (snapshotType >= Type.HOURLY.ordinal() && snapshotType <= Type.MONTHLY.ordinal()) {
-            return true;
-        }
-        return false;
-    }
-
-    public long getSize() {
-        return size;
-    }
-
-    public String getTypeDescription() {
-        return typeDescription;
-    }
-
-    public void setTypeDescription(String typeDescription) {
-        this.typeDescription = typeDescription;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public void setVersion(String version) {
-        this.version = version;
-    }
-
-    public Date getCreated() {
-        return created;
-    }
-
-    public Date getRemoved() {
-        return removed;
-    }
-
-    public State getStatus() {
-        return status;
-    }
-
-    public void setStatus(State status) {
-        this.status = status;
-    }
-
-    public String getBackupSnapshotId() {
-        return backupSnapshotId;
-    }
-
-    public long getPrevSnapshotId() {
-        return prevSnapshotId;
-    }
-
-    public void setBackupSnapshotId(String backUpSnapshotId) {
-        this.backupSnapshotId = backUpSnapshotId;
-    }
-
-    public void setPrevSnapshotId(long prevSnapshotId) {
-        this.prevSnapshotId = prevSnapshotId;
-    }
-
-    public static Type getSnapshotType(String snapshotType) {
-        for (Type type : Type.values()) {
-            if (type.equals(snapshotType)) {
-                return type;
-            }
-        }
-        return null;
-    }
-
-    public String getUuid() {
-        return this.uuid;
-    }
-
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-
-    public Long getS3Id() {
-        return s3Id;
-    }
-
-    public void setS3Id(Long s3Id) {
-        this.s3Id = s3Id;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
index 7120da1..b92f92f 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
@@ -55,11 +55,6 @@ public class DataStoreManagerImpl implements DataStoreManager {
     }
 
     @Override
-    public DataStore registerDataStore(Map<String, String> params, String providerUuid) {
-        return null;
-    }
-
-    @Override
     public DataStore getDataStore(String uuid, DataStoreRole role) {
         if (role == DataStoreRole.Primary) {
             return primaryStorMgr.getPrimaryDataStore(uuid);
@@ -85,11 +80,6 @@ public class DataStoreManagerImpl implements DataStoreManager {
     }
 
     @Override
-    public List<DataStore> getImageStoresByProvider(String provider) {
-        return imageDataStoreMgr.listImageStoreByProvider(provider);
-    }
-
-    @Override
     public DataStore getPrimaryDataStore(long storeId) {
         return primaryStorMgr.getPrimaryDataStore(storeId);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
index f62adfc..e861910 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
@@ -170,7 +170,7 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
     }
 
     @Override
-    public long getAvailableBytes() {
+    public long getUsedBytes() {
         // TODO Auto-generated method stub
         return 0;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
index db056e9..50238a8 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
@@ -57,12 +57,6 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
         return providerMap.get(name);
     }
 
-    @Override
-    public List<DataStoreProvider> getDataStoreProviders() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public List<StorageProviderResponse> getPrimaryDataStoreProviders() {
         List<StorageProviderResponse> providers = new ArrayList<StorageProviderResponse>();
         for (DataStoreProvider provider : providerMap.values()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/src/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java
index 561c8c4..93b0c2b 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java
@@ -67,29 +67,10 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
     EndPointSelector _epSelector;
 
     @Override
-    public String grantAccess(DataObject data, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public DataTO getTO(DataObject data) {
         return null;
     }
 
-
-    @Override
-    public boolean revokeAccess(DataObject data, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public Set<DataObject> listObjects(DataStore store) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     class CreateContext<T> extends AsyncRpcConext<T> {
         final DataObject data;
 
@@ -202,8 +183,6 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
         return null;
     }
 
-
-
     @Override
     public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
         DeleteCommand cmd = new DeleteCommand(data.getTO());
@@ -224,21 +203,14 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
 
     @Override
     public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public boolean canCopy(DataObject srcData, DataObject destData) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
-        // TODO Auto-generated method stub
-
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
index 70e5a5a..6815dec 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
@@ -108,12 +108,12 @@ public class PrimaryDataStoreHelper {
 
         StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
         pool.setScope(scope.getScopeType());
-        pool.setAvailableBytes(existingInfo.getAvailableBytes());
+        pool.setUsedBytes(existingInfo.getAvailableBytes());
         pool.setCapacityBytes(existingInfo.getCapacityBytes());
         pool.setStatus(StoragePoolStatus.Up);
         this.dataStoreDao.update(pool.getId(), pool);
         this.storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE,
-                pool.getCapacityBytes() - pool.getAvailableBytes());
+                pool.getUsedBytes());
         return dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
index 1fc8251..cfdb5c0 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
@@ -168,19 +168,16 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
 
     @Override
     public boolean isHypervisorSupported(HypervisorType hypervisor) {
-        // TODO Auto-generated method stub
         return true;
     }
 
     @Override
     public boolean isLocalStorageSupported() {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean isVolumeDiskTypeSupported(DiskFormat diskType) {
-        // TODO Auto-generated method stub
         return false;
     }
 
@@ -216,13 +213,11 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
 
     @Override
     public SnapshotInfo getSnapshot(long snapshotId) {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public DiskFormat getDefaultDiskType() {
-        // TODO Auto-generated method stub
         return null;
     }
 
@@ -288,8 +283,8 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
     }
 
     @Override
-    public long getAvailableBytes() {
-        return this.pdsv.getAvailableBytes();
+    public long getUsedBytes() {
+        return this.pdsv.getUsedBytes();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
deleted file mode 100644
index b248758..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
+++ /dev/null
@@ -1,16 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
index 6431308..fa5e216 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
@@ -81,7 +81,7 @@ public class DefaultHostListener implements HypervisorHostListener {
         }
 
         StoragePoolVO poolVO = this.primaryStoreDao.findById(poolId);
-        poolVO.setAvailableBytes(mspAnswer.getPoolInfo().getAvailableBytes());
+        poolVO.setUsedBytes(mspAnswer.getPoolInfo().getAvailableBytes());
         poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
         primaryStoreDao.update(pool.getId(), poolVO);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java
deleted file mode 100644
index 454a50c..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.volume;
-
-import java.lang.reflect.Method;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
-import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
-import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
-import org.apache.cloudstack.storage.datastore.PrimaryDataStoreEntityImpl;
-
-public class VolumeEntityImpl implements VolumeEntity {
-    private VolumeInfo volumeInfo;
-    private final VolumeService vs;
-    private VolumeApiResult result;
-
-    public VolumeEntityImpl() {
-        this.vs = null;
-    }
-
-    public VolumeEntityImpl(VolumeInfo volumeObject, VolumeService vs) {
-        this.volumeInfo = volumeObject;
-        this.vs = vs;
-    }
-
-    public VolumeInfo getVolumeInfo() {
-        return volumeInfo;
-    }
-
-    @Override
-    public String getUuid() {
-        return volumeInfo.getUuid();
-    }
-
-    @Override
-    public long getId() {
-        return volumeInfo.getId();
-    }
-
-    public String getExternalId() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public String getCurrentState() {
-        return null;
-    }
-
-    @Override
-    public String getDesiredState() {
-        return null;
-    }
-
-    @Override
-    public Date getCreatedTime() {
-        return null;
-    }
-
-    @Override
-    public Date getLastUpdatedTime() {
-        return null;
-    }
-
-    @Override
-    public String getOwner() {
-        return null;
-    }
-
-    @Override
-    public List<Method> getApplicableActions() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public SnapshotEntity takeSnapshotOf(boolean full) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public String reserveForMigration(long expirationTime) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public void migrate(String reservationToken) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public VolumeEntity setupForCopy() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public void copy(VolumeEntity dest) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void attachTo(String vm, long deviceId) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void detachFrom() {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public long getSize() {
-        return volumeInfo.getSize();
-    }
-
-    @Override
-    public DiskFormat getDiskType() {
-        return null;
-    }
-
-    @Override
-    public VolumeType getType() {
-        return null;
-    }
-
-    @Override
-    public StorageEntity getDataStore() {
-        return new PrimaryDataStoreEntityImpl((PrimaryDataStoreInfo) volumeInfo.getDataStore());
-    }
-
-    @Override
-    public void destroy() {
-        /*
-         * AsyncCallFuture<VolumeApiResult> future =
-         * vs.deleteVolumeAsync(volumeInfo); try { result = future.get(); if
-         * (!result.isSuccess()) { throw new
-         * CloudRuntimeException("Failed to create volume:" +
-         * result.getResult()); } } catch (InterruptedException e) { throw new
-         * CloudRuntimeException("wait to delete volume info failed", e); }
-         * catch (ExecutionException e) { throw new
-         * CloudRuntimeException("wait to delete volume failed", e); }
-         */
-    }
-
-    @Override
-    public Map<String, String> getDetails() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public void addDetail(String name, String value) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void delDetail(String name, String value) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void updateDetail(String name, String value) {
-        // TODO Auto-generated method stub
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
index 963015c..e799098 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
@@ -451,6 +451,47 @@ public class VolumeObject implements VolumeInfo {
 
     }
 
+    public void incRefCount() {
+        if (this.dataStore == null) {
+            return;
+        }
+
+        if (this.dataStore.getRole() == DataStoreRole.Image ||
+                this.dataStore.getRole() == DataStoreRole.ImageCache) {
+            VolumeDataStoreVO store = volumeStoreDao.findById(this.dataStore.getId());
+            store.incrRefCnt();
+            store.setLastUpdated(new Date());
+            volumeStoreDao.update(store.getId(), store);
+        }
+    }
+
+    @Override
+    public void decRefCount() {
+        if (this.dataStore == null) {
+            return;
+        }
+        if (this.dataStore.getRole() == DataStoreRole.Image ||
+                this.dataStore.getRole() == DataStoreRole.ImageCache) {
+            VolumeDataStoreVO store = volumeStoreDao.findById(this.dataStore.getId());
+            store.decrRefCnt();
+            store.setLastUpdated(new Date());
+            volumeStoreDao.update(store.getId(), store);
+        }
+    }
+
+    @Override
+    public Long getRefCount() {
+        if (this.dataStore == null) {
+            return null;
+        }
+        if (this.dataStore.getRole() == DataStoreRole.Image ||
+                this.dataStore.getRole() == DataStoreRole.ImageCache) {
+            VolumeDataStoreVO store = volumeStoreDao.findById(this.dataStore.getId());
+            return store.getRefCnt();
+        }
+        return null;
+    }
+
     @Override
     public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) {
         try {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/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 7d5b7a2..1d36f93 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
@@ -120,9 +120,6 @@ public class VolumeServiceImpl implements VolumeService {
         private final DataObject volume;
         private final AsyncCallFuture<VolumeApiResult> future;
 
-        /**
-         * @param callback
-         */
         public CreateVolumeContext(AsyncCompletionCallback<T> callback, DataObject volume,
                 AsyncCallFuture<VolumeApiResult> future) {
             super(callback);
@@ -178,9 +175,6 @@ public class VolumeServiceImpl implements VolumeService {
         private final VolumeObject volume;
         private final AsyncCallFuture<VolumeApiResult> future;
 
-        /**
-         * @param callback
-         */
         public DeleteVolumeContext(AsyncCompletionCallback<T> callback, VolumeObject volume,
                 AsyncCallFuture<VolumeApiResult> future) {
             super(callback);
@@ -266,17 +260,7 @@ public class VolumeServiceImpl implements VolumeService {
 
     @Override
     public VolumeEntity getVolumeEntity(long volumeId) {
-        VolumeVO vo = volDao.findById(volumeId);
-        if (vo == null) {
-            return null;
-        }
-
-        if (vo.getPoolId() == null) {
-            return new VolumeEntityImpl(VolumeObject.getVolumeObject(null, vo), this);
-        } else {
-            PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(vo.getPoolId());
-            return new VolumeEntityImpl(dataStore.getVolume(volumeId), this);
-        }
+        return null;
     }
 
     class CreateBaseImageContext<T> extends AsyncRpcConext<T> {
@@ -315,15 +299,6 @@ public class VolumeServiceImpl implements VolumeService {
 
     }
 
-    static class CreateBaseImageResult extends CommandResult {
-        final TemplateInfo template;
-
-        public CreateBaseImageResult(TemplateInfo template) {
-            super();
-            this.template = template;
-        }
-    }
-
     private TemplateInfo waitForTemplateDownloaded(PrimaryDataStore store, TemplateInfo template) {
         int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(
                 configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
@@ -571,9 +546,6 @@ public class VolumeServiceImpl implements VolumeService {
         final VolumeInfo destVolume;
         final AsyncCallFuture<VolumeApiResult> future;
 
-        /**
-         * @param callback
-         */
         public CopyVolumeContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<VolumeApiResult> future,
                 VolumeInfo srcVolume, VolumeInfo destVolume, DataStore destStore) {
             super(callback);
@@ -845,9 +817,6 @@ public class VolumeServiceImpl implements VolumeService {
         final Map<VolumeInfo, DataStore> volumeToPool;
         final AsyncCallFuture<CommandResult> future;
 
-        /**
-         * @param callback
-         */
         public MigrateVmWithVolumesContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<CommandResult> future,
                 Map<VolumeInfo, DataStore> volumeToPool) {
             super(callback);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java
index 7ff56f6..7b30575 100644
--- a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java
@@ -124,50 +124,32 @@ public class CloudStackImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
     @Override
     public boolean attachCluster(DataStore store, ClusterScope scope) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
-        // TODO Auto-generated method stub
         return false;
     }
 
 
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean dettach() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean unmanaged() {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean maintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean cancelMaintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean deleteDataStore(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
index 6965a15..2630d13 100644
--- a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
+++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
@@ -53,8 +53,6 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
     ImageStoreHelper imageStoreHelper;
     @Inject
     ImageStoreProviderManager imageStoreMgr;
-    @Inject
-    S3Manager _s3Mgr;
 
     protected List<? extends Discoverer> _discoverers;
 
@@ -83,12 +81,6 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
         s_logger.info("Trying to add a S3 store in data center " + dcId);
 
-        /*
-         * try{ // verify S3 parameters _s3Mgr.verifyS3Fields(details); } catch
-         * (DiscoveryException ex){ throw new
-         * InvalidParameterValueException("failed to verify S3 parameters!"); }
-         */
-
         Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
         imageStoreParameters.put("name", name);
         imageStoreParameters.put("zoneId", dcId);
@@ -113,51 +105,31 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
     @Override
     public boolean attachCluster(DataStore store, ClusterScope scope) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
-        // TODO Auto-generated method stub
         return false;
     }
 
-
-
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean dettach() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean unmanaged() {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean maintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean cancelMaintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean deleteDataStore(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
index 2dae3c8..44f94f3 100644
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
@@ -37,15 +37,12 @@ public class SampleImageStoreDriverImpl extends BaseImageStoreDriverImpl {
     public SampleImageStoreDriverImpl() {
     }
 
-
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
         // TODO Auto-generated method stub
         return null;
     }
 
-
-
     @Override
     public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format) {
         // TODO Auto-generated method stub

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
index c7e4801..e4df6f5 100644
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
@@ -52,49 +52,31 @@ public class SampleImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
     @Override
     public boolean attachCluster(DataStore store, ClusterScope scope) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisor) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean dettach() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean unmanaged() {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean maintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean cancelMaintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean deleteDataStore(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
index c0c55d6..c52e96e 100644
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
@@ -44,8 +44,6 @@ public class SampleImageStoreProviderImpl implements ImageStoreProvider {
     protected ImageStoreDriver driver;
     @Inject
     ImageStoreProviderManager storeMgr;
-    long id;
-    String uuid;
 
     @Override
     public DataStoreLifeCycle getDataStoreLifeCycle() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
index bd5a14a..d6d6cd2 100644
--- a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
@@ -39,7 +39,6 @@ public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
     @Inject
     ImageStoreDetailsDao _imageStoreDetailsDao;
 
-
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
         ImageStoreImpl imgStore = (ImageStoreImpl) store;
@@ -48,11 +47,9 @@ public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
                 details.get(ApiConstants.USERNAME), details.get(ApiConstants.KEY));
     }
 
-
     @Override
     public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format) {
         throw new UnsupportedServiceException("Extract entity url is not yet supported for Swift image store provider");
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
index 38e2007..4256cc2 100644
--- a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
@@ -16,12 +16,11 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.lifecycle;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-
+import com.cloud.agent.api.StoragePoolInfo;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.resource.ResourceManager;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.ScopeType;
 import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
@@ -33,12 +32,9 @@ import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
 import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
 import org.apache.log4j.Logger;
 
-import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.resource.Discoverer;
-import com.cloud.resource.ResourceManager;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.ScopeType;
+import javax.inject.Inject;
+import java.util.HashMap;
+import java.util.Map;
 
 public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
@@ -52,16 +48,6 @@ public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
     @Inject
     ImageStoreProviderManager imageStoreMgr;
 
-    protected List<? extends Discoverer> _discoverers;
-
-    public List<? extends Discoverer> getDiscoverers() {
-        return _discoverers;
-    }
-
-    public void setDiscoverers(List<? extends Discoverer> _discoverers) {
-        this._discoverers = _discoverers;
-    }
-
     public SwiftImageStoreLifeCycleImpl() {
     }
 
@@ -99,50 +85,32 @@ public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
     @Override
     public boolean attachCluster(DataStore store, ClusterScope scope) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
-        // TODO Auto-generated method stub
         return false;
     }
 
 
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean dettach() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean unmanaged() {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean maintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean cancelMaintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean deleteDataStore(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
index 4c2f389..8d7c965 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
@@ -18,27 +18,6 @@
  */
 package org.apache.cloudstack.storage.datastore.driver;
 
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.command.CommandResult;
-import org.apache.cloudstack.storage.command.CreateObjectCommand;
-import org.apache.cloudstack.storage.command.DeleteCommand;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.volume.VolumeObject;
-import org.apache.log4j.Logger;
-
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.storage.ResizeVolumeAnswer;
 import com.cloud.agent.api.storage.ResizeVolumeCommand;
@@ -58,6 +37,16 @@ import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.snapshot.SnapshotManager;
 import com.cloud.vm.dao.VMInstanceDao;
+import org.apache.cloudstack.engine.subsystem.api.storage.*;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.command.CommandResult;
+import org.apache.cloudstack.storage.command.CreateObjectCommand;
+import org.apache.cloudstack.storage.command.DeleteCommand;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.volume.VolumeObject;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
 
 public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
     private static final Logger s_logger = Logger.getLogger(CloudStackPrimaryDataStoreDriverImpl.class);
@@ -85,31 +74,12 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
     EndPointSelector epSelector;
 
     @Override
-    public String grantAccess(DataObject data, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public DataTO getTO(DataObject data) {
         return null;
     }
 
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public boolean revokeAccess(DataObject data, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public Set<DataObject> listObjects(DataStore store) {
-        // TODO Auto-generated method stub
         return null;
     }
 
@@ -126,7 +96,6 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
 
     @Override
     public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
-        // TODO Auto-generated method stub
         String errMsg = null;
         Answer answer = null;
         if (data.getType() == DataObjectType.VOLUME) {
@@ -168,13 +137,10 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
 
     @Override
     public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public boolean canCopy(DataObject srcData, DataObject destData) {
-        // TODO Auto-generated method stub
         return false;
     }
 
@@ -205,8 +171,6 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
 
     @Override
     public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
index 38dd5a9..2e0ff66 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
@@ -418,18 +418,6 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
     }
 
     @Override
-    public boolean dettach() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean unmanaged() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
     public boolean maintain(DataStore dataStore) {
         storagePoolAutmation.maintain(dataStore);
         this.dataStoreHelper.maintain(dataStore);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
index ad506d1..643c933 100644
--- a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
@@ -16,35 +16,20 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.driver;
 
-import java.net.URISyntaxException;
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.agent.api.to.DataTO;
+import com.cloud.storage.dao.StoragePoolHostDao;
+import org.apache.cloudstack.engine.subsystem.api.storage.*;
 import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.framework.async.AsyncRpcConext;
 import org.apache.cloudstack.storage.command.CommandResult;
-import org.apache.cloudstack.storage.command.CreateObjectAnswer;
 import org.apache.cloudstack.storage.command.CreateObjectCommand;
 import org.apache.cloudstack.storage.datastore.DataObjectManager;
 import org.apache.log4j.Logger;
 
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.DataTO;
-import com.cloud.storage.dao.StoragePoolHostDao;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.storage.encoding.DecodedDataObject;
-import com.cloud.utils.storage.encoding.Decoder;
+import javax.inject.Inject;
 
 public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
     private static final Logger s_logger = Logger.getLogger(SamplePrimaryDataStoreDriverImpl.class);
@@ -66,25 +51,15 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
 
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
-        // TODO Auto-generated method stub
         return null;
     }
 
     private class CreateVolumeContext<T> extends AsyncRpcConext<T> {
         private final DataObject volume;
-
-        /**
-         * @param callback
-         */
         public CreateVolumeContext(AsyncCompletionCallback<T> callback, DataObject volume) {
             super(callback);
             this.volume = volume;
         }
-
-        public DataObject getVolume() {
-            return this.volume;
-        }
-
     }
 
     public Void createAsyncCallback(AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> callback,
@@ -183,74 +158,24 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
     }
 
     @Override
-    public String grantAccess(DataObject object, EndPoint ep) {
-        // StoragePoolHostVO poolHost =
-        // storeHostDao.findByPoolHost(object.getDataStore().getId(),
-        // ep.getId());
-
-        String uri = object.getUri();
-        try {
-            DecodedDataObject obj = Decoder.decode(uri);
-            if (obj.getPath() == null) {
-                // create an obj
-                EndPoint newEp = selector.select(object);
-                CreateObjectCommand createCmd = new CreateObjectCommand(null);
-                CreateObjectAnswer answer = (CreateObjectAnswer) ep.sendMessage(createCmd);
-                if (answer.getResult()) {
-                    // dataObjMgr.update(object, answer.getPath(),
-                    // answer.getSize());
-                } else {
-                    s_logger.debug("failed to create object" + answer.getDetails());
-                    throw new CloudRuntimeException("failed to create object" + answer.getDetails());
-                }
-            }
-
-            return object.getUri();
-        } catch (URISyntaxException e) {
-            throw new CloudRuntimeException("uri parsed error", e);
-        }
-    }
-
-    @Override
-    public boolean revokeAccess(DataObject vol, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public Set<DataObject> listObjects(DataStore store) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public boolean canCopy(DataObject srcData, DataObject destData) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
index 7ee8565..92538ad 100644
--- a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
@@ -18,18 +18,12 @@
  */
 package org.apache.cloudstack.storage.datastore.lifecycle;
 
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
-import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import com.cloud.agent.api.StoragePoolInfo;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.StoragePoolStatus;
+import org.apache.cloudstack.engine.subsystem.api.storage.*;
 import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
 import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
@@ -37,11 +31,9 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
 
-import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.StoragePoolStatus;
+import javax.inject.Inject;
+import java.util.List;
+import java.util.Map;
 
 public class SamplePrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLifeCycle {
     @Inject
@@ -103,44 +95,27 @@ public class SamplePrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLife
     }
 
     @Override
-    public boolean dettach() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean unmanaged() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean maintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean cancelMaintain(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean deleteDataStore(DataStore store) {
-        // TODO Auto-generated method stub
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
index 8708821..79ffc8f 100644
--- a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
@@ -40,8 +40,6 @@ public class SamplePrimaryDatastoreProviderImpl implements PrimaryDataStoreProvi
     PrimaryDataStoreProviderManager storeMgr;
 
     protected DataStoreLifeCycle lifecycle;
-    protected String uuid;
-    protected long id;
 
     @Override
     public String getName() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
index a296bab..960378c 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
@@ -16,92 +16,51 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.driver;
 
-import java.util.Set;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.command.CommandResult;
-
 import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
+import org.apache.cloudstack.engine.subsystem.api.storage.*;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.command.CommandResult;
 
 public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
 
     @Override
-    public String grantAccess(DataObject data, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public DataTO getTO(DataObject data) {
         return null;
     }
 
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public boolean revokeAccess(DataObject data, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public Set<DataObject> listObjects(DataStore store) {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public boolean canCopy(DataObject srcData, DataObject destData) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override
     public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) {
-        // TODO Auto-generated method stub
-
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
index 03f241e..2965e8f 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
@@ -29,11 +29,6 @@ import org.springframework.stereotype.Component;
 public class SolidfirePrimaryDataStoreProvider implements PrimaryDataStoreProvider {
     private final String name = "Solidfire Primary Data Store Provider";
 
-    public SolidfirePrimaryDataStoreProvider() {
-
-        // TODO Auto-generated constructor stub
-    }
-
     @Override
     public String getName() {
         return name;
@@ -41,31 +36,26 @@ public class SolidfirePrimaryDataStoreProvider implements PrimaryDataStoreProvid
 
     @Override
     public DataStoreLifeCycle getDataStoreLifeCycle() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public DataStoreDriver getDataStoreDriver() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public HypervisorHostListener getHostListener() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public boolean configure(Map<String, Object> params) {
-        // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public Set<DataStoreProviderType> getTypes() {
-        // TODO Auto-generated method stub
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 5ee0fad..6bad417 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -72,7 +72,10 @@ public enum Config {
 	StorageOverprovisioningFactor("Storage", StoragePoolAllocator.class, String.class, "storage.overprovisioning.factor", "2", "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", null, ConfigurationParameterScope.zone.toString()),
 	StorageStatsInterval("Storage", ManagementServer.class, String.class, "storage.stats.interval", "60000", "The interval (in milliseconds) when storage stats (per host) are retrieved from agents.", null),
 	MaxVolumeSize("Storage", ManagementServer.class, Integer.class, "storage.max.volume.size", "2000", "The maximum size for a volume (in GB).", null),
-	MaxUploadVolumeSize("Storage",  ManagementServer.class, Integer.class, "storage.max.volume.upload.size", "500", "The maximum size for a uploaded volume(in GB).", null),
+    StorageCacheReplacementLRUTimeInterval("Storage", ManagementServer.class, Integer.class, "storage.cache.replacement.lru.interval", "30", "time interval for unsed data on cache storage (in days).", null),
+    StorageCacheReplacementEnabled("Storage", ManagementServer.class, Boolean.class, "storage.cache.replacement.enabled", "true", "enable or disable cache storage replacement algorithm.", null),
+    StorageCacheReplacementInterval("Storage", ManagementServer.class, Integer.class, "storage.cache.replacement.interval", "86400", "time interval between cache replacement threads (in seconds).", null),
+    MaxUploadVolumeSize("Storage",  ManagementServer.class, Integer.class, "storage.max.volume.upload.size", "500", "The maximum size for a uploaded volume(in GB).", null),
 	TotalRetries("Storage", AgentManager.class, Integer.class, "total.retries", "4", "The number of times each command sent to a host should be retried in case of failure.", null),
 	StoragePoolMaxWaitSeconds("Storage", ManagementServer.class, Integer.class, "storage.pool.max.waitseconds", "3600", "Timeout (in seconds) to synchronize storage pool operations.", null),
 	StorageTemplateCleanupEnabled("Storage", ManagementServer.class, Boolean.class, "storage.template.cleanup.enabled", "true", "Enable/disable template cleanup activity, only take effect when overall storage cleanup is enabled", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/server/src/com/cloud/server/StatsCollector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java
index e510435..0d7fc3d 100755
--- a/server/src/com/cloud/server/StatsCollector.java
+++ b/server/src/com/cloud/server/StatsCollector.java
@@ -185,13 +185,6 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
              _executor.scheduleAtFixedRate(new VmDiskStatsTask(), vmDiskStatsInterval, vmDiskStatsInterval, TimeUnit.SECONDS);
          }
 
-		// -1 means we don't even start this thread to pick up any data.
-		if (volumeStatsInterval > 0) {
-			_executor.scheduleWithFixedDelay(new VolumeCollector(), 15000L, volumeStatsInterval, TimeUnit.MILLISECONDS);
-		} else {
-			s_logger.info("Disabling volume stats collector");
-		}
-
         //Schedule disk stats update task
         _diskStatsUpdateExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("DiskStatsUpdater"));
         String aggregationRange = configs.get("usage.stats.job.aggregation.range");
@@ -548,13 +541,6 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                     if (answer != null && answer.getResult()) {
                         storageStats.put(storeId, (StorageStats)answer);
                         s_logger.trace("HostId: "+storeId+ " Used: " + ((StorageStats)answer).getByteUsed() + " Total Available: " + ((StorageStats)answer).getCapacityBytes());
-                        //Seems like we have dynamically updated the sec. storage as prev. size and the current do not match
-                        if (_storageStats.get(storeId)!=null &&
-                        		_storageStats.get(storeId).getCapacityBytes() != ((StorageStats)answer).getCapacityBytes()){
-                            ImageStoreVO imgStore = _imageStoreDao.findById(storeId);
-	                       	imgStore.setTotalSize(((StorageStats)answer).getCapacityBytes());
-	                        _imageStoreDao.update(storeId, imgStore);
-	                    }
                     }
                 }
                 _storageStats = storageStats;
@@ -603,79 +589,4 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
 	public StorageStats getStoragePoolStats(long id) {
 		return _storagePoolStats.get(id);
 	}
-
-	class VolumeCollector implements Runnable {
-		@Override
-        public void run() {
-			try {
-				List<VolumeVO> volumes = _volsDao.listAll();
-				Map<Long, List<VolumeCommand>> commandsByPool = new HashMap<Long, List<VolumeCommand>>();
-
-				for (VolumeVO volume : volumes) {
-					List<VolumeCommand> commands = commandsByPool.get(volume.getPoolId());
-					if (commands == null) {
-						commands = new ArrayList<VolumeCommand>();
-						commandsByPool.put(volume.getPoolId(), commands);
-					}
-					VolumeCommand vCommand = new VolumeCommand();
-					vCommand.volumeId = volume.getId();
-					vCommand.command = new GetFileStatsCommand(volume);
-					commands.add(vCommand);
-				}
-				ConcurrentHashMap<Long, VolumeStats> volumeStats = new ConcurrentHashMap<Long, VolumeStats>();
-				for (Iterator<Long> iter = commandsByPool.keySet().iterator(); iter.hasNext();) {
-					Long poolId = iter.next();
-					if(poolId != null) {
-						List<VolumeCommand> commandsList = commandsByPool.get(poolId);
-
-						long[] volumeIdArray = new long[commandsList.size()];
-						Commands commands = new Commands(OnError.Continue);
-						for (int i = 0; i < commandsList.size(); i++) {
-							VolumeCommand vCommand = commandsList.get(i);
-							volumeIdArray[i] = vCommand.volumeId;
-							commands.addCommand(vCommand.command);
-						}
-
-			            List<StoragePoolHostVO> poolhosts = _storagePoolHostDao.listByPoolId(poolId);
-			            for(StoragePoolHostVO poolhost : poolhosts) {
-	    					Answer[] answers = _agentMgr.send(poolhost.getHostId(), commands);
-	    					if (answers != null) {
-	    					    long totalBytes = 0L;
-	    						for (int i = 0; i < answers.length; i++) {
-	    							if (answers[i].getResult()) {
-	    							    VolumeStats vStats = (VolumeStats)answers[i];
-	    								volumeStats.put(volumeIdArray[i], vStats);
-	    								totalBytes += vStats.getBytesUsed();
-	    							}
-	    						}
-	    						break;
-	                        }
-			            }
-					}
-				}
-
-				// We replace the existing volumeStats so that it does not grow with no bounds
-				_volumeStats = volumeStats;
-			} catch (AgentUnavailableException e) {
-			    s_logger.debug(e.getMessage());
-			} catch (Throwable t) {
-				s_logger.error("Error trying to retrieve volume stats", t);
-			}
-		}
-	}
-
-	private class VolumeCommand {
-		public long volumeId;
-		public GetFileStatsCommand command;
-	}
-
-	public VolumeStats[] getVolumeStats(long[] ids) {
-		VolumeStats[] stats = new VolumeStats[ids.length];
-		if (volumeStatsInterval > 0) {
-			for (int i = 0; i < ids.length; i++) {
-				stats[i] = _volumeStats.get(ids[i]);
-			}
-		}
-		return stats;
-	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 387e909..a8a133f 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -37,6 +37,7 @@ ALTER TABLE `cloud`.`load_balancer_vm_map` ADD state VARCHAR(40) NULL COMMENT 's
 
 alter table storage_pool add hypervisor varchar(32);
 alter table storage_pool change storage_provider_id storage_provider_name varchar(255);
+alter table storage_pool change available_bytes used_bytes bigint unsigned;
 -- alter table template_host_ref add state varchar(255);
 -- alter table template_host_ref add update_count bigint unsigned;
 -- alter table template_host_ref add updated datetime;
@@ -88,7 +89,8 @@ CREATE TABLE `cloud`.`image_store` (
   `parent` varchar(255) COMMENT 'parent path for the storage server',
   `created` datetime COMMENT 'date the image store first signed on',
   `removed` datetime COMMENT 'date removed if not null',  
-  `total_size` bigint unsigned COMMENT 'storage statistics',
+  `total_size` bigint unsigned COMMENT 'storage total size statistics',
+  `used_bytes` bigint unsigned COMMENT 'storage available bytes statistics',
   PRIMARY KEY(`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -149,6 +151,7 @@ CREATE TABLE  `cloud`.`template_store_ref` (
   `destroyed` tinyint(1) COMMENT 'indicates whether the template_store entry was destroyed by the user or not',
   `is_copy` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates whether this was copied ',
   `update_count` bigint unsigned,
+  `ref_cnt` bigint unsigned,
   `updated` datetime, 
   PRIMARY KEY  (`id`),
 --  CONSTRAINT `fk_template_store_ref__store_id` FOREIGN KEY `fk_template_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
@@ -183,6 +186,7 @@ CREATE TABLE  `cloud`.`snapshot_store_ref` (
   `state` varchar(255) NOT NULL,  
   -- `removed` datetime COMMENT 'date removed if not null',  
   `update_count` bigint unsigned,
+  `ref_cnt` bigint unsigned,
   `updated` datetime,   
   PRIMARY KEY  (`id`),
   INDEX `i_snapshot_store_ref__store_id`(`store_id`),
@@ -210,6 +214,7 @@ CREATE TABLE  `cloud`.`volume_store_ref` (
   `state` varchar(255) NOT NULL,  
   `destroyed` tinyint(1) COMMENT 'indicates whether the volume_host entry was destroyed by the user or not',
   `update_count` bigint unsigned,
+  `ref_cnt` bigint unsigned,
   `updated` datetime,   
   PRIMARY KEY  (`id`),
   CONSTRAINT `fk_volume_store_ref__store_id` FOREIGN KEY `fk_volume_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/test/pom.xml
----------------------------------------------------------------------
diff --git a/test/pom.xml b/test/pom.xml
index d4b8832..92e6273 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -75,7 +75,7 @@
     </dependencies>
     <build>
         <defaultGoal>compile</defaultGoal>
-        <sourceDirectory>src</sourceDirectory>
+        <sourceDirectory>test</sourceDirectory>
         <testSourceDirectory>test</testSourceDirectory>
         <plugins>
             <plugin>


[3/3] git commit: updated refs/heads/object_store to a715eb8

Posted by ed...@apache.org.
clean up storage related code, and add lru replacement algorithm for cache storage


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

Branch: refs/heads/object_store
Commit: a715eb8121b3e9b6bb61fe3db150580b22e4b3aa
Parents: 0acce2c
Author: Edison Su <ed...@citrix.com>
Authored: Fri Jun 14 15:55:44 2013 -0700
Committer: Edison Su <ed...@citrix.com>
Committed: Fri Jun 14 15:55:59 2013 -0700

----------------------------------------------------------------------
 agent/src/com/cloud/agent/AgentShell.java       |   1 +
 api/src/com/cloud/storage/StoragePool.java      |   2 +-
 client/tomcatconf/applicationContext.xml.in     |   1 +
 client/tomcatconf/log4j-cloud.xml.in            |   4 +
 .../agent/test/BackupSnapshotCommandTest.java   |   2 +-
 .../api/agent/test/CheckNetworkAnswerTest.java  | 205 ++++++++++++
 .../api/agent/test/SnapshotCommandTest.java     |   2 +-
 .../agent/api/test/ResizeVolumeCommandTest.java | 229 --------------
 .../subsystem/api/storage/ClusterScope.java     |   1 +
 .../api/storage/DataMigrationSubSystem.java     |  30 --
 .../api/storage/DataMotionService.java          |   4 +-
 .../api/storage/DataMotionStrategy.java         |   8 +-
 .../subsystem/api/storage/DataObject.java       |  25 +-
 .../api/storage/DataObjectInStore.java          |  10 +-
 .../subsystem/api/storage/DataStoreDriver.java  |  27 +-
 .../api/storage/DataStoreLifeCycle.java         |  16 +-
 .../subsystem/api/storage/DataStoreManager.java |  18 +-
 .../api/storage/DataStoreProvider.java          |  25 +-
 .../api/storage/DataStoreProviderManager.java   |  11 +-
 .../engine/subsystem/api/storage/EndPoint.java  |  10 +-
 .../subsystem/api/storage/EndPointSelector.java |  10 +-
 .../engine/subsystem/api/storage/HostScope.java |   1 +
 .../api/storage/ImageStoreProvider.java         |   4 +-
 .../api/storage/PrimaryDataStoreDriver.java     |   4 +-
 .../api/storage/PrimaryDataStoreInfo.java       |  12 +-
 .../engine/subsystem/api/storage/Scope.java     |   6 +-
 .../api/storage/SnapshotDataFactory.java        |   6 +-
 .../subsystem/api/storage/SnapshotInfo.java     |  10 +-
 .../subsystem/api/storage/SnapshotService.java  |   8 +-
 .../subsystem/api/storage/SnapshotStrategy.java |  10 +-
 .../api/storage/StorageCacheManager.java        |   8 +-
 .../api/storage/StorageOrchestrator.java        |  76 -----
 .../api/storage/StoragePoolAllocator.java       |   2 +-
 .../subsystem/api/storage/StorageSubSystem.java |  31 --
 .../subsystem/api/storage/TemplateInfo.java     |   4 +-
 .../subsystem/api/storage/TemplateProfile.java  | 312 -------------------
 .../subsystem/api/storage/TemplateService.java  |   2 +-
 .../subsystem/api/storage/VolumeInfo.java       |  18 +-
 .../subsystem/api/storage/VolumeProfile.java    |  35 ---
 .../subsystem/api/storage/VolumeService.java    |   3 +-
 .../engine/subsystem/api/storage/ZoneScope.java |   1 +
 .../storage/command/CreateObjectCommand.java    |   1 -
 .../storage/datastore/db/ImageStoreDao.java     |  10 +-
 .../storage/datastore/db/ImageStoreVO.java      |  10 +
 .../datastore/db/PrimaryDataStoreDaoImpl.java   |   2 +-
 .../datastore/db/SnapshotDataStoreDao.java      |  10 +-
 .../datastore/db/SnapshotDataStoreVO.java       |  15 +
 .../storage/datastore/db/StoragePoolVO.java     |  16 +-
 .../datastore/db/TemplateDataStoreDao.java      |   8 +-
 .../datastore/db/TemplateDataStoreVO.java       |  21 +-
 .../datastore/db/VolumeDataStoreDao.java        |  12 +-
 .../storage/datastore/db/VolumeDataStoreVO.java |  19 +-
 .../storage/image/datastore/ImageStoreInfo.java |   4 +-
 .../cloudstack/storage/to/ImageStoreTO.java     |   9 +-
 .../storage/to/PrimaryDataStoreTO.java          |   6 +
 .../cloudstack/storage/to/SnapshotObjectTO.java |   6 +
 .../cloudstack/storage/to/TemplateObjectTO.java |   6 +
 .../cloudstack/storage/to/VolumeObjectTO.java   |   6 +
 .../cache/manager/StorageCacheManagerImpl.java  | 156 +++++++---
 .../StorageCacheReplacementAlgorithm.java       |  26 ++
 .../StorageCacheReplacementAlgorithmLRU.java    | 106 +++++++
 .../motion/AncientDataMotionStrategy.java       |  15 +-
 .../storage/motion/DataMotionDriver.java        |  25 --
 .../storage/image/ImageOrchestrator.java        |  29 --
 .../storage/image/TemplateServiceImpl.java      |   2 -
 .../image/downloader/ImageDownloader.java       |  25 --
 .../manager/ImageStoreProviderManagerImpl.java  |   1 -
 .../storage/image/store/ImageStoreImpl.java     |  10 +-
 .../storage/image/store/TemplateObject.java     |  42 +++
 .../storage/allocator/StorageAllocatorTest.java |   4 +-
 ...StorageCacheReplacementAlgorithmLRUTest.java | 226 ++++++++++++++
 .../cloudstack/storage/test/SnapshotTest.java   | 101 +++---
 .../cloudstack/storage/test/VolumeTest.java     |  79 +++--
 .../test/resource/storageContext.xml            |   5 +-
 .../storage/snapshot/SnapshotObject.java        |  44 ++-
 .../storage/snapshot/SnapshotServiceImpl.java   |  44 +--
 .../snapshot/SnapshotStateMachineManager.java   |   2 +-
 .../snapshot/XenserverSnapshotStrategy.java     |   1 -
 .../storage/snapshot/db/SnapshotDao2.java       |  25 --
 .../storage/snapshot/db/SnapshotDao2Impl.java   |  28 --
 .../storage/snapshot/db/SnapshotVO.java         | 296 ------------------
 .../storage/datastore/DataStoreManagerImpl.java |  10 -
 .../datastore/PrimaryDataStoreEntityImpl.java   |   2 +-
 .../provider/DataStoreProviderManagerImpl.java  |   6 -
 .../storage/image/BaseImageStoreDriverImpl.java |  28 --
 .../datastore/PrimaryDataStoreHelper.java       |   4 +-
 .../storage/datastore/PrimaryDataStoreImpl.java |   9 +-
 .../driver/PrimaryDataStoreDriver.java          |  16 -
 .../datastore/provider/DefaultHostListener.java |   2 +-
 .../storage/volume/VolumeEntityImpl.java        | 201 ------------
 .../cloudstack/storage/volume/VolumeObject.java |  41 +++
 .../storage/volume/VolumeServiceImpl.java       |  33 +-
 .../CloudStackImageStoreLifeCycleImpl.java      |  18 --
 .../lifecycle/S3ImageStoreLifeCycleImpl.java    |  28 --
 .../driver/SampleImageStoreDriverImpl.java      |   3 -
 .../SampleImageStoreLifeCycleImpl.java          |  18 --
 .../provider/SampleImageStoreProviderImpl.java  |   2 -
 .../driver/SwiftImageStoreDriverImpl.java       |   3 -
 .../lifecycle/SwiftImageStoreLifeCycleImpl.java |  48 +--
 .../CloudStackPrimaryDataStoreDriverImpl.java   |  56 +---
 ...CloudStackPrimaryDataStoreLifeCycleImpl.java |  12 -
 .../SamplePrimaryDataStoreDriverImpl.java       |  87 +-----
 .../SamplePrimaryDataStoreLifeCycleImpl.java    |  43 +--
 .../SamplePrimaryDatastoreProviderImpl.java     |   2 -
 .../driver/SolidfirePrimaryDataStoreDriver.java |  47 +--
 .../SolidfirePrimaryDataStoreProvider.java      |  10 -
 server/src/com/cloud/configuration/Config.java  |   5 +-
 server/src/com/cloud/server/StatsCollector.java |  89 ------
 setup/db/db/schema-410to420.sql                 |   7 +-
 test/pom.xml                                    |   2 +-
 110 files changed, 1226 insertions(+), 2253 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/agent/src/com/cloud/agent/AgentShell.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java
index cf454b8..e7f114b 100644
--- a/agent/src/com/cloud/agent/AgentShell.java
+++ b/agent/src/com/cloud/agent/AgentShell.java
@@ -82,6 +82,7 @@ public class AgentShell implements IAgentShell, Daemon {
     private int _pingRetries;
     private final List<Agent> _agents = new ArrayList<Agent>();
 
+
     public AgentShell() {
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/api/src/com/cloud/storage/StoragePool.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/StoragePool.java b/api/src/com/cloud/storage/StoragePool.java
index 8b95383..8f8b864 100644
--- a/api/src/com/cloud/storage/StoragePool.java
+++ b/api/src/com/cloud/storage/StoragePool.java
@@ -58,7 +58,7 @@ public interface StoragePool extends Identity, InternalIdentity {
     /**
      * @return available storage in bytes
      */
-    long getAvailableBytes();
+    long getUsedBytes();
 
     Long getClusterId();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 8d251ee..181219a 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -815,6 +815,7 @@
   <bean id="swiftImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl" />  
   <bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" />
   <bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" />
+  <bean id="StorageCacheReplacementAlgorithm" class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU" />
 
 
 <!--=======================================================================================================-->

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/client/tomcatconf/log4j-cloud.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/log4j-cloud.xml.in b/client/tomcatconf/log4j-cloud.xml.in
index 0e7f004..fc1c29e 100755
--- a/client/tomcatconf/log4j-cloud.xml.in
+++ b/client/tomcatconf/log4j-cloud.xml.in
@@ -132,6 +132,10 @@ under the License.
       <priority value="INFO"/>
    </category>
 
+   <category name="org.apache.cloudstack">
+      <priority value="DEBUG"/>
+   </category>
+
    <category name="org.apache.cloudstack.api.command">
       <priority value="TRACE"/>
    </category>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
index 40083a8..9890593 100644
--- a/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
+++ b/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
@@ -83,7 +83,7 @@ public class BackupSnapshotCommandTest {
         };
 
         @Override
-        public long getAvailableBytes() {
+        public long getUsedBytes() {
             return 0L;
         };
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java
index 1853d39..4db6557 100644
--- a/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java
+++ b/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java
@@ -16,9 +16,15 @@
 // under the License.
 package org.apache.cloudstack.api.agent.test;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import com.cloud.agent.api.storage.ResizeVolumeCommand;
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.storage.Storage;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.StoragePoolStatus;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -26,6 +32,10 @@ import org.mockito.Mockito;
 import com.cloud.agent.api.CheckNetworkAnswer;
 import com.cloud.agent.api.CheckNetworkCommand;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 public class CheckNetworkAnswerTest {
     CheckNetworkCommand cnc;
     CheckNetworkAnswer cna;
@@ -59,4 +69,199 @@ public class CheckNetworkAnswerTest {
         boolean b = cna.executeInSequence();
         assertFalse(b);
     }
+
+    public static class ResizeVolumeCommandTest {
+
+        public StoragePool dummypool = new StoragePool() {
+            @Override
+            public long getId() {
+                return 1L;
+            };
+
+            @Override
+            public String getName() {
+                return "name";
+            };
+
+            @Override
+            public String getUuid() {
+                return "bed9f83e-cac3-11e1-ac8a-0050568b007e";
+            };
+
+            @Override
+            public Storage.StoragePoolType getPoolType() {
+                return Storage.StoragePoolType.Filesystem;
+            };
+
+            @Override
+            public Date getCreated() {
+                Date date = null;
+                try {
+                    date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
+                    .parse("01/01/1970 12:12:12");
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+                return date;
+            }
+
+            @Override
+            public Date getUpdateTime() {
+                return new Date();
+            };
+
+            @Override
+            public long getDataCenterId() {
+                return 0L;
+            };
+
+            @Override
+            public long getCapacityBytes() {
+                return 0L;
+            };
+
+            @Override
+            public long getUsedBytes() {
+                return 0L;
+            };
+
+            @Override
+            public Long getClusterId() {
+                return 0L;
+            };
+
+            @Override
+            public String getHostAddress() {
+                return "hostAddress";
+            };
+
+            @Override
+            public String getPath() {
+                return "path";
+            };
+
+            @Override
+            public String getUserInfo() {
+                return "userInfo";
+            };
+
+            @Override
+            public boolean isShared() {
+                return false;
+            };
+
+            @Override
+            public boolean isLocal() {
+                return false;
+            };
+
+            @Override
+            public StoragePoolStatus getStatus() {
+                return StoragePoolStatus.Up;
+            };
+
+            @Override
+            public int getPort() {
+                return 25;
+            };
+
+            @Override
+            public Long getPodId() {
+                return 0L;
+            }
+
+            @Override
+            public String getStorageProviderName() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public boolean isInMaintenance() {
+                // TODO Auto-generated method stub
+                return false;
+            };
+        };
+
+        Long newSize = 4194304L;
+        Long currentSize = 1048576L;
+
+        ResizeVolumeCommand rv = new ResizeVolumeCommand("dummydiskpath",
+                new StorageFilerTO(dummypool), currentSize, newSize, false,
+                "vmName");
+
+        @Test
+        public void testExecuteInSequence() {
+            boolean b = rv.executeInSequence();
+            assertFalse(b);
+        }
+
+        @Test
+        public void testGetPath() {
+            String path = rv.getPath();
+            assertTrue(path.equals("dummydiskpath"));
+        }
+
+        @Test
+        public void testGetPoolUuid() {
+            String poolUuid = rv.getPoolUuid();
+            assertTrue(poolUuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
+        }
+
+        @Test
+        public void testGetPool() {
+            StorageFilerTO pool = rv.getPool();
+
+            Long id = pool.getId();
+            Long expectedL = 1L;
+            assertEquals(expectedL, id);
+
+            String uuid = pool.getUuid();
+            assertTrue(uuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
+
+            String host = pool.getHost();
+            assertTrue(host.equals("hostAddress"));
+
+            String path = pool.getPath();
+            assertTrue(path.equals("path"));
+
+            String userInfo = pool.getUserInfo();
+            assertTrue(userInfo.equals("userInfo"));
+
+            Integer port = pool.getPort();
+            Integer expectedI = 25;
+            assertEquals(expectedI, port);
+
+            Storage.StoragePoolType type = pool.getType();
+            assertEquals(Storage.StoragePoolType.Filesystem, type);
+
+            String str = pool.toString();
+            assertTrue(str.equals("Pool[" + id.toString() + "|" + host + ":"
+                    + port.toString() + "|" + path + "]"));
+        }
+
+        @Test
+        public void testGetNewSize() {
+            long newSize = rv.getNewSize();
+            assertTrue(newSize == 4194304L);
+        }
+
+        @Test
+        public void testGetCurrentSize() {
+            long currentSize = rv.getCurrentSize();
+            assertTrue(currentSize == 1048576L);
+        }
+
+        @Test
+        public void testGetShrinkOk() {
+            assertFalse(rv.getShrinkOk());
+        }
+
+        @Test
+        public void testGetInstanceName() {
+            String vmName = rv.getInstanceName();
+            assertTrue(vmName.equals("vmName"));
+        }
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java
index 56a1d22..3076d45 100644
--- a/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java
+++ b/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java
@@ -74,7 +74,7 @@ public class SnapshotCommandTest {
             return 0L;
         };
 
-        public long getAvailableBytes() {
+        public long getUsedBytes() {
             return 0L;
         };
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/core/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java b/core/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java
deleted file mode 100644
index 02085f5..0000000
--- a/core/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package src.com.cloud.agent.api.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.junit.Test;
-
-import com.cloud.agent.api.storage.ResizeVolumeCommand;
-import com.cloud.agent.api.to.StorageFilerTO;
-import com.cloud.storage.Storage.StoragePoolType;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.StoragePoolStatus;
-
-
-public class ResizeVolumeCommandTest {
-
-    public StoragePool dummypool = new StoragePool() {
-        @Override
-        public long getId() {
-            return 1L;
-        };
-
-        @Override
-        public String getName() {
-            return "name";
-        };
-
-        @Override
-        public String getUuid() {
-            return "bed9f83e-cac3-11e1-ac8a-0050568b007e";
-        };
-
-        @Override
-        public StoragePoolType getPoolType() {
-            return StoragePoolType.Filesystem;
-        };
-
-        @Override
-        public Date getCreated() {
-            Date date = null;
-            try {
-                date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
-                .parse("01/01/1970 12:12:12");
-            } catch (ParseException e) {
-                e.printStackTrace();
-            }
-            return date;
-        }
-
-        @Override
-        public Date getUpdateTime() {
-            return new Date();
-        };
-
-        @Override
-        public long getDataCenterId() {
-            return 0L;
-        };
-
-        @Override
-        public long getCapacityBytes() {
-            return 0L;
-        };
-
-        @Override
-        public long getAvailableBytes() {
-            return 0L;
-        };
-
-        @Override
-        public Long getClusterId() {
-            return 0L;
-        };
-
-        @Override
-        public String getHostAddress() {
-            return "hostAddress";
-        };
-
-        @Override
-        public String getPath() {
-            return "path";
-        };
-
-        @Override
-        public String getUserInfo() {
-            return "userInfo";
-        };
-
-        @Override
-        public boolean isShared() {
-            return false;
-        };
-
-        @Override
-        public boolean isLocal() {
-            return false;
-        };
-
-        @Override
-        public StoragePoolStatus getStatus() {
-            return StoragePoolStatus.Up;
-        };
-
-        @Override
-        public int getPort() {
-            return 25;
-        };
-
-        @Override
-        public Long getPodId() {
-            return 0L;
-        }
-
-        @Override
-        public String getStorageProviderName() {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public boolean isInMaintenance() {
-            // TODO Auto-generated method stub
-            return false;
-        };
-    };
-
-    Long newSize = 4194304L;
-    Long currentSize = 1048576L;
-
-    ResizeVolumeCommand rv = new ResizeVolumeCommand("dummydiskpath", 
-            new StorageFilerTO(dummypool), currentSize, newSize, false, 
-            "vmName");
-
-    @Test
-    public void testExecuteInSequence() {
-        boolean b = rv.executeInSequence();
-        assertFalse(b);
-    }
-
-    @Test
-    public void testGetPath() {
-        String path = rv.getPath();
-        assertTrue(path.equals("dummydiskpath"));
-    }
-
-    @Test
-    public void testGetPoolUuid() {
-        String poolUuid = rv.getPoolUuid();
-        assertTrue(poolUuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
-    }
-
-    @Test
-    public void testGetPool() {
-        StorageFilerTO pool = rv.getPool();
-
-        Long id = pool.getId();
-        Long expectedL = 1L;
-        assertEquals(expectedL, id);
-
-        String uuid = pool.getUuid();
-        assertTrue(uuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
-
-        String host = pool.getHost();
-        assertTrue(host.equals("hostAddress"));
-
-        String path = pool.getPath();
-        assertTrue(path.equals("path"));
-
-        String userInfo = pool.getUserInfo();
-        assertTrue(userInfo.equals("userInfo"));
-
-        Integer port = pool.getPort();
-        Integer expectedI = 25;
-        assertEquals(expectedI, port);
-
-        StoragePoolType type = pool.getType();
-        assertEquals(StoragePoolType.Filesystem, type);
-
-        String str = pool.toString();
-        assertTrue(str.equals("Pool[" + id.toString() + "|" + host + ":"
-                + port.toString() + "|" + path + "]"));
-    }
-
-    @Test
-    public void testGetNewSize() {
-        long newSize = rv.getNewSize();
-        assertTrue(newSize == 4194304L);
-    }
-
-    @Test
-    public void testGetCurrentSize() {
-        long currentSize = rv.getCurrentSize();
-        assertTrue(currentSize == 1048576L);
-    }
-
-    @Test
-    public void testGetShrinkOk() {
-        assertFalse(rv.getShrinkOk());
-    }
-
-    @Test
-    public void testGetInstanceName() {
-        String vmName = rv.getInstanceName();
-        assertTrue(vmName.equals("vmName"));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java
index 15e6d45..b0ed7d7 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java
@@ -27,6 +27,7 @@ public class ClusterScope extends AbstractScope {
     private Long zoneId;
 
     public ClusterScope(Long clusterId, Long podId, Long zoneId) {
+        super();
         this.clusterId = clusterId;
         this.podId = podId;
         this.zoneId = zoneId;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMigrationSubSystem.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMigrationSubSystem.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMigrationSubSystem.java
deleted file mode 100755
index ad81043..0000000
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMigrationSubSystem.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.engine.subsystem.api.storage;
-
-import java.net.URI;
-
-import com.cloud.org.Grouping;
-
-public interface DataMigrationSubSystem {
-
-    Class<? extends Grouping> getScopeCoverage();
-
-    void migrate(URI source, URI dest, String reservationId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java
index 5a124aa..5e10a0b 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java
@@ -26,9 +26,9 @@ import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.host.Host;
 
 public interface DataMotionService {
-    public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
+    void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
 
-    public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
+    void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
             AsyncCompletionCallback<CopyCommandResult> callback);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java
index 5bff21f..6deb6c1 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java
@@ -26,13 +26,13 @@ import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.host.Host;
 
 public interface DataMotionStrategy {
-    public boolean canHandle(DataObject srcData, DataObject destData);
+    boolean canHandle(DataObject srcData, DataObject destData);
 
-    public boolean canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
+    boolean canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
 
-    public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
+    Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
 
-    public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
+    Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
             AsyncCompletionCallback<CopyCommandResult> callback);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
index 0cd2111..c57b01c 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
@@ -23,24 +23,29 @@ import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.DataTO;
 
 public interface DataObject {
-    public long getId();
+    long getId();
 
-    public String getUri();
+    String getUri();
 
-    public DataTO getTO();
+    DataTO getTO();
 
-    public DataStore getDataStore();
+    DataStore getDataStore();
 
-    public Long getSize();
+    Long getSize();
 
-    public DataObjectType getType();
+    DataObjectType getType();
 
-    // public DiskFormat getFormat();
-    public String getUuid();
+    String getUuid();
 
     boolean delete();
 
-    public void processEvent(ObjectInDataStoreStateMachine.Event event);
+    void processEvent(ObjectInDataStoreStateMachine.Event event);
 
-    public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer);
+    void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer);
+
+    void incRefCount();
+
+    void decRefCount();
+
+    Long getRefCount();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/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 929774c..95bb9b9 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
@@ -21,13 +21,13 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 import com.cloud.utils.fsm.StateObject;
 
 public interface DataObjectInStore extends StateObject<ObjectInDataStoreStateMachine.State> {
-    public String getInstallPath();
+    String getInstallPath();
 
-    public void setInstallPath(String path);
+    void setInstallPath(String path);
 
-    public long getObjectId();
+    long getObjectId();
 
-    public long getDataStoreId();
+    long getDataStoreId();
 
-    public ObjectInDataStoreStateMachine.State getObjectInStoreState();
+    ObjectInDataStoreStateMachine.State getObjectInStoreState();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java
index 2143080..1cb6e15 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java
@@ -18,32 +18,23 @@
  */
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
-import java.util.Set;
-
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.command.CommandResult;
-
 import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.command.CommandResult;
 
 public interface DataStoreDriver {
-    public String grantAccess(DataObject data, EndPoint ep);
-
-    public boolean revokeAccess(DataObject data, EndPoint ep);
-
-    public Set<DataObject> listObjects(DataStore store);
-
-    public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
+    void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
 
-    public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback);
+    void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback);
 
-    public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
+    void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
 
-    public boolean canCopy(DataObject srcData, DataObject destData);
+    boolean canCopy(DataObject srcData, DataObject destData);
 
-    public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
+    void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
 
-    public DataTO getTO(DataObject data);
+    DataTO getTO(DataObject data);
 
-    public DataStoreTO getStoreTO(DataStore store);
+    DataStoreTO getStoreTO(DataStore store);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
index bd8c6e0..1e893db 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
@@ -24,21 +24,17 @@ import com.cloud.agent.api.StoragePoolInfo;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 
 public interface DataStoreLifeCycle {
-    public DataStore initialize(Map<String, Object> dsInfos);
+    DataStore initialize(Map<String, Object> dsInfos);
 
-    public boolean attachCluster(DataStore store, ClusterScope scope);
+    boolean attachCluster(DataStore store, ClusterScope scope);
 
-    public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo);
+    boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo);
 
     boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType);
 
-    public boolean dettach();
+    boolean maintain(DataStore store);
 
-    public boolean unmanaged();
+    boolean cancelMaintain(DataStore store);
 
-    public boolean maintain(DataStore store);
-
-    public boolean cancelMaintain(DataStore store);
-
-    public boolean deleteDataStore(DataStore store);
+    boolean deleteDataStore(DataStore store);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreManager.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreManager.java
index 8617eb4..949b037 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreManager.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreManager.java
@@ -24,21 +24,17 @@ import java.util.Map;
 import com.cloud.storage.DataStoreRole;
 
 public interface DataStoreManager {
-    public DataStore getDataStore(long storeId, DataStoreRole role);
+    DataStore getDataStore(long storeId, DataStoreRole role);
 
-    public DataStore getPrimaryDataStore(long storeId);
+    DataStore getPrimaryDataStore(long storeId);
 
-    public DataStore getDataStore(String uuid, DataStoreRole role);
+    DataStore getDataStore(String uuid, DataStoreRole role);
 
-    public List<DataStore> getImageStoresByScope(ZoneScope scope);
+    List<DataStore> getImageStoresByScope(ZoneScope scope);
 
-    public DataStore getImageStore(long zoneId);
+    DataStore getImageStore(long zoneId);
 
-    public List<DataStore> getImageStoresByProvider(String provider);
+    List<DataStore> getImageCacheStores(Scope scope);
 
-    public List<DataStore> getImageCacheStores(Scope scope);
-
-    public DataStore registerDataStore(Map<String, String> params, String providerUuid);
-
-    public List<DataStore> listImageStores();
+    List<DataStore> listImageStores();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java
index a13c60b..855f085 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java
@@ -23,27 +23,26 @@ import java.util.Set;
 
 public interface DataStoreProvider {
     // constants for provider names
-    public static final String NFS_IMAGE = "NFS";
-    public static final String S3_IMAGE = "S3";
-    public static final String SWIFT_IMAGE = "Swift";
-    public static final String SAMPLE_IMAGE = "Sample";
+    static final String NFS_IMAGE = "NFS";
+    static final String S3_IMAGE = "S3";
+    static final String SWIFT_IMAGE = "Swift";
+    static final String SAMPLE_IMAGE = "Sample";
 
-    public static final String DEFAULT_PRIMARY = "DefaultPrimary";
+    static final String DEFAULT_PRIMARY = "DefaultPrimary";
 
-    public static enum DataStoreProviderType {
+    static enum DataStoreProviderType {
         PRIMARY, IMAGE, ImageCache
     }
 
-    public DataStoreLifeCycle getDataStoreLifeCycle();
+    DataStoreLifeCycle getDataStoreLifeCycle();
 
-    public DataStoreDriver getDataStoreDriver();
+    DataStoreDriver getDataStoreDriver();
 
-    public HypervisorHostListener getHostListener();
+    HypervisorHostListener getHostListener();
 
-    public String getName();
+    String getName();
 
-    public boolean configure(Map<String, Object> params);
-
-    public Set<DataStoreProviderType> getTypes();
+    boolean configure(Map<String, Object> params);
 
+    Set<DataStoreProviderType> getTypes();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
index 84272ef..d25e10e 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
@@ -24,14 +24,11 @@ import com.cloud.storage.DataStoreProviderApiService;
 import com.cloud.utils.component.Manager;
 
 public interface DataStoreProviderManager extends Manager, DataStoreProviderApiService {
-    public DataStoreProvider getDataStoreProvider(String name);
+    DataStoreProvider getDataStoreProvider(String name);
 
-    public DataStoreProvider getDefaultPrimaryDataStoreProvider();
+    DataStoreProvider getDefaultPrimaryDataStoreProvider();
 
-    public DataStoreProvider getDefaultImageDataStoreProvider();
-
-    public DataStoreProvider getDefaultCacheDataStoreProvider();
-
-    public List<DataStoreProvider> getDataStoreProviders();
+    DataStoreProvider getDefaultImageDataStoreProvider();
 
+    DataStoreProvider getDefaultCacheDataStoreProvider();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java
index ed9c0eb..254c91d 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java
@@ -22,13 +22,13 @@ import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
 
 public interface EndPoint {
-    public long getId();
+    long getId();
 
-    public String getHostAddr();
+    String getHostAddr();
 
-    public String getPublicAddr();
+    String getPublicAddr();
 
-    public Answer sendMessage(Command cmd);
+    Answer sendMessage(Command cmd);
 
-    public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback);
+    void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPointSelector.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPointSelector.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPointSelector.java
index a51fad8..ca0cc2c 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPointSelector.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPointSelector.java
@@ -21,19 +21,11 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 import java.util.List;
 
 public interface EndPointSelector {
-    public EndPoint select(DataObject srcData, DataObject destData);
+    EndPoint select(DataObject srcData, DataObject destData);
 
-    /**
-     * @param object
-     * @return
-     */
     EndPoint select(DataObject object);
 
     EndPoint select(DataStore store);
 
-    /**
-     * @param store
-     * @return
-     */
     List<EndPoint> selectAll(DataStore store);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java
index ff33077..1ff3818 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java
@@ -25,6 +25,7 @@ public class HostScope extends AbstractScope {
     private Long zoneId;
 
     public HostScope(Long hostId, Long zoneId) {
+        super();
         this.hostId = hostId;
         this.zoneId = zoneId;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageStoreProvider.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageStoreProvider.java
index bde4fe4..0025ae1 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageStoreProvider.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageStoreProvider.java
@@ -22,7 +22,7 @@ import com.cloud.storage.ScopeType;
 
 public interface ImageStoreProvider extends DataStoreProvider {
 
-    public boolean isScopeSupported(ScopeType scope);
+    boolean isScopeSupported(ScopeType scope);
 
-    public boolean needDownloadSysTemplate();
+    boolean needDownloadSysTemplate();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java
index ee35557..2528a53 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java
@@ -22,7 +22,7 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.storage.command.CommandResult;
 
 public interface PrimaryDataStoreDriver extends DataStoreDriver {
-    public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
+    void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
 
-    public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);
+    void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
index c69cd3a..95a5cc9 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
@@ -25,15 +25,15 @@ import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StoragePool;
 
 public interface PrimaryDataStoreInfo extends StoragePool {
-    public boolean isHypervisorSupported(HypervisorType hypervisor);
+    boolean isHypervisorSupported(HypervisorType hypervisor);
 
-    public boolean isLocalStorageSupported();
+    boolean isLocalStorageSupported();
 
-    public boolean isVolumeDiskTypeSupported(DiskFormat diskType);
+    boolean isVolumeDiskTypeSupported(DiskFormat diskType);
 
-    public String getUuid();
+    String getUuid();
 
-    public StoragePoolType getPoolType();
+    StoragePoolType getPoolType();
 
-    public PrimaryDataStoreLifeCycle getLifeCycle();
+    PrimaryDataStoreLifeCycle getLifeCycle();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java
index 5c71f3c..8e43fa0 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java
@@ -21,9 +21,9 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 import com.cloud.storage.ScopeType;
 
 public interface Scope {
-    public ScopeType getScopeType();
+    ScopeType getScopeType();
 
-    public boolean isSameScope(Scope scope);
+    boolean isSameScope(Scope scope);
 
-    public Long getScopeId();
+    Long getScopeId();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotDataFactory.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotDataFactory.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotDataFactory.java
index 04b67d4..0b8d1f1 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotDataFactory.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotDataFactory.java
@@ -21,9 +21,9 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 import com.cloud.storage.DataStoreRole;
 
 public interface SnapshotDataFactory {
-    public SnapshotInfo getSnapshot(long snapshotId, DataStore store);
+    SnapshotInfo getSnapshot(long snapshotId, DataStore store);
 
-    public SnapshotInfo getSnapshot(DataObject obj, DataStore store);
+    SnapshotInfo getSnapshot(DataObject obj, DataStore store);
 
-    public SnapshotInfo getSnapshot(long snapshotId, DataStoreRole role);
+    SnapshotInfo getSnapshot(long snapshotId, DataStoreRole role);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
index 91e0fd7..8d6b760 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
@@ -19,15 +19,15 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 import com.cloud.storage.Snapshot;
 
 public interface SnapshotInfo extends DataObject, Snapshot {
-    public SnapshotInfo getParent();
+    SnapshotInfo getParent();
 
-    public String getPath();
+    String getPath();
 
-    public SnapshotInfo getChild();
+    SnapshotInfo getChild();
 
-    public VolumeInfo getBaseVolume();
+    VolumeInfo getBaseVolume();
 
-    public void addPayload(Object data);
+    void addPayload(Object data);
 
     Long getDataCenterId();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
index 67c8847..d594a07 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
@@ -18,11 +18,11 @@
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
 public interface SnapshotService {
-    public SnapshotResult takeSnapshot(SnapshotInfo snapshot);
+    SnapshotResult takeSnapshot(SnapshotInfo snapshot);
 
-    public SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
+    SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
 
-    public boolean deleteSnapshot(SnapshotInfo snapshot);
+    boolean deleteSnapshot(SnapshotInfo snapshot);
 
-    public boolean revertSnapshot(SnapshotInfo snapshot);
+    boolean revertSnapshot(SnapshotInfo snapshot);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java
index 542246a..86ae532 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java
@@ -19,15 +19,11 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 import com.cloud.storage.Snapshot;
 
 public interface SnapshotStrategy {
-    public SnapshotInfo takeSnapshot(SnapshotInfo snapshot);
+    SnapshotInfo takeSnapshot(SnapshotInfo snapshot);
 
-    public SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
+    SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
 
-    public boolean deleteSnapshot(Long snapshotId);
+    boolean deleteSnapshot(Long snapshotId);
 
-    /**
-     * @param snapshot
-     * @return
-     */
     boolean canHandle(Snapshot snapshot);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java
index fd5211f..92724c9 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java
@@ -19,9 +19,9 @@
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
 public interface StorageCacheManager {
-    public DataStore getCacheStorage(Scope scope);
+    DataStore getCacheStorage(Scope scope);
 
-    public DataObject createCacheObject(DataObject data, Scope scope);
+    DataObject createCacheObject(DataObject data, Scope scope);
 
     /**
      * only create cache object in db
@@ -33,4 +33,8 @@ public interface StorageCacheManager {
     DataObject getCacheObject(DataObject data, Scope scope);
 
     boolean deleteCacheObject(DataObject data);
+
+    boolean releaseCacheObject(DataObject data);
+
+    DataObject createCacheObject(DataObject data, DataStore store);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java
deleted file mode 100755
index d4455c8..0000000
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.engine.subsystem.api.storage;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
-import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
-import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
-
-import com.cloud.deploy.DeploymentPlan;
-
-public interface StorageOrchestrator {
-
-    /**
-     * Prepares all storage ready for a VM to start
-     * 
-     * @param vm
-     * @param reservationId
-     */
-    void prepare(long vmId, DeploymentPlan plan, String reservationId);
-
-    /**
-     * Releases all storage that were used for a VM shutdown
-     * 
-     * @param vm
-     * @param disks
-     * @param reservationId
-     */
-    void release(long vmId, String reservationId);
-
-    /**
-     * Destroy all disks
-     * 
-     * @param disks
-     * @param reservationId
-     */
-    void destroy(List<Long> disks, String reservationId);
-
-    /**
-     * Cancel a reservation
-     * 
-     * @param reservationId
-     *            reservation to
-     */
-    void cancel(String reservationId);
-
-    /**
-     * If attaching a volume in allocated state to a running vm, need to create
-     * this volume
-     */
-    void prepareAttachDiskToVM(long diskId, long vmId, String reservationId);
-
-    boolean createVolume(VolumeEntity volume, long dataStoreId, DiskFormat diskType);
-
-    boolean createVolumeFromTemplate(VolumeEntity volume, long dataStoreId, DiskFormat dis, TemplateEntity template);
-
-    VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
index 13eb0de..eccf0f4 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
@@ -47,5 +47,5 @@ public interface StoragePoolAllocator extends Adapter {
     List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile<? extends VirtualMachine> vmProfile,
             DeploymentPlan plan, ExcludeList avoid, int returnUpTo);
 
-    public static int RETURN_UPTO_ALL = -1;
+    static int RETURN_UPTO_ALL = -1;
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageSubSystem.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageSubSystem.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageSubSystem.java
deleted file mode 100644
index e5a74a4..0000000
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageSubSystem.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage;
-
-import java.net.URI;
-
-import com.cloud.org.Grouping;
-
-public interface StorageSubSystem {
-    String getType();
-
-    Class<? extends Grouping> getScope();
-
-    URI grantAccess(String vol, String reservationId);
-
-    URI RemoveAccess(String vol, String reservationId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java
index 91dba11..ceb5fc0 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java
@@ -21,7 +21,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 import com.cloud.template.VirtualMachineTemplate;
 
 public interface TemplateInfo extends DataObject, VirtualMachineTemplate {
-    public String getUniqueName();
+    String getUniqueName();
 
-    public String getInstallPath();
+    String getInstallPath();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateProfile.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateProfile.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateProfile.java
deleted file mode 100755
index dcfd407..0000000
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateProfile.java
+++ /dev/null
@@ -1,312 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage;
-
-import java.util.Map;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.template.VirtualMachineTemplate;
-
-public class TemplateProfile {
-    Long userId;
-    String name;
-    String displayText;
-    Integer bits;
-    Boolean passwordEnabled;
-    Boolean sshKeyEnbaled;
-    Boolean requiresHvm;
-    String url;
-    Boolean isPublic;
-    Boolean featured;
-    Boolean isExtractable;
-    ImageFormat format;
-    Long guestOsId;
-    Long zoneId;
-    HypervisorType hypervisorType;
-    String accountName;
-    Long domainId;
-    Long accountId;
-    String chksum;
-    Boolean bootable;
-    Long templateId;
-    VirtualMachineTemplate template;
-    String templateTag;
-    Map details;
-
-    public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits,
-            Boolean passwordEnabled, Boolean requiresHvm, String url, Boolean isPublic, Boolean featured,
-            Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId, HypervisorType hypervisorType,
-            String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details,
-            Boolean sshKeyEnabled) {
-        this.templateId = templateId;
-        this.userId = userId;
-        this.name = name;
-        this.displayText = displayText;
-        this.bits = bits;
-        this.passwordEnabled = passwordEnabled;
-        this.requiresHvm = requiresHvm;
-        this.url = url;
-        this.isPublic = isPublic;
-        this.featured = featured;
-        this.isExtractable = isExtractable;
-        this.format = format;
-        this.guestOsId = guestOsId;
-        this.zoneId = zoneId;
-        this.hypervisorType = hypervisorType;
-        this.accountName = accountName;
-        this.domainId = domainId;
-        this.accountId = accountId;
-        this.chksum = chksum;
-        this.bootable = bootable;
-        this.details = details;
-        this.sshKeyEnbaled = sshKeyEnabled;
-    }
-
-    public TemplateProfile(Long userId, VirtualMachineTemplate template, Long zoneId) {
-        this.userId = userId;
-        this.template = template;
-        this.zoneId = zoneId;
-    }
-
-    public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits,
-            Boolean passwordEnabled, Boolean requiresHvm, String url, Boolean isPublic, Boolean featured,
-            Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId, HypervisorType hypervisorType,
-            String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag,
-            Map details, Boolean sshKeyEnabled) {
-        this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured,
-                isExtractable, format, guestOsId, zoneId, hypervisorType, accountName, domainId, accountId, chksum,
-                bootable, details, sshKeyEnabled);
-        this.templateTag = templateTag;
-    }
-
-    public Long getTemplateId() {
-        return templateId;
-    }
-
-    public void setTemplateId(Long id) {
-        this.templateId = id;
-    }
-
-    public Long getUserId() {
-        return userId;
-    }
-
-    public void setUserId(Long userId) {
-        this.userId = userId;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getDisplayText() {
-        return displayText;
-    }
-
-    public void setDisplayText(String text) {
-        this.displayText = text;
-    }
-
-    public Integer getBits() {
-        return bits;
-    }
-
-    public void setBits(Integer bits) {
-        this.bits = bits;
-    }
-
-    public Boolean getPasswordEnabled() {
-        return passwordEnabled;
-    }
-
-    public void setPasswordEnabled(Boolean enabled) {
-        this.passwordEnabled = enabled;
-    }
-
-    public Boolean getRequiresHVM() {
-        return requiresHvm;
-    }
-
-    public void setRequiresHVM(Boolean hvm) {
-        this.requiresHvm = hvm;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public Boolean getIsPublic() {
-        return isPublic;
-    }
-
-    public void setIsPublic(Boolean is) {
-        this.isPublic = is;
-    }
-
-    public Boolean getFeatured() {
-        return featured;
-    }
-
-    public void setFeatured(Boolean featured) {
-        this.featured = featured;
-    }
-
-    public Boolean getIsExtractable() {
-        return isExtractable;
-    }
-
-    public void setIsExtractable(Boolean is) {
-        this.isExtractable = is;
-    }
-
-    public ImageFormat getFormat() {
-        return format;
-    }
-
-    public void setFormat(ImageFormat format) {
-        this.format = format;
-    }
-
-    public Long getGuestOsId() {
-        return guestOsId;
-    }
-
-    public void setGuestOsId(Long id) {
-        this.guestOsId = id;
-    }
-
-    public Long getZoneId() {
-        return zoneId;
-    }
-
-    public void setZoneId(Long id) {
-        this.zoneId = id;
-    }
-
-    public HypervisorType getHypervisorType() {
-        return hypervisorType;
-    }
-
-    public void setHypervisorType(HypervisorType type) {
-        this.hypervisorType = type;
-    }
-
-    public Long getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(Long id) {
-        this.domainId = id;
-    }
-
-    public Long getAccountId() {
-        return accountId;
-    }
-
-    public void setAccountId(Long id) {
-        this.accountId = id;
-    }
-
-    public String getCheckSum() {
-        return chksum;
-    }
-
-    public void setCheckSum(String chksum) {
-        this.chksum = chksum;
-    }
-
-    public Boolean getBootable() {
-        return this.bootable;
-    }
-
-    public void setBootable(Boolean bootable) {
-        this.bootable = bootable;
-    }
-
-    public VirtualMachineTemplate getTemplate() {
-        return template;
-    }
-
-    public void setTemplate(VirtualMachineTemplate template) {
-        this.template = template;
-    }
-
-    public String getTemplateTag() {
-        return templateTag;
-    }
-
-    public void setTemplateTag(String templateTag) {
-        this.templateTag = templateTag;
-    }
-
-    public Map getDetails() {
-        return this.details;
-    }
-
-    public void setDetails(Map details) {
-        this.details = details;
-    }
-
-    public void setSshKeyEnabled(Boolean enabled) {
-        this.sshKeyEnbaled = enabled;
-    }
-
-    public Boolean getSshKeyEnabled() {
-        return this.sshKeyEnbaled;
-    }
-
-    public String getImageStorageUri() {
-        return null;
-    }
-
-    public void setLocalPath(String path) {
-
-    }
-
-    public String getLocalPath() {
-        return null;
-    }
-
-    public String getJobId() {
-        return null;
-    }
-
-    public void setTemplatePoolRefId(long id) {
-
-    }
-
-    public long getId() {
-        return 0;
-    }
-
-    public long getTemplatePoolRefId() {
-        return 0;
-    }
-
-    public long getSize() {
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateService.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateService.java
index 52e18f1..085fbbd 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateService.java
@@ -27,7 +27,7 @@ import com.cloud.storage.StoragePool;
 
 public interface TemplateService {
 
-    public class TemplateApiResult extends CommandResult {
+    class TemplateApiResult extends CommandResult {
         private final TemplateInfo template;
 
         public TemplateApiResult(TemplateInfo template) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
index 463c0ff..3d7b1aa 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
@@ -23,21 +23,21 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.Volume;
 
 public interface VolumeInfo extends DataObject, Volume {
-    public boolean isAttachedVM();
+    boolean isAttachedVM();
 
-    public void addPayload(Object data);
+    void addPayload(Object data);
 
-    public Object getpayload();
+    Object getpayload();
 
-    public HypervisorType getHypervisorType();
+    HypervisorType getHypervisorType();
 
-    public Long getLastPoolId();
+    Long getLastPoolId();
 
-    public String getAttachedVmName();
+    String getAttachedVmName();
 
-    public void processEventOnly(ObjectInDataStoreStateMachine.Event event);
+    void processEventOnly(ObjectInDataStoreStateMachine.Event event);
 
-    public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer);
+    void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer);
 
-    public boolean stateTransit(Volume.Event event);
+    boolean stateTransit(Volume.Event event);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeProfile.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeProfile.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeProfile.java
deleted file mode 100644
index 8701912..0000000
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeProfile.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.engine.subsystem.api.storage;
-
-public class VolumeProfile {
-    private String _uri;
-
-    public String getURI() {
-        return _uri;
-    }
-
-    public String getPath() {
-        return null;
-    }
-
-    public long getSize() {
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java
index 3947952..f96ea40 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java
@@ -29,8 +29,7 @@ import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.host.Host;
 
 public interface VolumeService {
-
-    public class VolumeApiResult extends CommandResult {
+    class VolumeApiResult extends CommandResult {
         private final VolumeInfo volume;
 
         public VolumeApiResult(VolumeInfo volume) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java
index 9ba1d10..a0d75b5 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java
@@ -25,6 +25,7 @@ public class ZoneScope extends AbstractScope {
     private Long zoneId;
 
     public ZoneScope(Long zoneId) {
+        super();
         this.zoneId = zoneId;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
index a282a51..121a7ee 100644
--- a/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
+++ b/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
@@ -35,7 +35,6 @@ public final class CreateObjectCommand extends Command implements StorageSubSyst
 
     @Override
     public boolean executeInSequence() {
-        // TODO Auto-generated method stub
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
index 8d63a82..70e9bb3 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
@@ -25,13 +25,13 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import com.cloud.utils.db.GenericDao;
 
 public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> {
-    public ImageStoreVO findByName(String name);
+    ImageStoreVO findByName(String name);
 
-    public List<ImageStoreVO> findByProvider(String provider);
+    List<ImageStoreVO> findByProvider(String provider);
 
-    public List<ImageStoreVO> findByScope(ZoneScope scope);
+    List<ImageStoreVO> findByScope(ZoneScope scope);
 
-    public List<ImageStoreVO> findImageCacheByScope(ZoneScope scope);
+    List<ImageStoreVO> findImageCacheByScope(ZoneScope scope);
 
-    public List<ImageStoreVO> listImageStores();
+    List<ImageStoreVO> listImageStores();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
index 3c903ad..5ed48a3 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
@@ -80,6 +80,9 @@ public class ImageStoreVO implements ImageStore {
     @Column(name = "total_size")
     private Long totalSize;
 
+    @Column(name = "used_bytes")
+    private Long usedBytes;
+
     public DataStoreRole getRole() {
         return role;
     }
@@ -180,4 +183,11 @@ public class ImageStoreVO implements ImageStore {
         this.totalSize = totalSize;
     }
 
+    public Long getUsedBytes() {
+        return usedBytes;
+    }
+
+    public void setUsedBytes(Long usedBytes) {
+        this.usedBytes = usedBytes;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
index 0808287..8f7826f 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -147,7 +147,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
     @Override
     public void updateAvailable(long id, long available) {
         StoragePoolVO pool = createForUpdate(id);
-        pool.setAvailableBytes(available);
+        pool.setUsedBytes(available);
         update(id, pool);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/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 48d0db2..01f0220 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
@@ -28,13 +28,13 @@ import com.cloud.utils.fsm.StateDao;
 public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>,
         StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
 
-    public List<SnapshotDataStoreVO> listByStoreId(long id, DataStoreRole role);
+    List<SnapshotDataStoreVO> listByStoreId(long id, DataStoreRole role);
 
-    public void deletePrimaryRecordsForStore(long id);
+    void deletePrimaryRecordsForStore(long id);
 
-    public SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, long snapshotId);
+    SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, long snapshotId);
 
-    public SnapshotDataStoreVO findBySnapshot(long snapshotId, DataStoreRole role);
+    SnapshotDataStoreVO findBySnapshot(long snapshotId, DataStoreRole role);
 
-    public List<SnapshotDataStoreVO> listDestroyed(long storeId);
+    List<SnapshotDataStoreVO> listDestroyed(long storeId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/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 6ceb0d0..2ae3e8c 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
@@ -92,6 +92,9 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     @Enumerated(EnumType.STRING)
     ObjectInDataStoreStateMachine.State state;
 
+    @Column(name = "ref_cnt")
+    Long refCnt;
+
     public String getInstallPath() {
         return installPath;
     }
@@ -242,4 +245,16 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     public void setParentSnapshotId(long parentSnapshotId) {
         this.parentSnapshotId = parentSnapshotId;
     }
+
+    public Long getRefCnt() {
+        return refCnt;
+    }
+
+    public void incrRefCnt() {
+        this.refCnt++;
+    }
+
+    public void decrRefCnt() {
+        this.refCnt--;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
index a991924..9b8de67 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
@@ -71,8 +71,8 @@ public class StoragePoolVO implements StoragePool {
     @Column(name = "pod_id", updatable = true)
     private Long podId;
 
-    @Column(name = "available_bytes", updatable = true, nullable = true)
-    private long availableBytes;
+    @Column(name = "used_bytes", updatable = true, nullable = true)
+    private long usedBytes;
 
     @Column(name = "capacity_bytes", updatable = true, nullable = true)
     private long capacityBytes;
@@ -126,7 +126,7 @@ public class StoragePoolVO implements StoragePool {
         this.uuid = uuid;
         this.poolType = type;
         this.dataCenterId = dataCenterId;
-        this.availableBytes = availableBytes;
+        this.usedBytes = availableBytes;
         this.capacityBytes = capacityBytes;
         this.hostAddress = hostAddress;
         this.path = hostPath;
@@ -136,7 +136,7 @@ public class StoragePoolVO implements StoragePool {
     }
 
     public StoragePoolVO(StoragePoolVO that) {
-        this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.availableBytes,
+        this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.usedBytes,
                 that.capacityBytes, that.hostAddress, that.port, that.path);
     }
 
@@ -181,8 +181,8 @@ public class StoragePoolVO implements StoragePool {
         return dataCenterId;
     }
 
-    public long getAvailableBytes() {
-        return availableBytes;
+    public long getUsedBytes() {
+        return usedBytes;
     }
 
     public String getStorageProviderName() {
@@ -197,8 +197,8 @@ public class StoragePoolVO implements StoragePool {
         return capacityBytes;
     }
 
-    public void setAvailableBytes(long available) {
-        availableBytes = available;
+    public void setUsedBytes(long available) {
+        usedBytes = available;
     }
 
     public void setCapacityBytes(long capacity) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
index 79acd31..13b84ff 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
@@ -30,13 +30,13 @@ import com.cloud.utils.fsm.StateDao;
 public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>,
         StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
 
-    public List<TemplateDataStoreVO> listByStoreId(long id);
+    List<TemplateDataStoreVO> listByStoreId(long id);
 
-    public List<TemplateDataStoreVO> listDestroyed(long storeId);
+    List<TemplateDataStoreVO> listDestroyed(long storeId);
 
-    public void deletePrimaryRecordsForStore(long id);
+    void deletePrimaryRecordsForStore(long id);
 
-    public void deletePrimaryRecordsForTemplate(long templateId);
+    void deletePrimaryRecordsForTemplate(long templateId);
 
     List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId);
 


[2/3] clean up storage related code, and add lru replacement algorithm for cache storage

Posted by ed...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/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 2cee4d1..c6b434d 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
@@ -71,7 +71,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     private int downloadPercent;
 
     @Column(name = "size")
-    private long size;
+    private Long size;
 
     @Column(name = "physical_size")
     private long physicalSize;
@@ -112,11 +112,15 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     @Enumerated(EnumType.STRING)
     ObjectInDataStoreStateMachine.State state;
 
+    @Column(name = "ref_cnt")
+    Long refCnt;
+
     public TemplateDataStoreVO(Long hostId, long templateId) {
         super();
         this.dataStoreId = hostId;
         this.templateId = templateId;
         this.state = ObjectInDataStoreStateMachine.State.Allocated;
+        this.refCnt = 0L;
     }
 
     public TemplateDataStoreVO(Long hostId, long templateId, Date lastUpdated, int downloadPercent,
@@ -131,6 +135,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
         this.localDownloadPath = localDownloadPath;
         this.errorString = errorString;
         this.jobId = jobId;
+        this.refCnt = 0L;
         this.installPath = installPath;
         this.setDownloadUrl(downloadUrl);
         switch (downloadState) {
@@ -156,7 +161,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     }
 
     public TemplateDataStoreVO() {
-
+        this.refCnt = 0L;
     }
 
     @Override
@@ -352,4 +357,16 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
         this.dataStoreRole = dataStoreRole;
     }
 
+    public Long getRefCnt() {
+        return refCnt;
+    }
+
+    public void incrRefCnt() {
+        this.refCnt++;
+    }
+
+    public void decrRefCnt() {
+        this.refCnt--;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/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 7c89bbf..4152516 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
@@ -27,15 +27,15 @@ import com.cloud.utils.fsm.StateDao;
 public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
         StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
 
-    public List<VolumeDataStoreVO> listByStoreId(long id);
+    List<VolumeDataStoreVO> listByStoreId(long id);
 
-    public void deletePrimaryRecordsForStore(long id);
+    void deletePrimaryRecordsForStore(long id);
 
-    public VolumeDataStoreVO findByVolume(long volumeId);
+    VolumeDataStoreVO findByVolume(long volumeId);
 
-    public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId);
+    VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId);
 
-    public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock);
+    VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock);
 
-    public List<VolumeDataStoreVO> listDestroyed(long storeId);
+    List<VolumeDataStoreVO> listDestroyed(long storeId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/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 d2e5c25..222447f 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
@@ -111,6 +111,9 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
     @Enumerated(EnumType.STRING)
     ObjectInDataStoreStateMachine.State state;
 
+    @Column(name = "ref_cnt")
+    Long refCnt;
+
     public String getInstallPath() {
         return installPath;
     }
@@ -189,6 +192,7 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
         this.dataStoreId = hostId;
         this.volumeId = volumeId;
         this.state = ObjectInDataStoreStateMachine.State.Allocated;
+        this.refCnt = 0L;
     }
 
     public VolumeDataStoreVO(long hostId, long volumeId, Date lastUpdated, int downloadPercent, Status downloadState,
@@ -207,10 +211,11 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
         this.installPath = installPath;
         this.setDownloadUrl(downloadUrl);
         this.checksum = checksum;
+        this.refCnt = 0L;
     }
 
     public VolumeDataStoreVO() {
-
+        this.refCnt = 0L;
     }
 
     public void setLocalDownloadPath(String localPath) {
@@ -328,4 +333,16 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
         return this.state;
     }
 
+    public Long getRefCnt() {
+        return refCnt;
+    }
+
+    public void incrRefCnt() {
+        this.refCnt++;
+    }
+
+    public void decrRefCnt() {
+        this.refCnt--;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/image/datastore/ImageStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/image/datastore/ImageStoreInfo.java b/engine/api/src/org/apache/cloudstack/storage/image/datastore/ImageStoreInfo.java
index d51780d..7261a15 100644
--- a/engine/api/src/org/apache/cloudstack/storage/image/datastore/ImageStoreInfo.java
+++ b/engine/api/src/org/apache/cloudstack/storage/image/datastore/ImageStoreInfo.java
@@ -21,7 +21,7 @@ package org.apache.cloudstack.storage.image.datastore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 
 public interface ImageStoreInfo extends DataStore {
-    public long getImageStoreId();
+    long getImageStoreId();
 
-    public String getType();
+    String getType();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java b/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
index 45d0e98..0037ea5 100644
--- a/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
@@ -46,9 +46,6 @@ public class ImageStoreTO implements DataStoreTO {
         return this.uri;
     }
 
-    /**
-     * @return the providerName
-     */
     public String getProviderName() {
         return providerName;
     }
@@ -73,4 +70,10 @@ public class ImageStoreTO implements DataStoreTO {
     public DataStoreRole getRole() {
         return this.role;
     }
+
+    @Override
+    public String toString() {
+        return new StringBuilder("ImageStoreTO[type=").append(type).append("|provider=").append(providerName)
+                .append("|role=").append(role).append("|uri=").append(uri).append("]").toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java b/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
index 1b4c08f..5e870df 100644
--- a/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
@@ -94,4 +94,10 @@ public class PrimaryDataStoreTO implements DataStoreTO {
     public void setPort(int port) {
         this.port = port;
     }
+
+    @Override
+    public String toString() {
+        return new StringBuilder("PrimaryDataStoreTO[uuid=").append(uuid).append("|name=").append(name)
+                .append("|id=").append(id).append("|pooltype=").append(poolType).append("]").toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
index fcaa320..1115aec 100644
--- a/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
@@ -117,4 +117,10 @@ public class SnapshotObjectTO implements DataTO {
     public void setHypervisorType(HypervisorType hypervisorType) {
         this.hypervisorType = hypervisorType;
     }
+
+    @Override
+    public String toString() {
+        return new StringBuilder("SnapshotTO[datastore=").append(dataStore).append("|volume=").append(volume).append("|path")
+                .append(path).append("]").toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
index b3dc189..abe59eb 100644
--- a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
@@ -190,4 +190,10 @@ public class TemplateObjectTO implements DataTO {
     public void setSize(Long size) {
         this.size = size;
     }
+
+    @Override
+    public String toString() {
+        return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl)
+                .append("|name").append(name).append("]").toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
index 6057a74..bc1c061 100644
--- a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
@@ -166,4 +166,10 @@ public class VolumeObjectTO implements DataTO {
         this.format = format;
     }
 
+    @Override
+    public String toString() {
+        return new StringBuilder("volumeTO[uuid=").append(uuid).append("|path=").append(path)
+                .append("|datastore=").append(dataStore).append("]").toString();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
index cb5ea10..4b4e521 100644
--- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
+++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
@@ -18,32 +18,32 @@
  */
 package org.apache.cloudstack.storage.cache.manager;
 
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
-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.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import com.cloud.configuration.Config;
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.component.Manager;
+import com.cloud.utils.concurrency.NamedThreadFactory;
+import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria2;
+import com.cloud.utils.db.SearchCriteriaService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.engine.subsystem.api.storage.*;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
-import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
-import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
-import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.framework.async.AsyncRpcConext;
 import org.apache.cloudstack.storage.cache.allocator.StorageCacheAllocator;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
+import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
 import org.apache.log4j.Logger;
 
-import com.cloud.utils.component.Manager;
-import com.cloud.utils.exception.CloudRuntimeException;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.util.*;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 
 public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
     private static final Logger s_logger = Logger.getLogger(StorageCacheManagerImpl.class);
@@ -53,6 +53,16 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
     DataMotionService dataMotionSvr;
     @Inject
     ObjectInDataStoreManager objectInStoreMgr;
+    @Inject
+    DataStoreManager dataStoreManager;
+    @Inject
+    StorageCacheReplacementAlgorithm cacheReplacementAlgorithm;
+    @Inject
+    ConfigurationDao configDao;
+    Boolean cacheReplacementEnabled = Boolean.TRUE;
+    int workers;
+    ScheduledExecutorService executors;
+    int cacheReplaceMentInterval;
 
     @Override
     public DataStore getCacheStorage(Scope scope) {
@@ -65,6 +75,17 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
         return null;
     }
 
+    protected List<DataStore> getCacheStores() {
+        SearchCriteriaService<ImageStoreVO, ImageStoreVO> sc = SearchCriteria2.create(ImageStoreVO.class);
+        sc.addAnd(sc.getEntity().getRole(), SearchCriteria.Op.EQ, DataStoreRole.ImageCache);
+        List<ImageStoreVO> imageStoreVOs = sc.list();
+        List<DataStore> stores = new ArrayList<DataStore>();
+        for (ImageStoreVO vo : imageStoreVOs) {
+            stores.add(dataStoreManager.getDataStore(vo.getId(), vo.getRole()));
+        }
+        return stores;
+    }
+
     @Override
     public String getName() {
         // TODO Auto-generated method stub
@@ -103,12 +124,59 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
 
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
-        // TODO Auto-generated method stub
+        cacheReplacementEnabled = Boolean.parseBoolean(configDao.getValue(Config.StorageCacheReplacementEnabled.key()));
+        cacheReplaceMentInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementInterval.key()), 86400);
+        workers = NumbersUtil.parseInt(configDao.getValue(Config.ExpungeWorkers.key()), 10);
+        executors = Executors.newScheduledThreadPool(workers, new NamedThreadFactory("StorageCacheManager-cache-replacement"));
         return true;
     }
 
+    protected class CacheReplacementRunner implements Runnable {
+
+        @Override
+        public void run() {
+            GlobalLock replacementLock = null;
+            try {
+                replacementLock = GlobalLock.getInternLock("storageCacheMgr.replacement");
+                if (replacementLock.lock(3)) {
+                    List<DataStore> stores = getCacheStores();
+                    Collections.shuffle(stores);
+                    DataObject object = null;
+                    DataStore findAStore = null;
+                    for (DataStore store : stores) {
+                        object = cacheReplacementAlgorithm.chooseOneToBeReplaced(store);
+                        findAStore = store;
+                        if (object != null) {
+                              break;
+                        }
+                    }
+
+                    if (object == null) {
+                        return;
+                    }
+
+                    while(object != null) {
+                        object.delete();
+                        object = cacheReplacementAlgorithm.chooseOneToBeReplaced(findAStore);
+                    }
+                }
+            } catch (Exception e) {
+                s_logger.debug("Failed to execute CacheReplacementRunner: " + e.toString());
+            } finally {
+                if (replacementLock != null) {
+                    replacementLock.unlock();
+                }
+            }
+        }
+    }
+
     @Override
     public boolean start() {
+        if (cacheReplacementEnabled) {
+            Random generator = new Random();
+            int initalDelay = generator.nextInt(cacheReplaceMentInterval);
+            executors.scheduleWithFixedDelay(new CacheReplacementRunner(), initalDelay, cacheReplaceMentInterval, TimeUnit.SECONDS);
+        }
         return true;
     }
 
@@ -118,29 +186,17 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
         return true;
     }
 
-    private class CreateCacheObjectContext<T> extends AsyncRpcConext<T> {
-        final AsyncCallFuture<CopyCommandResult> future;
-
-        /**
-         * @param callback
-         */
-        public CreateCacheObjectContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<CopyCommandResult> future) {
-            super(callback);
-            this.future = future;
-        }
-
-    }
-
     @Override
-    public DataObject createCacheObject(DataObject data, Scope scope) {
-        DataStore cacheStore = this.getCacheStorage(scope);
-        DataObjectInStore obj = objectInStoreMgr.findObject(data, cacheStore);
+    public DataObject createCacheObject(DataObject data, DataStore store) {
+        DataObjectInStore obj = objectInStoreMgr.findObject(data, store);
         if (obj != null && obj.getState() == ObjectInDataStoreStateMachine.State.Ready) {
             s_logger.debug("there is already one in the cache store");
-            return objectInStoreMgr.get(data, cacheStore);
+            DataObject dataObj = objectInStoreMgr.get(data, store);
+            dataObj.incRefCount();
+            return dataObj;
         }
 
-        DataObject objOnCacheStore = cacheStore.create(data);
+        DataObject objOnCacheStore = store.create(data);
 
         AsyncCallFuture<CopyCommandResult> future = new AsyncCallFuture<CopyCommandResult>();
         CopyCommandResult result = null;
@@ -154,6 +210,7 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
                 objOnCacheStore.processEvent(Event.OperationFailed);
             } else {
                 objOnCacheStore.processEvent(Event.OperationSuccessed, result.getAnswer());
+                objOnCacheStore.incRefCount();
                 return objOnCacheStore;
             }
         } catch (InterruptedException e) {
@@ -167,28 +224,31 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
                 objOnCacheStore.processEvent(Event.OperationFailed);
             }
         }
-
         return null;
     }
 
     @Override
+    public DataObject createCacheObject(DataObject data, Scope scope) {
+        DataStore cacheStore = this.getCacheStorage(scope);
+        return this.createCacheObject(data, cacheStore);
+    }
+
+    @Override
     public DataObject getCacheObject(DataObject data, Scope scope) {
         DataStore cacheStore = this.getCacheStorage(scope);
         DataObject objOnCacheStore = cacheStore.create(data);
-
+        objOnCacheStore.incRefCount();
         return objOnCacheStore;
     }
 
-    protected Void createCacheObjectCallBack(
-            AsyncCallbackDispatcher<StorageCacheManagerImpl, CopyCommandResult> callback,
-            CreateCacheObjectContext<CopyCommandResult> context) {
-        AsyncCallFuture<CopyCommandResult> future = context.future;
-        future.complete(callback.getResult());
-        return null;
+    @Override
+    public boolean releaseCacheObject(DataObject data) {
+        data.decRefCount();
+        return true;
     }
 
     @Override
     public boolean deleteCacheObject(DataObject data) {
-        return objectInStoreMgr.delete(data);
+        return data.getDataStore().delete(data);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithm.java
----------------------------------------------------------------------
diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithm.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithm.java
new file mode 100644
index 0000000..f7a23fe
--- /dev/null
+++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithm.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.cache.manager;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+
+public interface StorageCacheReplacementAlgorithm {
+    DataObject chooseOneToBeReplaced(DataStore store);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java
----------------------------------------------------------------------
diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java
new file mode 100644
index 0000000..440bf53
--- /dev/null
+++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.cache.manager;
+import com.cloud.configuration.Config;
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria2;
+import com.cloud.utils.db.SearchCriteriaService;
+import org.apache.cloudstack.engine.subsystem.api.storage.*;
+import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
+import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
+import org.apache.commons.lang.math.NumberUtils;
+
+import java.util.Calendar;
+import java.util.Date;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+
+
+public class StorageCacheReplacementAlgorithmLRU implements StorageCacheReplacementAlgorithm {
+    @Inject
+    ConfigurationDao configDao;
+    @Inject
+    TemplateDataFactory templateFactory;
+    @Inject
+    VolumeDataFactory volumeFactory;
+    @Inject
+    SnapshotDataFactory snapshotFactory;
+
+    Integer unusedTimeInterval;
+
+    public StorageCacheReplacementAlgorithmLRU() {
+
+    }
+
+    @PostConstruct
+    public void initialize() {
+        unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30);
+    }
+
+    public void setUnusedTimeInterval(Integer interval) {
+        unusedTimeInterval = interval;
+    }
+
+    @Override
+    public DataObject chooseOneToBeReplaced(DataStore store) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(DateUtil.now());
+        cal.add(Calendar.DAY_OF_MONTH, -unusedTimeInterval.intValue());
+        Date bef = cal.getTime();
+
+        SearchCriteriaService<TemplateDataStoreVO, TemplateDataStoreVO> sc = SearchCriteria2.create(TemplateDataStoreVO.class);
+        sc.addAnd(sc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
+        sc.addAnd(sc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
+        sc.addAnd(sc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
+        sc.addAnd(sc.getEntity().getDataStoreRole(), SearchCriteria.Op.EQ, store.getRole());
+        sc.addAnd(sc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
+        TemplateDataStoreVO template = sc.find();
+        if (template != null) {
+            return templateFactory.getTemplate(template.getTemplateId(), store);
+        }
+
+        SearchCriteriaService<VolumeDataStoreVO, VolumeDataStoreVO> volSc = SearchCriteria2.create(VolumeDataStoreVO.class);
+        volSc.addAnd(volSc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
+        volSc.addAnd(volSc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
+        volSc.addAnd(volSc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
+        volSc.addAnd(volSc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
+        VolumeDataStoreVO volume = volSc.find();
+        if (volume != null) {
+            return volumeFactory.getVolume(volume.getVolumeId(), store);
+        }
+
+        SearchCriteriaService<SnapshotDataStoreVO, SnapshotDataStoreVO> snapshotSc = SearchCriteria2.create(SnapshotDataStoreVO.class);
+        snapshotSc.addAnd(snapshotSc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
+        snapshotSc.addAnd(snapshotSc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
+        snapshotSc.addAnd(snapshotSc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
+        snapshotSc.addAnd(snapshotSc.getEntity().getRole(), SearchCriteria.Op.EQ, store.getRole());
+        snapshotSc.addAnd(snapshotSc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
+        SnapshotDataStoreVO snapshot = snapshotSc.find();
+        if (snapshot != null) {
+            return snapshotFactory.getSnapshot(snapshot.getSnapshotId(), store);
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index a01d2d3..631de6a 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -172,10 +172,11 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
                 EndPoint ep = selector.select(srcData, destData);
                 answer = ep.sendMessage(cmd);
             }
-            // clean up cache entry in case of failure
-            if (answer == null || !answer.getResult()) {
-                if (cacheData != null) {
+            if (cacheData != null) {
+                if (answer == null || !answer.getResult()) {
                     cacheMgr.deleteCacheObject(cacheData);
+                } else {
+                    cacheMgr.releaseCacheObject(cacheData);
                 }
             }
             return answer;
@@ -191,8 +192,9 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
 
     protected DataObject cacheSnapshotChain(SnapshotInfo snapshot) {
         DataObject leafData = null;
+        DataStore store = cacheMgr.getCacheStorage(snapshot.getDataStore().getScope());
         while (snapshot != null) {
-            DataObject cacheData = cacheMgr.createCacheObject(snapshot, snapshot.getDataStore().getScope());
+            DataObject cacheData = cacheMgr.createCacheObject(snapshot, store);
             if (leafData == null) {
                 leafData = cacheData;
             }
@@ -202,7 +204,10 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
     }
 
     protected void deleteSnapshotCacheChain(SnapshotInfo snapshot) {
-
+       while (snapshot != null) {
+           cacheMgr.deleteCacheObject(snapshot);
+           snapshot = snapshot.getParent();
+       }
     }
 
     protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionDriver.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionDriver.java
deleted file mode 100644
index 3a59b21..0000000
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionDriver.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.motion;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-
-public interface DataMotionDriver {
-    public void copy(DataObject srcObj, DataObject destObj);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageOrchestrator.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageOrchestrator.java
deleted file mode 100644
index e4141f3..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageOrchestrator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.image;
-
-public interface ImageOrchestrator {
-    void registerTemplate(long templateId);
-
-    void registerSnapshot(long snapshotId);
-
-    void registerVolume(long volumeId);
-
-    void registerIso(long isoId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
index c06756e..96c35f3 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
@@ -576,8 +576,6 @@ public class TemplateServiceImpl implements TemplateService {
             if (result.isFailed()) {
                 res.setResult(result.getResult());
                 destTemplate.processEvent(Event.OperationFailed);
-                // remove entry from template_store_ref
-                destTemplate.getDataStore().delete(destTemplate);
             } else {
                 destTemplate.processEvent(Event.OperationSuccessed, result.getAnswer());
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/image/src/org/apache/cloudstack/storage/image/downloader/ImageDownloader.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/downloader/ImageDownloader.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/downloader/ImageDownloader.java
deleted file mode 100644
index af572d4..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/downloader/ImageDownloader.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.image.downloader;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
-
-public interface ImageDownloader {
-    public void downloadImage(TemplateInfo template);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java
index 73c960f..64ef78f 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java
@@ -66,7 +66,6 @@ public class ImageStoreProviderManagerImpl implements ImageStoreProviderManager
         ImageStoreProvider provider = (ImageStoreProvider) providerManager.getDataStoreProvider(providerName);
         ImageStoreEntity imgStore = ImageStoreImpl
                 .getDataStore(dataStore, driverMaps.get(provider.getName()), provider);
-        // TODO Auto-generated method stub
         return imgStore;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageStoreImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageStoreImpl.java
index a3da304..6d8e8e5 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageStoreImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageStoreImpl.java
@@ -24,6 +24,7 @@ import java.util.concurrent.ExecutionException;
 
 import javax.inject.Inject;
 
+import com.cloud.capacity.dao.CapacityDao;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
 import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
@@ -52,10 +53,11 @@ public class ImageStoreImpl implements ImageStoreEntity {
     VMTemplateDao imageDao;
     @Inject
     private ObjectInDataStoreManager objectInStoreMgr;
+    @Inject
+    private CapacityDao capacityDao;
     protected ImageStoreDriver driver;
     protected ImageStoreVO imageDataStoreVO;
     protected ImageStoreProvider provider;
-    boolean needDownloadToCacheStorage = false;
 
     public ImageStoreImpl() {
         super();
@@ -77,13 +79,11 @@ public class ImageStoreImpl implements ImageStoreEntity {
 
     @Override
     public Set<TemplateInfo> listTemplates() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public DataStoreDriver getDriver() {
-        // TODO Auto-generated method stub
         return this.driver;
     }
 
@@ -94,7 +94,6 @@ public class ImageStoreImpl implements ImageStoreEntity {
 
     @Override
     public long getId() {
-        // TODO Auto-generated method stub
         return this.imageDataStoreVO.getId();
     }
 
@@ -110,19 +109,16 @@ public class ImageStoreImpl implements ImageStoreEntity {
 
     @Override
     public TemplateInfo getTemplate(long templateId) {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public VolumeInfo getVolume(long volumeId) {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public SnapshotInfo getSnapshot(long snapshotId) {
-        // TODO Auto-generated method stub
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
index 72a8849..5ab52de 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -259,6 +259,48 @@ public class TemplateObject implements TemplateInfo {
     }
 
     @Override
+    public void incRefCount() {
+        if (this.dataStore == null) {
+            return;
+        }
+
+        if (this.dataStore.getRole() == DataStoreRole.Image ||
+                this.dataStore.getRole() == DataStoreRole.ImageCache) {
+            TemplateDataStoreVO store = templateStoreDao.findById(this.dataStore.getId());
+            store.incrRefCnt();
+            store.setLastUpdated(new Date());
+            templateStoreDao.update(store.getId(), store);
+        }
+    }
+
+    @Override
+    public void decRefCount() {
+        if (this.dataStore == null) {
+            return;
+        }
+        if (this.dataStore.getRole() == DataStoreRole.Image ||
+                this.dataStore.getRole() == DataStoreRole.ImageCache) {
+            TemplateDataStoreVO store = templateStoreDao.findById(this.dataStore.getId());
+            store.decrRefCnt();
+            store.setLastUpdated(new Date());
+            templateStoreDao.update(store.getId(), store);
+        }
+    }
+
+    @Override
+    public Long getRefCount() {
+        if (this.dataStore == null) {
+            return null;
+        }
+        if (this.dataStore.getRole() == DataStoreRole.Image ||
+                this.dataStore.getRole() == DataStoreRole.ImageCache) {
+            TemplateDataStoreVO store = templateStoreDao.findById(this.dataStore.getId());
+            return store.getRefCnt();
+        }
+        return null;
+    }
+
+    @Override
     public DataTO getTO() {
         DataTO to = null;
         if (this.dataStore == null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
index 3d300de..40d9d41 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
@@ -128,7 +128,7 @@ public class StorageAllocatorTest {
         storage.setClusterId(clusterId);
         storage.setStatus(StoragePoolStatus.Up);
         storage.setScope(ScopeType.CLUSTER);
-        storage.setAvailableBytes(1000);
+        storage.setUsedBytes(1000);
         storage.setCapacityBytes(20000);
         storage.setHostAddress(UUID.randomUUID().toString());
         storage.setPath(UUID.randomUUID().toString());
@@ -170,7 +170,7 @@ public class StorageAllocatorTest {
             storage.setClusterId(clusterId);
             storage.setStatus(StoragePoolStatus.Up);
             storage.setScope(ScopeType.CLUSTER);
-            storage.setAvailableBytes(1000);
+            storage.setUsedBytes(1000);
             storage.setCapacityBytes(20000);
             storage.setHostAddress(UUID.randomUUID().toString());
             storage.setPath(UUID.randomUUID().toString());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/integration-test/test/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRUTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRUTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRUTest.java
new file mode 100644
index 0000000..7d40ea7
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRUTest.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.cache.manager;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.Storage;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.component.ComponentContext;
+import junit.framework.Assert;
+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.DataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
+import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = "classpath:/storageContext.xml")
+public class StorageCacheReplacementAlgorithmLRUTest {
+    @Inject
+    VMTemplateDao templateDao;
+    @Inject
+    ImageStoreDao imageStoreDao;
+    @Inject
+    TemplateDataStoreDao templateDataStoreDao;
+    @Inject
+    StorageCacheReplacementAlgorithmLRU cacheReplacementAlgorithm;
+    @Inject
+    DataStoreManager dataStoreManager;
+    @Before
+    public void setup() throws Exception {
+        ComponentContext.initComponentsLifeCycle();
+    }
+    @Test
+    public void testSelectObject() {
+        cacheReplacementAlgorithm.setUnusedTimeInterval(1);
+        try {
+            VMTemplateVO template = new VMTemplateVO();
+            template.setTemplateType(Storage.TemplateType.USER);
+            template.setUrl(UUID.randomUUID().toString());
+            template.setUniqueName(UUID.randomUUID().toString());
+            template.setName(UUID.randomUUID().toString());
+            template.setPublicTemplate(true);
+            template.setFeatured(true);
+            template.setRequiresHvm(true);
+            template.setBits(64);
+            template.setFormat(Storage.ImageFormat.VHD);
+            template.setEnablePassword(true);
+            template.setEnableSshKey(true);
+            template.setGuestOSId(1);
+            template.setBootable(true);
+            template.setPrepopulate(true);
+            template.setCrossZones(true);
+            template.setExtractable(true);
+            template = templateDao.persist(template);
+
+            VMTemplateVO template2 = new VMTemplateVO();
+            template2.setTemplateType(Storage.TemplateType.USER);
+            template2.setUrl(UUID.randomUUID().toString());
+            template2.setUniqueName(UUID.randomUUID().toString());
+            template2.setName(UUID.randomUUID().toString());
+            template2.setPublicTemplate(true);
+            template2.setFeatured(true);
+            template2.setRequiresHvm(true);
+            template2.setBits(64);
+            template2.setFormat(Storage.ImageFormat.VHD);
+            template2.setEnablePassword(true);
+            template2.setEnableSshKey(true);
+            template2.setGuestOSId(1);
+            template2.setBootable(true);
+            template2.setPrepopulate(true);
+            template2.setCrossZones(true);
+            template2.setExtractable(true);
+            template2 = templateDao.persist(template2);
+
+            ImageStoreVO imageStoreVO = new ImageStoreVO();
+            imageStoreVO.setRole(DataStoreRole.ImageCache);
+            imageStoreVO.setName(UUID.randomUUID().toString());
+            imageStoreVO.setProviderName(DataStoreProvider.NFS_IMAGE);
+            imageStoreVO.setProtocol("nfs");
+            imageStoreVO.setUrl(UUID.randomUUID().toString());
+            imageStoreVO = imageStoreDao.persist(imageStoreVO);
+
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(DateUtil.now());
+            cal.add(Calendar.DAY_OF_MONTH, -2);
+            Date date = cal.getTime();
+
+            TemplateDataStoreVO templateStoreVO1 = new TemplateDataStoreVO();
+            templateStoreVO1.setLastUpdated(date);
+            templateStoreVO1.setDataStoreRole(DataStoreRole.ImageCache);
+            templateStoreVO1.setDataStoreId(imageStoreVO.getId());
+            templateStoreVO1.setState(ObjectInDataStoreStateMachine.State.Ready);
+            templateStoreVO1.setCopy(true);
+            templateStoreVO1.setTemplateId(template.getId());
+            templateDataStoreDao.persist(templateStoreVO1);
+
+            TemplateDataStoreVO templateStoreVO2 = new TemplateDataStoreVO();
+            templateStoreVO2.setLastUpdated(date);
+            templateStoreVO2.setDataStoreRole(DataStoreRole.ImageCache);
+            templateStoreVO2.setDataStoreId(imageStoreVO.getId());
+            templateStoreVO2.setState(ObjectInDataStoreStateMachine.State.Ready);
+            templateStoreVO2.setCopy(true);
+            templateStoreVO2.setTemplateId(template2.getId());
+            templateDataStoreDao.persist(templateStoreVO2);
+
+            DataStore store = dataStoreManager.getDataStore(imageStoreVO.getId(), DataStoreRole.ImageCache);
+            Assert.assertNotNull(cacheReplacementAlgorithm.chooseOneToBeReplaced(store));
+
+        } catch (Exception e) {
+           Assert.fail();
+        }
+    }
+
+
+    @Test
+    public void testSelectObjectFailed() {
+        cacheReplacementAlgorithm.setUnusedTimeInterval(1);
+        try {
+            VMTemplateVO template = new VMTemplateVO();
+            template.setTemplateType(Storage.TemplateType.USER);
+            template.setUrl(UUID.randomUUID().toString());
+            template.setUniqueName(UUID.randomUUID().toString());
+            template.setName(UUID.randomUUID().toString());
+            template.setPublicTemplate(true);
+            template.setFeatured(true);
+            template.setRequiresHvm(true);
+            template.setBits(64);
+            template.setFormat(Storage.ImageFormat.VHD);
+            template.setEnablePassword(true);
+            template.setEnableSshKey(true);
+            template.setGuestOSId(1);
+            template.setBootable(true);
+            template.setPrepopulate(true);
+            template.setCrossZones(true);
+            template.setExtractable(true);
+            template = templateDao.persist(template);
+
+            VMTemplateVO template2 = new VMTemplateVO();
+            template2.setTemplateType(Storage.TemplateType.USER);
+            template2.setUrl(UUID.randomUUID().toString());
+            template2.setUniqueName(UUID.randomUUID().toString());
+            template2.setName(UUID.randomUUID().toString());
+            template2.setPublicTemplate(true);
+            template2.setFeatured(true);
+            template2.setRequiresHvm(true);
+            template2.setBits(64);
+            template2.setFormat(Storage.ImageFormat.VHD);
+            template2.setEnablePassword(true);
+            template2.setEnableSshKey(true);
+            template2.setGuestOSId(1);
+            template2.setBootable(true);
+            template2.setPrepopulate(true);
+            template2.setCrossZones(true);
+            template2.setExtractable(true);
+            template2 = templateDao.persist(template2);
+
+            ImageStoreVO imageStoreVO = new ImageStoreVO();
+            imageStoreVO.setRole(DataStoreRole.ImageCache);
+            imageStoreVO.setName(UUID.randomUUID().toString());
+            imageStoreVO.setProviderName(DataStoreProvider.NFS_IMAGE);
+            imageStoreVO.setProtocol("nfs");
+            imageStoreVO.setUrl(UUID.randomUUID().toString());
+            imageStoreVO = imageStoreDao.persist(imageStoreVO);
+
+
+            Date date = DateUtil.now();
+
+            TemplateDataStoreVO templateStoreVO1 = new TemplateDataStoreVO();
+            templateStoreVO1.setLastUpdated(date);
+            templateStoreVO1.setDataStoreRole(DataStoreRole.ImageCache);
+            templateStoreVO1.setDataStoreId(imageStoreVO.getId());
+            templateStoreVO1.setState(ObjectInDataStoreStateMachine.State.Ready);
+            templateStoreVO1.setCopy(true);
+            templateStoreVO1.setTemplateId(template.getId());
+            templateDataStoreDao.persist(templateStoreVO1);
+
+            TemplateDataStoreVO templateStoreVO2 = new TemplateDataStoreVO();
+            templateStoreVO2.setLastUpdated(date);
+            templateStoreVO2.setDataStoreRole(DataStoreRole.ImageCache);
+            templateStoreVO2.setDataStoreId(imageStoreVO.getId());
+            templateStoreVO2.setState(ObjectInDataStoreStateMachine.State.Ready);
+            templateStoreVO2.setCopy(true);
+            templateStoreVO2.setTemplateId(template2.getId());
+            templateDataStoreDao.persist(templateStoreVO2);
+
+            DataStore store = dataStoreManager.getDataStore(imageStoreVO.getId(), DataStoreRole.ImageCache);
+            Assert.assertNull(cacheReplacementAlgorithm.chooseOneToBeReplaced(store));
+
+        } catch (Exception e) {
+            Assert.fail();
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java
index 8210dfe..2579a38 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java
@@ -26,6 +26,8 @@ import java.util.concurrent.ExecutionException;
 
 import javax.inject.Inject;
 
+import junit.framework.Assert;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@@ -43,6 +45,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
 import org.apache.cloudstack.storage.LocalHostEndpoint;
@@ -351,7 +354,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
         return volume;
     }
 
-    public VolumeInfo createCopyBaseImage() {
+    public VolumeInfo createCopyBaseImage() throws InterruptedException, ExecutionException {
         DataStore primaryStore = createPrimaryDataStore();
         primaryStoreId = primaryStore.getId();
         primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
@@ -361,45 +364,13 @@ public class SnapshotTest extends CloudStackTestNGBase {
                 this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
 
         VolumeApiResult result;
-        try {
-            result = future.get();
-            return result.getVolume();
-        } catch (InterruptedException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (ExecutionException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        return null;
+        result = future.get();
+        Assert.assertTrue(result.isSuccess());
+        return result.getVolume();
+        
     }
 
-    @Test
-    public void createSnapshot() {
-        VolumeInfo vol = createCopyBaseImage();
-        SnapshotVO snapshotVO = createSnapshotInDb(vol);
-        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
-        SnapshotInfo newSnapshot = null;
-        for (SnapshotStrategy strategy : this.snapshotStrategies) {
-            if (strategy.canHandle(snapshot)) {
-                newSnapshot = strategy.takeSnapshot(snapshot);
-            }
-        }
-        AssertJUnit.assertNotNull(newSnapshot);
-
-        LocalHostEndpoint ep = new MockLocalHostEndPoint();
-        ep.setResource(new MockLocalNfsSecondaryStorageResource());
-        Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
-
-        // delete snapshot
-        for (SnapshotStrategy strategy : this.snapshotStrategies) {
-            if (strategy.canHandle(snapshot)) {
-                strategy.deleteSnapshot(newSnapshot.getId());
-            }
-        }
-
-        Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
-    }
+   
 
     private VMTemplateVO createTemplateInDb() {
         VMTemplateVO image = new VMTemplateVO();
@@ -424,7 +395,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
     }
 
     @Test
-    public void createVolumeFromSnapshot() {
+    public void createVolumeFromSnapshot() throws InterruptedException, ExecutionException {
         VolumeInfo vol = createCopyBaseImage();
         SnapshotVO snapshotVO = createSnapshotInDb(vol);
         SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
@@ -440,11 +411,13 @@ public class SnapshotTest extends CloudStackTestNGBase {
 
         VolumeVO volVO = createVolume(vol.getTemplateId(), vol.getPoolId());
         VolumeInfo newVol = this.volFactory.getVolume(volVO.getId());
-        this.volumeService.createVolumeFromSnapshot(newVol, newVol.getDataStore(), snapshot);
+        AsyncCallFuture<VolumeApiResult> volFuture = this.volumeService.createVolumeFromSnapshot(newVol, newVol.getDataStore(), snapshot);
+        VolumeApiResult apiResult = volFuture.get();
+        Assert.assertTrue(apiResult.isSuccess());
     }
 
     @Test
-    public void deleteSnapshot() {
+    public void deleteSnapshot() throws InterruptedException, ExecutionException {
         VolumeInfo vol = createCopyBaseImage();
         SnapshotVO snapshotVO = createSnapshotInDb(vol);
         SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
@@ -466,7 +439,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
     }
 
     @Test
-    public void createTemplateFromSnapshot() {
+    public void createTemplateFromSnapshot() throws InterruptedException, ExecutionException {
         VolumeInfo vol = createCopyBaseImage();
         SnapshotVO snapshotVO = createSnapshotInDb(vol);
         SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
@@ -482,10 +455,46 @@ public class SnapshotTest extends CloudStackTestNGBase {
         LocalHostEndpoint ep = new LocalHostEndpoint();
         ep.setResource(new MockLocalNfsSecondaryStorageResource());
         Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep);
-        VMTemplateVO templateVO = createTemplateInDb();
-        TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
-        DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
-        this.imageService.createTemplateFromSnapshotAsync(snapshot, tmpl, imageStore);
+
+        try {
+            VMTemplateVO templateVO = createTemplateInDb();
+            TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
+            DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
+            AsyncCallFuture<TemplateApiResult> templateFuture = this.imageService.createTemplateFromSnapshotAsync(snapshot, tmpl, imageStore);
+            TemplateApiResult apiResult = templateFuture.get();
+            Assert.assertTrue(apiResult.isSuccess());
+        } finally {
+            Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(remoteEp);
+        }
+    }
+    
+    @Test
+    public void createSnapshot() throws InterruptedException, ExecutionException {
+        VolumeInfo vol = createCopyBaseImage();
+        SnapshotVO snapshotVO = createSnapshotInDb(vol);
+        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
+        SnapshotInfo newSnapshot = null;
+        for (SnapshotStrategy strategy : this.snapshotStrategies) {
+            if (strategy.canHandle(snapshot)) {
+                newSnapshot = strategy.takeSnapshot(snapshot);
+            }
+        }
+        AssertJUnit.assertNotNull(newSnapshot);
+
+        LocalHostEndpoint ep = new MockLocalHostEndPoint();
+        ep.setResource(new MockLocalNfsSecondaryStorageResource());
+        Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
+
+        try {
+            for (SnapshotStrategy strategy : this.snapshotStrategies) {
+                if (strategy.canHandle(snapshot)) {
+                    boolean res = strategy.deleteSnapshot(newSnapshot.getId());
+                    Assert.assertTrue(res);
+                }
+            }
+        } finally {
+            Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
index ef5c4ca..70fdb1b 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
@@ -26,6 +26,8 @@ import java.util.concurrent.ExecutionException;
 
 import javax.inject.Inject;
 
+import junit.framework.Assert;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@@ -39,6 +41,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
 import org.apache.cloudstack.storage.RemoteHostEndPoint;
@@ -237,6 +240,7 @@ public class VolumeTest extends CloudStackTestNGBase {
         TemplateObjectTO to = new TemplateObjectTO();
         to.setPath(this.getImageInstallPath());
         to.setFormat(ImageFormat.VHD);
+        to.setSize(100L);
         CopyCmdAnswer answer = new CopyCmdAnswer(to);
         templateOnStore.processEvent(Event.CreateOnlyRequested);
         templateOnStore.processEvent(Event.OperationSuccessed, answer);
@@ -335,57 +339,52 @@ public class VolumeTest extends CloudStackTestNGBase {
             AssertJUnit.assertTrue(result.isSuccess());
 
             VolumeInfo newVol = result.getVolume();
-            this.volumeService.destroyVolume(newVol.getId());
+            boolean res = this.volumeService.destroyVolume(newVol.getId());
+            Assert.assertTrue(res);
             VolumeInfo vol = this.volFactory.getVolume(volume.getId());
-            this.volumeService.expungeVolumeAsync(vol);
+            future = this.volumeService.expungeVolumeAsync(vol);
+            result = future.get();
+            Assert.assertTrue(result.isSuccess());
         } catch (InterruptedException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            Assert.fail(e.toString());
         } catch (ExecutionException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            Assert.fail(e.toString());
         } catch (ConcurrentOperationException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            Assert.fail(e.toString());
         }
     }
 
     @Test
-    public void testCreateDataDisk() {
+    public void testCreateDataDisk() throws InterruptedException, ExecutionException {
         DataStore primaryStore = createPrimaryDataStore();
         primaryStoreId = primaryStore.getId();
         primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
         VolumeVO volume = createVolume(null, primaryStore.getId());
         VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
-        this.volumeService.createVolumeAsync(volInfo, primaryStore);
+        AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
+        VolumeApiResult result = future.get();
+        Assert.assertTrue(result.isSuccess());
     }
 
     @Test
-    public void testDeleteDisk() {
+    public void testDeleteDisk() throws InterruptedException, ExecutionException, ConcurrentOperationException {
         DataStore primaryStore = createPrimaryDataStore();
         primaryStoreId = primaryStore.getId();
         primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
         VolumeVO volume = createVolume(null, primaryStore.getId());
         VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
         AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
-        try {
-            VolumeApiResult result = future.get();
-            VolumeInfo vol = result.getVolume();
 
-            this.volumeService.destroyVolume(volInfo.getId());
-            volInfo = this.volFactory.getVolume(vol.getId());
-            this.volumeService.expungeVolumeAsync(volInfo);
-        } catch (InterruptedException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (ExecutionException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (ConcurrentOperationException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
+        VolumeApiResult result = future.get();
+        Assert.assertTrue(result.isSuccess());
+        VolumeInfo vol = result.getVolume();
 
+        boolean res = this.volumeService.destroyVolume(volInfo.getId());
+        Assert.assertTrue(res);
+        volInfo = this.volFactory.getVolume(vol.getId());
+        future = this.volumeService.expungeVolumeAsync(volInfo);
+        result = future.get();
+        Assert.assertTrue(result.isSuccess());
     }
 
     private VMTemplateVO createTemplateInDb() {
@@ -411,30 +410,24 @@ public class VolumeTest extends CloudStackTestNGBase {
     }
 
     @Test
-    public void testCreateTemplateFromVolume() {
+    public void testCreateTemplateFromVolume() throws InterruptedException, ExecutionException {
         DataStore primaryStore = createPrimaryDataStore();
         primaryStoreId = primaryStore.getId();
         primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
         VolumeVO volume = createVolume(null, primaryStore.getId());
         VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
         AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
-        try {
-            VolumeApiResult result = future.get();
 
-            AssertJUnit.assertTrue(result.isSuccess());
-            volInfo = result.getVolume();
-            VMTemplateVO templateVO = createTemplateInDb();
-            TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
-            DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
+        VolumeApiResult result = future.get();
 
-            this.imageService.createTemplateFromVolumeAsync(volInfo, tmpl, imageStore);
-        } catch (InterruptedException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (ExecutionException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
+        AssertJUnit.assertTrue(result.isSuccess());
+        volInfo = result.getVolume();
+        VMTemplateVO templateVO = createTemplateInDb();
+        TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
+        DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
 
+        AsyncCallFuture<TemplateApiResult> templateResult = this.imageService.createTemplateFromVolumeAsync(volInfo, tmpl, imageStore);
+        TemplateApiResult templateApiResult = templateResult.get();
+        Assert.assertTrue(templateApiResult.isSuccess());
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/integration-test/test/resource/storageContext.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resource/storageContext.xml b/engine/storage/integration-test/test/resource/storageContext.xml
index cc8e3bf..9f4f102 100644
--- a/engine/storage/integration-test/test/resource/storageContext.xml
+++ b/engine/storage/integration-test/test/resource/storageContext.xml
@@ -43,9 +43,7 @@
   <bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" />
   <bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
   <bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl" />
-  <bean id="snapshotDao2Impl" class="org.apache.cloudstack.storage.snapshot.db.SnapshotDao2Impl" />
   <bean id="templatePrimaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDaoImpl" />
-  <bean id="volumeDao2Impl" class="org.apache.cloudstack.storage.volume.db.VolumeDao2Impl" />
   <bean id="LocalStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.LocalStoragePoolAllocator"/>
   <bean id="clusterScopeStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator" />
   <bean id="zoneWideStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ZoneWideStoragePoolAllocator" />
@@ -76,7 +74,6 @@
   <bean id="snapshotDataFactoryImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotDataFactoryImpl" />
   <bean id="snapshotServiceImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotServiceImpl" />
   <bean id="snapshotStateMachineManagerImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotStateMachineManagerImpl" />
-  <bean id="templateInstallStrategyImpl" class="org.apache.cloudstack.storage.volume.TemplateInstallStrategyImpl" />
   <bean id="unknown" class="org.apache.cloudstack.storage.image.format.Unknown" />
   <bean id="VHD" class="org.apache.cloudstack.storage.image.format.VHD" />
   <bean id="volumeDataFactoryImpl" class="org.apache.cloudstack.storage.volume.VolumeDataFactoryImpl" />
@@ -88,4 +85,6 @@
   <bean id="BAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
   <bean id="storagePoolAutomationImpl" class="com.cloud.storage.StoragePoolAutomationImpl" />
   <bean id="AccountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />
+  <bean id="StorageCacheReplacementAlgorithm" class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU" />
+  <bean id="ServiceOfferingDetailsDao" class="com.cloud.service.dao.ServiceOfferingDetailsDaoImpl" />
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
index bd14573..0310488 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -22,6 +22,7 @@ import java.util.Date;
 
 import javax.inject.Inject;
 
+import com.cloud.storage.DataStoreRole;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
@@ -273,6 +274,47 @@ public class SnapshotObject implements SnapshotInfo {
         this.processEvent(event);
     }
 
+    public void incRefCount() {
+        if (this.store == null) {
+            return;
+        }
+
+        if (this.store.getRole() == DataStoreRole.Image ||
+                this.store.getRole() == DataStoreRole.ImageCache) {
+            SnapshotDataStoreVO store = snapshotStoreDao.findById(this.store.getId());
+            store.incrRefCnt();
+            store.setLastUpdated(new Date());
+            snapshotStoreDao.update(store.getId(), store);
+        }
+    }
+
+    @Override
+    public void decRefCount() {
+        if (this.store == null) {
+            return;
+        }
+        if (this.store.getRole() == DataStoreRole.Image ||
+                this.store.getRole() == DataStoreRole.ImageCache) {
+            SnapshotDataStoreVO store = snapshotStoreDao.findById(this.store.getId());
+            store.decrRefCnt();
+            store.setLastUpdated(new Date());
+            snapshotStoreDao.update(store.getId(), store);
+        }
+    }
+
+    @Override
+    public Long getRefCount() {
+        if (this.store == null) {
+            return null;
+        }
+        if (this.store.getRole() == DataStoreRole.Image ||
+                this.store.getRole() == DataStoreRole.ImageCache) {
+            SnapshotDataStoreVO store = snapshotStoreDao.findById(this.store.getId());
+            return store.getRefCnt();
+        }
+        return null;
+    }
+
     @Override
     public ObjectInDataStoreStateMachine.State getStatus() {
         return this.objectInStoreMgr.findObject(this, store).getObjectInStoreState();
@@ -280,8 +322,6 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public void addPayload(Object data) {
-        // TODO Auto-generated method stub
-
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
index ed53811..631d220 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
@@ -17,23 +17,19 @@
 
 package org.apache.cloudstack.storage.snapshot;
 
-import java.util.concurrent.ExecutionException;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
-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.ObjectInDataStoreStateMachine;
+import com.cloud.dc.dao.ClusterDao;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.VolumeManager;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.snapshot.SnapshotManager;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.fsm.NoTransitionException;
+import com.cloud.vm.dao.UserVmDao;
+import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+import org.apache.cloudstack.engine.subsystem.api.storage.*;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
-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.SnapshotResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
 import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
@@ -47,19 +43,8 @@ import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
-import com.cloud.dc.dao.ClusterDao;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.Snapshot;
-import com.cloud.storage.SnapshotVO;
-import com.cloud.storage.VolumeManager;
-import com.cloud.storage.dao.SnapshotDao;
-import com.cloud.storage.dao.VolumeDao;
-import com.cloud.storage.snapshot.SnapshotManager;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.fsm.NoTransitionException;
-import com.cloud.vm.dao.UserVmDao;
-import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+import javax.inject.Inject;
+import java.util.concurrent.ExecutionException;
 
 @Component
 public class SnapshotServiceImpl implements SnapshotService {
@@ -391,7 +376,6 @@ public class SnapshotServiceImpl implements SnapshotService {
 
     @Override
     public boolean revertSnapshot(SnapshotInfo snapshot) {
-        // TODO Auto-generated method stub
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManager.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManager.java
index f07db7e..2ad4ae7 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManager.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManager.java
@@ -22,5 +22,5 @@ import com.cloud.storage.SnapshotVO;
 import com.cloud.utils.fsm.NoTransitionException;
 
 public interface SnapshotStateMachineManager {
-    public void processEvent(SnapshotVO snapshot, Event event) throws NoTransitionException;
+    void processEvent(SnapshotVO snapshot, Event event) throws NoTransitionException;
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
index 0c3f31c..92af8c2 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
@@ -194,7 +194,6 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
     @Override
     public SnapshotInfo takeSnapshot(SnapshotInfo snapshot) {
         snapshot = snapshotSvr.takeSnapshot(snapshot).getSnashot();
-        // TODO: add async
         return this.backupSnapshot(snapshot);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2.java
deleted file mode 100644
index d531ede..0000000
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.snapshot.db;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface SnapshotDao2 extends GenericDao<SnapshotVO, Long> {
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a715eb81/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2Impl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2Impl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2Impl.java
deleted file mode 100644
index 74cec5e..0000000
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2Impl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.snapshot.db;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-
-@Component
-public class SnapshotDao2Impl extends GenericDaoBase<SnapshotVO, Long> implements SnapshotDao2 {
-
-}