cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [1/4] Removed schema from the dependency of many components
Date Mon, 29 Jul 2013 17:54:46 GMT
Updated Branches:
  refs/heads/master 399c37345 -> a4cea4ebf


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
new file mode 100644
index 0000000..300df1e
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
@@ -0,0 +1,271 @@
+// 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.datastore.db;
+
+import java.util.Date;
+
+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 javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.fsm.StateObject;
+
+/**
+ * Join table for image_data_store and snapshots
+ * 
+ */
+@Entity
+@Table(name = "snapshot_store_ref")
+public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    Long id;
+
+    @Column(name = "store_id")
+    private long dataStoreId;
+
+    @Column(name = "store_role")
+    @Enumerated(EnumType.STRING)
+    private DataStoreRole role;
+
+    @Column(name = "snapshot_id")
+    private long snapshotId;
+
+    @Column(name = GenericDaoBase.CREATED_COLUMN)
+    private Date created = null;
+
+    @Column(name = "last_updated")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date lastUpdated = null;
+
+    @Column(name = "size")
+    private long size;
+
+    @Column(name = "physical_size")
+    private long physicalSize;
+
+    @Column(name = "parent_snapshot_id")
+    private long parentSnapshotId;
+
+    @Column(name = "job_id")
+    private String jobId;
+
+    @Column(name = "install_path")
+    private String installPath;
+
+    @Column(name = "update_count", updatable = true, nullable = false)
+    protected long updatedCount;
+
+    @Column(name = "updated")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    Date updated;
+
+    @Column(name = "state")
+    @Enumerated(EnumType.STRING)
+    ObjectInDataStoreStateMachine.State state;
+
+    @Column(name = "ref_cnt")
+    Long refCnt = 0L;
+
+    @Column(name = "volume_id")
+    Long volumeId;
+
+    public String getInstallPath() {
+        return installPath;
+    }
+
+    @Override
+    public long getDataStoreId() {
+        return dataStoreId;
+    }
+
+    public void setDataStoreId(long storeId) {
+        this.dataStoreId = storeId;
+    }
+
+    public long getSnapshotId() {
+        return snapshotId;
+    }
+
+    public void setSnapshotId(long snapshotId) {
+        this.snapshotId = snapshotId;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public Date getLastUpdated() {
+        return lastUpdated;
+    }
+
+    public void setLastUpdated(Date date) {
+        lastUpdated = date;
+    }
+
+    public void setInstallPath(String installPath) {
+        this.installPath = installPath;
+    }
+
+    public SnapshotDataStoreVO(long hostId, long snapshotId) {
+        super();
+        this.dataStoreId = hostId;
+        this.snapshotId = snapshotId;
+        this.state = ObjectInDataStoreStateMachine.State.Allocated;
+    }
+
+    public SnapshotDataStoreVO() {
+
+    }
+
+    public void setJobId(String jobId) {
+        this.jobId = jobId;
+    }
+
+    public String getJobId() {
+        return jobId;
+    }
+
+    public boolean equals(Object obj) {
+        if (obj instanceof SnapshotDataStoreVO) {
+            SnapshotDataStoreVO other = (SnapshotDataStoreVO) obj;
+            return (this.snapshotId == other.getSnapshotId() && this.dataStoreId == other.getDataStoreId());
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        Long tid = new Long(snapshotId);
+        Long hid = new Long(dataStoreId);
+        return tid.hashCode() + hid.hashCode();
+    }
+
+    public void setSize(long size) {
+        this.size = size;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public void setPhysicalSize(long physicalSize) {
+        this.physicalSize = physicalSize;
+    }
+
+    public long getPhysicalSize() {
+        return physicalSize;
+    }
+
+    public long getVolumeSize() {
+        return -1;
+    }
+
+    public String toString() {
+        return new StringBuilder("VolumeHost[").append(id).append("-").append(snapshotId).append("-")
+                .append(dataStoreId).append(installPath).append("]").toString();
+    }
+
+    public long getUpdatedCount() {
+        return this.updatedCount;
+    }
+
+    public void incrUpdatedCount() {
+        this.updatedCount++;
+    }
+
+    public void decrUpdatedCount() {
+        this.updatedCount--;
+    }
+
+    public Date getUpdated() {
+        return updated;
+    }
+
+    @Override
+    public ObjectInDataStoreStateMachine.State getState() {
+        // TODO Auto-generated method stub
+        return this.state;
+    }
+
+    public void setState(ObjectInDataStoreStateMachine.State state) {
+        this.state = state;
+    }
+
+    @Override
+    public long getObjectId() {
+        return this.getSnapshotId();
+    }
+
+    public DataStoreRole getRole() {
+        return role;
+    }
+
+    public void setRole(DataStoreRole role) {
+        this.role = role;
+    }
+
+    @Override
+    public State getObjectInStoreState() {
+        return this.state;
+    }
+
+    public long getParentSnapshotId() {
+        return parentSnapshotId;
+    }
+
+    public void setParentSnapshotId(long parentSnapshotId) {
+        this.parentSnapshotId = parentSnapshotId;
+    }
+
+    public Long getRefCnt() {
+        return refCnt;
+    }
+
+    public void incrRefCnt() {
+        this.refCnt++;
+    }
+
+    public void decrRefCnt() {
+        this.refCnt--;
+    }
+
+    public Long getVolumeId() {
+        return volumeId;
+    }
+
+    public void setVolumeId(Long volumeId) {
+        this.volumeId = volumeId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
new file mode 100644
index 0000000..e51f3a3
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
@@ -0,0 +1,81 @@
+// 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.datastore.db;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "storage_pool_details")
+public class StoragePoolDetailVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    long id;
+
+    @Column(name = "pool_id")
+    long poolId;
+
+    @Column(name = "name")
+    String name;
+
+    @Column(name = "value")
+    String value;
+
+    public StoragePoolDetailVO(long poolId, String name, String value) {
+        this.poolId = poolId;
+        this.name = name;
+        this.value = value;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getPoolId() {
+        return poolId;
+    }
+
+    public void setPoolId(long poolId) {
+        this.poolId = poolId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    protected StoragePoolDetailVO() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
new file mode 100644
index 0000000..49f4f19
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
@@ -0,0 +1,30 @@
+// 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.datastore.db;
+
+import java.util.Map;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface StoragePoolDetailsDao extends GenericDao<StoragePoolDetailVO, Long> {
+
+    void update(long poolId, Map<String, String> details);
+
+    Map<String, String> getDetails(long poolId);
+
+    StoragePoolDetailVO findDetail(long poolId, String name);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
new file mode 100644
index 0000000..941b952
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
@@ -0,0 +1,346 @@
+// 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.datastore.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.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.ScopeType;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = "storage_pool")
+public class StoragePoolVO implements StoragePool {
+    @Id
+    @TableGenerator(name = "storage_pool_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
+            pkColumnValue = "storage_pool_seq", allocationSize = 1)
+    @Column(name = "id", updatable = false, nullable = false)
+    private long id;
+
+    @Column(name = "name", updatable = false, nullable = false, length = 255)
+    private String name = null;
+
+    @Column(name = "uuid", length = 255)
+    private String uuid = null;
+
+    @Column(name = "pool_type", updatable = false, nullable = false, length = 32)
+    @Enumerated(value = EnumType.STRING)
+    private StoragePoolType poolType;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    Date created;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name = "update_time", updatable = true)
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date updateTime;
+
+    @Column(name = "data_center_id", updatable = true, nullable = false)
+    private long dataCenterId;
+
+    @Column(name = "pod_id", updatable = true)
+    private Long podId;
+
+    @Column(name = "used_bytes", updatable = true, nullable = true)
+    private long usedBytes;
+
+    @Column(name = "capacity_bytes", updatable = true, nullable = true)
+    private long capacityBytes;
+
+    @Column(name = "status", updatable = true, nullable = false)
+    @Enumerated(value = EnumType.STRING)
+    private StoragePoolStatus status;
+
+    @Column(name = "storage_provider_name", updatable = true, nullable = false)
+    private String storageProviderName;
+
+    @Column(name = "host_address")
+    private String hostAddress;
+
+    @Column(name = "path")
+    private String path;
+
+    @Column(name = "port")
+    private int port;
+
+    @Column(name = "user_info")
+    private String userInfo;
+
+    @Column(name = "cluster_id")
+    private Long clusterId;
+
+    @Column(name = "scope")
+    @Enumerated(value = EnumType.STRING)
+    private ScopeType scope;
+
+    @Column(name = "managed")
+    private boolean managed;
+
+    @Column(name = "capacity_iops", updatable = true, nullable = true)
+    private Long capacityIops;
+
+    @Column(name = "hypervisor")
+    @Enumerated(value = EnumType.STRING)
+    private HypervisorType hypervisor;
+
+    public long getId() {
+        return id;
+    }
+
+    public StoragePoolStatus getStatus() {
+        return status;
+    }
+
+    public StoragePoolVO() {
+        this.status = StoragePoolStatus.Initial;
+    }
+
+    public StoragePoolVO(long poolId, String name, String uuid, StoragePoolType type, long dataCenterId, Long podId,
+            long availableBytes, long capacityBytes, String hostAddress, int port, String hostPath) {
+        this.name = name;
+        this.id = poolId;
+        this.uuid = uuid;
+        this.poolType = type;
+        this.dataCenterId = dataCenterId;
+        this.usedBytes = availableBytes;
+        this.capacityBytes = capacityBytes;
+        this.hostAddress = hostAddress;
+        this.path = hostPath;
+        this.port = port;
+        this.podId = podId;
+        this.setStatus(StoragePoolStatus.Initial);
+    }
+
+    public StoragePoolVO(StoragePoolVO that) {
+        this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.usedBytes,
+                that.capacityBytes, that.hostAddress, that.port, that.path);
+    }
+
+    public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path) {
+        this.poolType = type;
+        this.hostAddress = hostAddress;
+        this.port = port;
+        this.path = path;
+        this.setStatus(StoragePoolStatus.Initial);
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public StoragePoolType getPoolType() {
+        return poolType;
+    }
+
+    public void setPoolType(StoragePoolType protocol) {
+        this.poolType = protocol;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public long getDataCenterId() {
+        return dataCenterId;
+    }
+
+    public long getUsedBytes() {
+        return usedBytes;
+    }
+
+    public String getStorageProviderName() {
+        return storageProviderName;
+    }
+
+    public void setStorageProviderName(String providerName) {
+        storageProviderName = providerName;
+    }
+
+    public long getCapacityBytes() {
+        return capacityBytes;
+    }
+
+    public void setUsedBytes(long usedBytes) {
+        this.usedBytes = usedBytes;
+    }
+
+    public void setCapacityBytes(long capacityBytes) {
+        this.capacityBytes = capacityBytes;
+    }
+
+    public void setManaged(boolean managed) {
+    	this.managed = managed;
+    }
+
+    public boolean isManaged() {
+    	return managed;
+    }
+
+    public void setCapacityIops(Long capacityIops) {
+        this.capacityIops = capacityIops;
+    }
+
+    public Long getCapacityIops() {
+        return capacityIops;
+    }
+
+    public Long getClusterId() {
+        return clusterId;
+    }
+
+    public void setClusterId(Long clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public String getHostAddress() {
+        return hostAddress;
+    }
+
+    public void setHostAddress(String host) {
+        this.hostAddress = host;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public String getUserInfo() {
+        return userInfo;
+    }
+
+    public void setStatus(StoragePoolStatus status) {
+        this.status = status;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public void setDataCenterId(long dcId) {
+        this.dataCenterId = dcId;
+    }
+
+    public void setPodId(Long podId) {
+        this.podId = podId;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public void setUserInfo(String userInfo) {
+        this.userInfo = userInfo;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setScope(ScopeType scope) {
+        this.scope = scope;
+    }
+
+    public ScopeType getScope() {
+        return this.scope;
+    }
+
+    public HypervisorType getHypervisor() {
+        return hypervisor;
+    }
+
+    public void setHypervisor(HypervisorType hypervisor) {
+        this.hypervisor = hypervisor;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof StoragePoolVO) || obj == null) {
+            return false;
+        }
+        StoragePoolVO that = (StoragePoolVO) obj;
+        return this.id == that.id;
+    }
+
+    @Override
+    public int hashCode() {
+        return new Long(id).hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return new StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
+    }
+
+    public boolean isShared() {
+        return this.scope == ScopeType.HOST ? false : true;
+    }
+
+    public boolean isLocal() {
+        return !isShared();
+    }
+
+    @Override
+    public boolean isInMaintenance() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
new file mode 100644
index 0000000..9350751
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
@@ -0,0 +1,65 @@
+// 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.datastore.db;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.VMTemplateStorageResourceAssoc;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>,
+StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
+
+    List<TemplateDataStoreVO> listByStoreId(long id);
+
+    List<TemplateDataStoreVO> listDestroyed(long storeId);
+
+    List<TemplateDataStoreVO> listActiveOnCache(long id);
+
+    void deletePrimaryRecordsForStore(long id);
+
+    void deletePrimaryRecordsForTemplate(long templateId);
+
+    List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId);
+
+    List<TemplateDataStoreVO> listByTemplateStoreStatus(long templateId, long storeId, State... states);
+
+    List<TemplateDataStoreVO> listByTemplateStoreDownloadStatus(long templateId, long storeId,
+            VMTemplateStorageResourceAssoc.Status... status);
+
+    List<TemplateDataStoreVO> listByTemplateZoneDownloadStatus(long templateId, Long zoneId,
+            VMTemplateStorageResourceAssoc.Status... status);
+
+    TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId,
+            VMTemplateStorageResourceAssoc.Status... status);
+
+    TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId);
+
+    TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId, boolean lock);
+
+    TemplateDataStoreVO findByTemplate(long templateId, DataStoreRole role);
+
+    TemplateDataStoreVO findByTemplateZone(long templateId, Long zoneId, DataStoreRole role);
+
+    List<TemplateDataStoreVO> listByTemplate(long templateId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
new file mode 100755
index 0000000..b6af559
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
@@ -0,0 +1,372 @@
+// 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.datastore.db;
+
+import java.util.Date;
+
+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 javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.fsm.StateObject;
+
+/**
+ * Join table for image_data_store and templates
+ * 
+ */
+@Entity
+@Table(name = "template_store_ref")
+public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    Long id;
+
+    @Column(name = "store_id")
+    private Long dataStoreId; // this can be null for baremetal templates
+
+    @Column(name = "template_id")
+    private long templateId;
+
+    @Column(name = "store_role")
+    @Enumerated(EnumType.STRING)
+    private DataStoreRole dataStoreRole;
+
+    @Column(name = GenericDaoBase.CREATED_COLUMN)
+    private Date created = null;
+
+    @Column(name = "last_updated")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date lastUpdated = null;
+
+    @Column(name = "download_pct")
+    private int downloadPercent;
+
+    @Column(name = "size")
+    private Long size;
+
+    @Column(name = "physical_size")
+    private long physicalSize;
+
+    @Column(name = "download_state")
+    @Enumerated(EnumType.STRING)
+    private Status downloadState;
+
+    @Column(name = "local_path")
+    private String localDownloadPath;
+
+    @Column(name = "error_str")
+    private String errorString;
+
+    @Column(name = "job_id")
+    private String jobId;
+
+    @Column(name = "install_path")
+    private String installPath;
+
+    @Column(name = "url")
+    private String downloadUrl;
+
+    @Column(name = "is_copy")
+    private boolean isCopy = false;
+
+    @Column(name = "destroyed")
+    boolean destroyed = false;
+
+    @Column(name = "update_count", updatable = true, nullable = false)
+    protected long updatedCount;
+
+    @Column(name = "updated")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    Date updated;
+
+    @Column(name = "state")
+    @Enumerated(EnumType.STRING)
+    ObjectInDataStoreStateMachine.State state;
+
+    @Column(name = "ref_cnt")
+    Long refCnt = 0L;
+
+    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,
+            Status downloadState, String localDownloadPath, String errorString, String jobId, String installPath,
+            String downloadUrl) {
+        super();
+        this.dataStoreId = hostId;
+        this.templateId = templateId;
+        this.lastUpdated = lastUpdated;
+        this.downloadPercent = downloadPercent;
+        this.downloadState = downloadState;
+        this.localDownloadPath = localDownloadPath;
+        this.errorString = errorString;
+        this.jobId = jobId;
+        this.refCnt = 0L;
+        this.installPath = installPath;
+        this.setDownloadUrl(downloadUrl);
+        switch (downloadState) {
+        case DOWNLOADED:
+            this.state = ObjectInDataStoreStateMachine.State.Ready;
+            break;
+        case CREATING:
+        case DOWNLOAD_IN_PROGRESS:
+        case UPLOAD_IN_PROGRESS:
+            this.state = ObjectInDataStoreStateMachine.State.Creating2;
+            break;
+        case DOWNLOAD_ERROR:
+        case UPLOAD_ERROR:
+            this.state = ObjectInDataStoreStateMachine.State.Failed;
+            break;
+        case ABANDONED:
+            this.state = ObjectInDataStoreStateMachine.State.Destroyed;
+            break;
+        default:
+            this.state = ObjectInDataStoreStateMachine.State.Allocated;
+            break;
+        }
+    }
+
+    public TemplateDataStoreVO() {
+        this.refCnt = 0L;
+    }
+
+    @Override
+    public String getInstallPath() {
+        return installPath;
+    }
+
+    @Override
+    public long getDataStoreId() {
+        return dataStoreId;
+    }
+
+    public void setDataStoreId(long storeId) {
+        this.dataStoreId = storeId;
+    }
+
+    public long getTemplateId() {
+        return templateId;
+    }
+
+    public void setTemplateId(long templateId) {
+        this.templateId = templateId;
+    }
+
+    public int getDownloadPercent() {
+        return downloadPercent;
+    }
+
+    public void setDownloadPercent(int downloadPercent) {
+        this.downloadPercent = downloadPercent;
+    }
+
+    public void setDownloadState(Status downloadState) {
+        this.downloadState = downloadState;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public Date getLastUpdated() {
+        return lastUpdated;
+    }
+
+    public void setLastUpdated(Date date) {
+        lastUpdated = date;
+    }
+
+    @Override
+    public void setInstallPath(String installPath) {
+        this.installPath = installPath;
+    }
+
+    public Status getDownloadState() {
+        return downloadState;
+    }
+
+    public void setLocalDownloadPath(String localPath) {
+        this.localDownloadPath = localPath;
+    }
+
+    public String getLocalDownloadPath() {
+        return localDownloadPath;
+    }
+
+    public void setErrorString(String errorString) {
+        this.errorString = errorString;
+    }
+
+    public String getErrorString() {
+        return errorString;
+    }
+
+    public void setJobId(String jobId) {
+        this.jobId = jobId;
+    }
+
+    public String getJobId() {
+        return jobId;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof TemplateDataStoreVO) {
+            TemplateDataStoreVO other = (TemplateDataStoreVO) obj;
+            return (this.templateId == other.getTemplateId() && this.dataStoreId == other.getDataStoreId());
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        Long tid = new Long(templateId);
+        Long hid = new Long(dataStoreId);
+        return tid.hashCode() + hid.hashCode();
+    }
+
+    public void setSize(Long size) {
+        this.size = size;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public void setPhysicalSize(long physicalSize) {
+        this.physicalSize = physicalSize;
+    }
+
+    public long getPhysicalSize() {
+        return physicalSize;
+    }
+
+    public void setDestroyed(boolean destroyed) {
+        this.destroyed = destroyed;
+    }
+
+    public boolean getDestroyed() {
+        return destroyed;
+    }
+
+    public void setDownloadUrl(String downloadUrl) {
+        this.downloadUrl = downloadUrl;
+    }
+
+    public String getDownloadUrl() {
+        return downloadUrl;
+    }
+
+    public void setCopy(boolean isCopy) {
+        this.isCopy = isCopy;
+    }
+
+    public boolean isCopy() {
+        return isCopy;
+    }
+
+    public long getTemplateSize() {
+        return -1;
+    }
+
+    @Override
+    public String toString() {
+        return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(dataStoreId)
+                .append(installPath).append("]").toString();
+    }
+
+    @Override
+    public ObjectInDataStoreStateMachine.State getState() {
+        // TODO Auto-generated method stub
+        return this.state;
+    }
+
+    public void setState(ObjectInDataStoreStateMachine.State state) {
+        this.state = state;
+    }
+
+    public long getUpdatedCount() {
+        return this.updatedCount;
+    }
+
+    public void incrUpdatedCount() {
+        this.updatedCount++;
+    }
+
+    public void decrUpdatedCount() {
+        this.updatedCount--;
+    }
+
+    public Date getUpdated() {
+        return updated;
+    }
+
+    @Override
+    public long getObjectId() {
+        return this.getTemplateId();
+    }
+
+    @Override
+    public State getObjectInStoreState() {
+        return this.state;
+    }
+
+    public DataStoreRole getDataStoreRole() {
+        return dataStoreRole;
+    }
+
+    public void setDataStoreRole(DataStoreRole dataStoreRole) {
+        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/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
new file mode 100644
index 0000000..698465f
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
@@ -0,0 +1,43 @@
+// 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.datastore.db;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
+StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
+
+    List<VolumeDataStoreVO> listByStoreId(long id);
+
+    List<VolumeDataStoreVO> listActiveOnCache(long id);
+
+    void deletePrimaryRecordsForStore(long id);
+
+    VolumeDataStoreVO findByVolume(long volumeId);
+
+    VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId);
+
+    VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock);
+
+    List<VolumeDataStoreVO> listDestroyed(long storeId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
new file mode 100755
index 0000000..a5d0830
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
@@ -0,0 +1,348 @@
+// 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.datastore.db;
+
+import java.util.Date;
+
+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 javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+
+import com.cloud.storage.Storage;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.fsm.StateObject;
+
+/**
+ * Join table for image_data_store and volumes
+ * 
+ */
+@Entity
+@Table(name = "volume_store_ref")
+public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    Long id;
+
+    @Column(name = "store_id")
+    private long dataStoreId;
+
+    @Column(name = "volume_id")
+    private long volumeId;
+
+    @Column(name = "zone_id")
+    private long zoneId;
+
+    @Column(name = GenericDaoBase.CREATED_COLUMN)
+    private Date created = null;
+
+    @Column(name = "last_updated")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date lastUpdated = null;
+
+    @Column(name = "download_pct")
+    private int downloadPercent;
+
+    @Column(name = "size")
+    private long size;
+
+    @Column(name = "physical_size")
+    private long physicalSize;
+
+    @Column(name = "download_state")
+    @Enumerated(EnumType.STRING)
+    private Status downloadState;
+
+    @Column(name = "checksum")
+    private String checksum;
+
+    @Column(name = "local_path")
+    private String localDownloadPath;
+
+    @Column(name = "error_str")
+    private String errorString;
+
+    @Column(name = "job_id")
+    private String jobId;
+
+    @Column(name = "install_path")
+    private String installPath;
+
+    @Column(name = "url")
+    private String downloadUrl;
+
+    @Column(name = "destroyed")
+    boolean destroyed = false;
+
+    @Column(name = "update_count", updatable = true, nullable = false)
+    protected long updatedCount;
+
+    @Column(name = "updated")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    Date updated;
+
+    @Column(name = "state")
+    @Enumerated(EnumType.STRING)
+    ObjectInDataStoreStateMachine.State state;
+
+    @Column(name = "ref_cnt")
+    Long refCnt = 0L;
+
+    public String getInstallPath() {
+        return installPath;
+    }
+
+    @Override
+    public long getDataStoreId() {
+        return dataStoreId;
+    }
+
+    public void setDataStoreId(long storeId) {
+        this.dataStoreId = storeId;
+    }
+
+    public long getVolumeId() {
+        return volumeId;
+    }
+
+    public void setVolumeId(long volumeId) {
+        this.volumeId = volumeId;
+    }
+
+    public long getZoneId() {
+        return zoneId;
+    }
+
+    public void setZoneId(long zoneId) {
+        this.zoneId = zoneId;
+    }
+
+    public int getDownloadPercent() {
+        return downloadPercent;
+    }
+
+    public void setDownloadPercent(int downloadPercent) {
+        this.downloadPercent = downloadPercent;
+    }
+
+    public void setDownloadState(Status downloadState) {
+        this.downloadState = downloadState;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public Date getLastUpdated() {
+        return lastUpdated;
+    }
+
+    public void setLastUpdated(Date date) {
+        lastUpdated = date;
+    }
+
+    public void setInstallPath(String installPath) {
+        this.installPath = installPath;
+    }
+
+    public Status getDownloadState() {
+        return downloadState;
+    }
+
+    public String getChecksum() {
+        return checksum;
+    }
+
+    public void setChecksum(String checksum) {
+        this.checksum = checksum;
+    }
+
+    public VolumeDataStoreVO(long hostId, long volumeId) {
+        super();
+        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,
+            String localDownloadPath, String errorString, String jobId, String installPath, String downloadUrl,
+            String checksum) {
+        // super();
+        this.dataStoreId = hostId;
+        this.volumeId = volumeId;
+        // this.zoneId = zoneId;
+        this.lastUpdated = lastUpdated;
+        this.downloadPercent = downloadPercent;
+        this.downloadState = downloadState;
+        this.localDownloadPath = localDownloadPath;
+        this.errorString = errorString;
+        this.jobId = jobId;
+        this.installPath = installPath;
+        this.setDownloadUrl(downloadUrl);
+        this.checksum = checksum;
+        this.refCnt = 0L;
+    }
+
+    public VolumeDataStoreVO() {
+        this.refCnt = 0L;
+    }
+
+    public void setLocalDownloadPath(String localPath) {
+        this.localDownloadPath = localPath;
+    }
+
+    public String getLocalDownloadPath() {
+        return localDownloadPath;
+    }
+
+    public void setErrorString(String errorString) {
+        this.errorString = errorString;
+    }
+
+    public String getErrorString() {
+        return errorString;
+    }
+
+    public void setJobId(String jobId) {
+        this.jobId = jobId;
+    }
+
+    public String getJobId() {
+        return jobId;
+    }
+
+    public boolean equals(Object obj) {
+        if (obj instanceof VolumeDataStoreVO) {
+            VolumeDataStoreVO other = (VolumeDataStoreVO) obj;
+            return (this.volumeId == other.getVolumeId() && this.dataStoreId == other.getDataStoreId());
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        Long tid = new Long(volumeId);
+        Long hid = new Long(dataStoreId);
+        return tid.hashCode() + hid.hashCode();
+    }
+
+    public void setSize(long size) {
+        this.size = size;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public void setPhysicalSize(long physicalSize) {
+        this.physicalSize = physicalSize;
+    }
+
+    public long getPhysicalSize() {
+        return physicalSize;
+    }
+
+    public void setDestroyed(boolean destroyed) {
+        this.destroyed = destroyed;
+    }
+
+    public boolean getDestroyed() {
+        return destroyed;
+    }
+
+    public void setDownloadUrl(String downloadUrl) {
+        this.downloadUrl = downloadUrl;
+    }
+
+    public String getDownloadUrl() {
+        return downloadUrl;
+    }
+
+    public long getVolumeSize() {
+        return -1;
+    }
+
+    public String toString() {
+        return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(dataStoreId)
+                .append(installPath).append("]").toString();
+    }
+
+    public long getUpdatedCount() {
+        return this.updatedCount;
+    }
+
+    public void incrUpdatedCount() {
+        this.updatedCount++;
+    }
+
+    public void decrUpdatedCount() {
+        this.updatedCount--;
+    }
+
+    public Date getUpdated() {
+        return updated;
+    }
+
+    @Override
+    public ObjectInDataStoreStateMachine.State getState() {
+        // TODO Auto-generated method stub
+        return this.state;
+    }
+
+    public void setState(ObjectInDataStoreStateMachine.State state) {
+        this.state = state;
+    }
+
+    @Override
+    public long getObjectId() {
+        return this.getVolumeId();
+    }
+
+    @Override
+    public State getObjectInStoreState() {
+        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/a4cea4eb/engine/storage/cache/pom.xml
----------------------------------------------------------------------
diff --git a/engine/storage/cache/pom.xml b/engine/storage/cache/pom.xml
index 584d14d..66c8804 100644
--- a/engine/storage/cache/pom.xml
+++ b/engine/storage/cache/pom.xml
@@ -1,13 +1,12 @@
 <!-- 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. -->
+  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. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
@@ -22,6 +21,11 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-schema</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-engine-storage</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 60dd9f7..aa0173c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -180,7 +180,7 @@
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>${cs.mysql.version}</version>
-        <scope>provided</scope>
+        <scope>provided,test</scope>
       </dependency>
       <dependency>
         <groupId>log4j</groupId>
@@ -276,12 +276,6 @@
       </dependency>
       <!-- Test dependency in mysql for db tests -->
       <dependency>
-        <groupId>mysql</groupId>
-        <artifactId>mysql-connector-java</artifactId>
-        <version>${cs.mysql.version}</version>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
         <groupId>commons-io</groupId>
         <artifactId>commons-io</artifactId>
         <version>${cs.commons-io.version}</version>
@@ -297,11 +291,11 @@
         <artifactId>esapi</artifactId>
         <version>2.0.1</version>
       </dependency>
-    <dependency>
-      <groupId>org.eclipse.persistence</groupId>
-      <artifactId>javax.persistence</artifactId>
-      <version>${cs.jpa.version}</version>
-    </dependency>
+      <dependency>
+        <groupId>org.eclipse.persistence</groupId>
+        <artifactId>javax.persistence</artifactId>
+        <version>${cs.jpa.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index b159b4d..9178f78 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -103,6 +103,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-schema</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-framework-ipc</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java b/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java
index 45f0faa..89a5f39 100644
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java
@@ -26,7 +26,7 @@ import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
 import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.ConsoleProxyVO;
+import com.cloud.vm.ConsoleProxy;
 
 import edu.emory.mathcs.backport.java.util.Collections;
 
@@ -36,40 +36,32 @@ public class ConsoleProxyBalanceAllocator extends AdapterBase implements Console
     private final Random _rand = new Random(System.currentTimeMillis());
 
     @Override
-    public ConsoleProxyVO allocProxy(List<ConsoleProxyVO> candidates, final Map<Long, Integer> loadInfo, long dataCenterId) {
-        if(candidates != null) {
+    public Long allocProxy(List<? extends ConsoleProxy> candidates, final Map<Long, Integer> loadInfo, long dataCenterId) {
+        List<ConsoleProxy> allocationList = new ArrayList<ConsoleProxy>(candidates);
 
-            List<ConsoleProxyVO> allocationList = new ArrayList<ConsoleProxyVO>();
-            for(ConsoleProxyVO proxy : candidates) {
-                allocationList.add(proxy);
-            }
-
-            Collections.sort(candidates, new Comparator<ConsoleProxyVO> () {
-                @Override
-                public int compare(ConsoleProxyVO x, ConsoleProxyVO y) {
-                    Integer loadOfX = loadInfo.get(x.getId());
-                    Integer loadOfY = loadInfo.get(y.getId());
+        Collections.sort(candidates, new Comparator<ConsoleProxy>() {
+            @Override
+            public int compare(ConsoleProxy x, ConsoleProxy y) {
+                Integer loadOfX = loadInfo.get(x.getId());
+                Integer loadOfY = loadInfo.get(y.getId());
 
-                    if(loadOfX != null && loadOfY != null) {
-                        if(loadOfX < loadOfY)
-                            return -1;
-                        else if(loadOfX > loadOfY)
-                            return 1;
-                        return 0;
-                    } else if(loadOfX == null && loadOfY == null) {
-                        return 0;
-                    } else {
-                        if(loadOfX == null)
-                            return -1;
+                if (loadOfX != null && loadOfY != null) {
+                    if (loadOfX < loadOfY)
+                        return -1;
+                    else if (loadOfX > loadOfY)
                         return 1;
-                    }
+                    return 0;
+                } else if (loadOfX == null && loadOfY == null) {
+                    return 0;
+                } else {
+                    if (loadOfX == null)
+                        return -1;
+                    return 1;
                 }
-            });
+            }
+        });
 
-            if(allocationList.size() > 0)
-                return allocationList.get(0);
-        }
-        return null;
+        return (allocationList.size() > 0) ? allocationList.get(0).getId() : null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index bae2405..e1c15dc 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -619,7 +619,12 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
                     }
                 }
             }
-            return allocator.allocProxy(runningList, loadInfo, dataCenterId);
+            Long allocated = allocator.allocProxy(runningList, loadInfo, dataCenterId);
+            if (allocated == null) {
+                s_logger.debug("Unable to find a console proxy ");
+                return null;
+            }
+            return _consoleProxyDao.findById(allocated);
         } else {
             if (s_logger.isTraceEnabled()) {
                 s_logger.trace("Empty running proxy pool for now in data center : " + dataCenterId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/usage/pom.xml
----------------------------------------------------------------------
diff --git a/usage/pom.xml b/usage/pom.xml
index 257359c..14a375f 100644
--- a/usage/pom.xml
+++ b/usage/pom.xml
@@ -39,6 +39,11 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-schema</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>mysql</groupId>
       <artifactId>mysql-connector-java</artifactId>
       <scope>runtime</scope>


Mime
View raw message