You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2016/05/24 09:49:27 UTC
[22/48] git commit: updated refs/heads/4.9-bountycastle-daan to
98bf0ca
Faster logic to see if a cluster supports resigning
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9d215562
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9d215562
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9d215562
Branch: refs/heads/4.9-bountycastle-daan
Commit: 9d215562eb9e395efd1b6433d59513c5267a4d4c
Parents: 2bd035d
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Fri May 13 13:52:49 2016 -0600
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Mon May 16 07:18:39 2016 -0600
----------------------------------------------------------------------
.../schema/src/com/cloud/dc/dao/ClusterDao.java | 2 +-
.../src/com/cloud/dc/dao/ClusterDaoImpl.java | 33 ++++--------
.../src/com/cloud/host/dao/HostDetailsDao.java | 2 -
.../com/cloud/host/dao/HostDetailsDaoImpl.java | 26 ----------
.../motion/StorageSystemDataMotionStrategy.java | 8 +--
.../snapshot/StorageSystemSnapshotStrategy.java | 4 +-
.../storage/volume/VolumeServiceImpl.java | 2 +-
.../com/cloud/resource/ResourceManagerImpl.java | 54 +++++++++++++++++---
.../com/cloud/storage/StorageManagerImpl.java | 2 +-
9 files changed, 65 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/engine/schema/src/com/cloud/dc/dao/ClusterDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/ClusterDao.java b/engine/schema/src/com/cloud/dc/dao/ClusterDao.java
index 8e02822..06bc5a3 100644
--- a/engine/schema/src/com/cloud/dc/dao/ClusterDao.java
+++ b/engine/schema/src/com/cloud/dc/dao/ClusterDao.java
@@ -46,5 +46,5 @@ public interface ClusterDao extends GenericDao<ClusterVO, Long> {
List<Long> listAllCusters(long zoneId);
- boolean computeWhetherClusterSupportsResigning(long clusterId);
+ boolean getSupportsResigning(long clusterId);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
index aa0b21b..0c5bd6f 100644
--- a/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
@@ -28,11 +28,10 @@ import javax.inject.Inject;
import org.springframework.stereotype.Component;
+import com.cloud.dc.ClusterDetailsDao;
+import com.cloud.dc.ClusterDetailsVO;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.HostPodVO;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-import com.cloud.host.dao.HostDetailsDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.org.Grouping;
import com.cloud.utils.db.GenericDaoBase;
@@ -60,9 +59,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
private static final String GET_POD_CLUSTER_MAP_PREFIX = "SELECT pod_id, id FROM cloud.cluster WHERE cluster.id IN( ";
private static final String GET_POD_CLUSTER_MAP_SUFFIX = " )";
@Inject
- private HostDao hostDao;
- @Inject
- private HostDetailsDao hostDetailsDao;
+ private ClusterDetailsDao clusterDetailsDao;
@Inject
protected HostPodDao hostPodDao;
@@ -269,33 +266,21 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
}
@Override
- public boolean computeWhetherClusterSupportsResigning(long clusterId) {
+ public boolean getSupportsResigning(long clusterId) {
ClusterVO cluster = findById(clusterId);
if (cluster == null || cluster.getAllocationState() != Grouping.AllocationState.Enabled) {
return false;
}
- List<HostVO> hosts = hostDao.findByClusterId(clusterId);
-
- if (hosts == null) {
- return false;
- }
-
- Map<Long, String> mapSupportsResign = hostDetailsDao.findDetails("supportsResign");
-
- for (HostVO host : hosts) {
- if (host == null) {
- return false;
- }
+ ClusterDetailsVO clusterDetailsVO = clusterDetailsDao.findDetail(clusterId, "supportsResign");
- String value = mapSupportsResign.get(host.getId());
+ if (clusterDetailsVO != null) {
+ String value = clusterDetailsVO.getValue();
- if (Boolean.parseBoolean(value) == false) {
- return false;
- }
+ return Boolean.parseBoolean(value);
}
- return true;
+ return false;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/engine/schema/src/com/cloud/host/dao/HostDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/host/dao/HostDetailsDao.java b/engine/schema/src/com/cloud/host/dao/HostDetailsDao.java
index 77e45dd..7f1a618 100644
--- a/engine/schema/src/com/cloud/host/dao/HostDetailsDao.java
+++ b/engine/schema/src/com/cloud/host/dao/HostDetailsDao.java
@@ -24,8 +24,6 @@ import com.cloud.utils.db.GenericDao;
public interface HostDetailsDao extends GenericDao<DetailVO, Long> {
Map<String, String> findDetails(long hostId);
- Map<Long, String> findDetails(String name);
-
void persist(long hostId, Map<String, String> details);
DetailVO findDetail(long hostId, String name);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/engine/schema/src/com/cloud/host/dao/HostDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/host/dao/HostDetailsDaoImpl.java b/engine/schema/src/com/cloud/host/dao/HostDetailsDaoImpl.java
index 525ee9a..b864a59 100644
--- a/engine/schema/src/com/cloud/host/dao/HostDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/host/dao/HostDetailsDaoImpl.java
@@ -37,7 +37,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implements HostDetailsDao {
protected final SearchBuilder<DetailVO> HostSearch;
protected final SearchBuilder<DetailVO> DetailSearch;
- protected final SearchBuilder<DetailVO> NameSearch;
public HostDetailsDaoImpl() {
HostSearch = createSearchBuilder();
@@ -48,10 +47,6 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
DetailSearch.and("hostId", DetailSearch.entity().getHostId(), SearchCriteria.Op.EQ);
DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
DetailSearch.done();
-
- NameSearch = createSearchBuilder();
- NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
- NameSearch.done();
}
@Override
@@ -89,27 +84,6 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
}
@Override
- public Map<Long, String> findDetails(String name) {
- SearchCriteria<DetailVO> sc = NameSearch.create();
-
- sc.setParameters("name", name);
-
- List<DetailVO> results = search(sc, null);
-
- Map<Long, String> details = new HashMap<>(results.size());
-
- for (DetailVO result : results) {
- if ("password".equals(result.getName())) {
- details.put(result.getHostId(), DBEncryptionUtil.decrypt(result.getValue()));
- } else {
- details.put(result.getHostId(), result.getValue());
- }
- }
-
- return details;
- }
-
- @Override
public void deleteDetails(long hostId) {
SearchCriteria sc = HostSearch.create();
sc.setParameters("hostId", hostId);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
index adb1720..7a59ad0 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
@@ -291,7 +291,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
HostVO hostVO = getHost(snapshotInfo);
boolean usingBackendSnapshot = usingBackendSnapshotFor(snapshotInfo);
- boolean computeClusterSupportsResign = clusterDao.computeWhetherClusterSupportsResigning(hostVO.getClusterId());
+ boolean computeClusterSupportsResign = clusterDao.getSupportsResigning(hostVO.getClusterId());
if (usingBackendSnapshot && !computeClusterSupportsResign) {
String noSupportForResignErrMsg = "Unable to locate an applicable host with which to perform a resignature operation : Cluster ID = " + hostVO.getClusterId();
@@ -399,7 +399,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
throw new CloudRuntimeException("Unable to locate a host capable of resigning in the zone with the following ID: " + volumeInfo.getDataCenterId());
}
- boolean computeClusterSupportsResign = clusterDao.computeWhetherClusterSupportsResigning(hostVO.getClusterId());
+ boolean computeClusterSupportsResign = clusterDao.getSupportsResigning(hostVO.getClusterId());
if (!computeClusterSupportsResign) {
String noSupportForResignErrMsg = "Unable to locate an applicable host with which to perform a resignature operation : Cluster ID = " + hostVO.getClusterId();
@@ -467,7 +467,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
HostVO hostVO = getHost(snapshotInfo);
boolean usingBackendSnapshot = usingBackendSnapshotFor(snapshotInfo);
- boolean computeClusterSupportsResign = clusterDao.computeWhetherClusterSupportsResigning(hostVO.getClusterId());
+ boolean computeClusterSupportsResign = clusterDao.getSupportsResigning(hostVO.getClusterId());
if (usingBackendSnapshot && !computeClusterSupportsResign) {
String noSupportForResignErrMsg = "Unable to locate an applicable host with which to perform a resignature operation : Cluster ID = " + hostVO.getClusterId();
@@ -711,7 +711,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
continue;
}
- if (clusterDao.computeWhetherClusterSupportsResigning(clusterId)) {
+ if (clusterDao.getSupportsResigning(clusterId)) {
return host;
}
else {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
index d74ee57..02691ff 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
@@ -186,7 +186,7 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
HostVO hostVO = getHost(volumeInfo.getId());
boolean canStorageSystemCreateVolumeFromSnapshot = canStorageSystemCreateVolumeFromSnapshot(volumeInfo.getPoolId());
- boolean computeClusterSupportsResign = clusterDao.computeWhetherClusterSupportsResigning(hostVO.getClusterId());
+ boolean computeClusterSupportsResign = clusterDao.getSupportsResigning(hostVO.getClusterId());
// if canStorageSystemCreateVolumeFromSnapshot && computeClusterSupportsResign, then take a back-end snapshot or create a back-end clone;
// else, just create a new back-end volume (eventually used to create a new SR on and to copy a VDI to)
@@ -468,7 +468,7 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
for (HostVO host : hosts) {
if (host.getResourceState() == ResourceState.Enabled) {
if (computeClusterMustSupportResign) {
- if (clusterDao.computeWhetherClusterSupportsResigning(cluster.getId())) {
+ if (clusterDao.getSupportsResigning(cluster.getId())) {
return Optional.of(host);
}
else {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/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 54e5105..05ec7d0 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
@@ -1093,7 +1093,7 @@ public class VolumeServiceImpl implements VolumeService {
for (HostVO host : hosts) {
if (host.getResourceState() == ResourceState.Enabled) {
if (computeClusterMustSupportResign) {
- if (clusterDao.computeWhetherClusterSupportsResigning(cluster.getId())) {
+ if (clusterDao.getSupportsResigning(cluster.getId())) {
return host;
}
else {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 0b59e39..0689b81 100644
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -1736,7 +1736,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
if (startup instanceof StartupRoutingCommand) {
final StartupRoutingCommand ssCmd = (StartupRoutingCommand)startup;
- updateHostDetails(host, ssCmd);
+ updateSupportsClonedVolumes(host, ssCmd.getSupportsClonedVolumes());
}
try {
@@ -1756,21 +1756,61 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
return host;
}
- private void updateHostDetails(HostVO host, StartupRoutingCommand startupRoutingCmd) {
+ private void updateSupportsClonedVolumes(HostVO host, boolean supportsClonedVolumes) {
final String name = "supportsResign";
- final String value = String.valueOf(startupRoutingCmd.getSupportsClonedVolumes());
DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), name);
if (hostDetail != null) {
- hostDetail.setValue(value);
+ if (supportsClonedVolumes) {
+ hostDetail.setValue(Boolean.TRUE.toString());
- _hostDetailsDao.update(hostDetail.getId(), hostDetail);
+ _hostDetailsDao.update(hostDetail.getId(), hostDetail);
+ }
+ else {
+ _hostDetailsDao.remove(hostDetail.getId());
+ }
}
else {
- hostDetail = new DetailVO(host.getId(), name, value);
+ if (supportsClonedVolumes) {
+ hostDetail = new DetailVO(host.getId(), name, Boolean.TRUE.toString());
+
+ _hostDetailsDao.persist(hostDetail);
+ }
+ }
+
+ boolean clusterSupportsResigning = true;
- _hostDetailsDao.persist(hostDetail);
+ List<HostVO> hostVOs = _hostDao.findByClusterId(host.getClusterId());
+
+ for (HostVO hostVO : hostVOs) {
+ DetailVO hostDetailVO = _hostDetailsDao.findDetail(hostVO.getId(), name);
+
+ if (hostDetailVO == null || Boolean.parseBoolean(hostDetailVO.getValue()) == false) {
+ clusterSupportsResigning = false;
+
+ break;
+ }
+ }
+
+ ClusterDetailsVO clusterDetailsVO = _clusterDetailsDao.findDetail(host.getClusterId(), name);
+
+ if (clusterDetailsVO != null) {
+ if (clusterSupportsResigning) {
+ clusterDetailsVO.setValue(Boolean.TRUE.toString());
+
+ _clusterDetailsDao.update(clusterDetailsVO.getId(), clusterDetailsVO);
+ }
+ else {
+ _clusterDetailsDao.remove(clusterDetailsVO.getId());
+ }
+ }
+ else {
+ if (clusterSupportsResigning) {
+ clusterDetailsVO = new ClusterDetailsVO(host.getClusterId(), name, Boolean.TRUE.toString());
+
+ _clusterDetailsDao.persist(clusterDetailsVO);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d215562/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index 331f09e..0c56d2d 100644
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -1751,7 +1751,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
// This next call leads to CloudStack asking how many more bytes it will need for the template (if the template is
// already stored on the primary storage, then the answer is 0).
- if (clusterId != null && _clusterDao.computeWhetherClusterSupportsResigning(clusterId)) {
+ if (clusterId != null && _clusterDao.getSupportsResigning(clusterId)) {
totalAskingSize += getBytesRequiredForTemplate(tmpl, pool);
}
}