You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mt...@apache.org on 2015/01/28 03:08:05 UTC
git commit: updated refs/heads/master to c2330f4
Repository: cloudstack
Updated Branches:
refs/heads/master a696947ea -> c2330f48d
Replace synchronized with the use of database locking
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c2330f48
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c2330f48
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c2330f48
Branch: refs/heads/master
Commit: c2330f48dda1127ff0d4ea6a2fcc044259f8da36
Parents: a696947
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Tue Jan 27 15:46:34 2015 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Tue Jan 27 17:36:21 2015 -0700
----------------------------------------------------------------------
.../snapshot/StorageSystemSnapshotStrategy.java | 4 +-
.../driver/SolidFirePrimaryDataStoreDriver.java | 86 +++++++++++++-------
2 files changed, 58 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2330f48/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 90c7244..deec7fe 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
@@ -200,9 +200,7 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
volumeInfo.stateTransit(Volume.Event.OperationFailed);
}
- if (snapshotVO != null) {
- _snapshotDao.releaseFromLockTable(snapshotInfo.getId());
- }
+ _snapshotDao.releaseFromLockTable(snapshotInfo.getId());
}
return snapshotInfo;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2330f48/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 064bb1a..62a03a4 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
@@ -71,10 +71,12 @@ import com.cloud.user.AccountDetailVO;
import com.cloud.user.AccountDetailsDao;
import com.cloud.user.AccountVO;
import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.exception.CloudRuntimeException;
public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
private static final Logger s_logger = Logger.getLogger(SolidFirePrimaryDataStoreDriver.class);
+ private static final int s_lockTimeInSeconds = 300;
@Inject private AccountDao _accountDao;
@Inject private AccountDetailsDao _accountDetailsDao;
@@ -124,7 +126,7 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
// if the ID of volumeInfo in not in the VAG, add it (ModifyVolumeAccessGroup)
// if the VAG doesn't exist, create it with the IQNs of the hosts and the ID of volumeInfo (CreateVolumeAccessGroup)
@Override
- public synchronized boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore)
+ public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore)
{
if (dataObject == null || host == null || dataStore == null) {
return false;
@@ -134,40 +136,52 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
long clusterId = host.getClusterId();
long storagePoolId = dataStore.getId();
- ClusterDetailsVO clusterDetail = _clusterDetailsDao.findDetail(clusterId, SolidFireUtil.getVagKey(storagePoolId));
+ ClusterVO cluster = _clusterDao.findById(clusterId);
- String vagId = clusterDetail != null ? clusterDetail.getValue() : null;
+ GlobalLock lock = GlobalLock.getInternLock(cluster.getUuid());
- List<HostVO> hosts = _hostDao.findByClusterId(clusterId);
-
- if (!SolidFireUtil.hostsSupport_iScsi(hosts)) {
- return false;
+ if (!lock.lock(s_lockTimeInSeconds)) {
+ s_logger.debug("Couldn't lock the DB (in grantAccess) on the following string: " + cluster.getUuid());
}
- SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao);
+ try {
+ ClusterDetailsVO clusterDetail = _clusterDetailsDao.findDetail(clusterId, SolidFireUtil.getVagKey(storagePoolId));
- if (vagId != null) {
- SolidFireUtil.SolidFireVag sfVag = SolidFireUtil.getSolidFireVag(sfConnection, Long.parseLong(vagId));
+ String vagId = clusterDetail != null ? clusterDetail.getValue() : null;
- String[] hostIqns = SolidFireUtil.getNewHostIqns(sfVag.getInitiators(), SolidFireUtil.getIqnsFromHosts(hosts));
- long[] volumeIds = SolidFireUtil.getNewVolumeIds(sfVag.getVolumeIds(), sfVolumeId, true);
+ List<HostVO> hosts = _hostDao.findByClusterId(clusterId);
- SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), hostIqns, volumeIds);
- }
- else {
- ClusterVO cluster = _clusterDao.findById(clusterId);
+ if (!SolidFireUtil.hostsSupport_iScsi(hosts)) {
+ return false;
+ }
- SolidFireUtil.placeVolumeInVolumeAccessGroup(sfConnection, sfVolumeId, storagePoolId, cluster.getUuid(), hosts, _clusterDetailsDao);
- }
+ SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao);
+
+ if (vagId != null) {
+ SolidFireUtil.SolidFireVag sfVag = SolidFireUtil.getSolidFireVag(sfConnection, Long.parseLong(vagId));
+
+ String[] hostIqns = SolidFireUtil.getNewHostIqns(sfVag.getInitiators(), SolidFireUtil.getIqnsFromHosts(hosts));
+ long[] volumeIds = SolidFireUtil.getNewVolumeIds(sfVag.getVolumeIds(), sfVolumeId, true);
+
+ SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), hostIqns, volumeIds);
+ }
+ else {
+ SolidFireUtil.placeVolumeInVolumeAccessGroup(sfConnection, sfVolumeId, storagePoolId, cluster.getUuid(), hosts, _clusterDetailsDao);
+ }
- return true;
+ return true;
+ }
+ finally {
+ lock.unlock();
+ lock.releaseRef();
+ }
}
// get the VAG associated with volumeInfo's cluster, if any (ListVolumeAccessGroups) // might not exist if using CHAP
// if the VAG exists
// remove the ID of volumeInfo from the VAG (ModifyVolumeAccessGroup)
@Override
- public synchronized void revokeAccess(DataObject dataObject, Host host, DataStore dataStore)
+ public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore)
{
if (dataObject == null || host == null || dataStore == null) {
return;
@@ -177,21 +191,35 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
long clusterId = host.getClusterId();
long storagePoolId = dataStore.getId();
- ClusterDetailsVO clusterDetail = _clusterDetailsDao.findDetail(clusterId, SolidFireUtil.getVagKey(storagePoolId));
+ ClusterVO cluster = _clusterDao.findById(clusterId);
- String vagId = clusterDetail != null ? clusterDetail.getValue() : null;
+ GlobalLock lock = GlobalLock.getInternLock(cluster.getUuid());
- if (vagId != null) {
- List<HostVO> hosts = _hostDao.findByClusterId(clusterId);
+ if (!lock.lock(s_lockTimeInSeconds)) {
+ s_logger.debug("Couldn't lock the DB (in revokeAccess) on the following string: " + cluster.getUuid());
+ }
- SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao);
+ try {
+ ClusterDetailsVO clusterDetail = _clusterDetailsDao.findDetail(clusterId, SolidFireUtil.getVagKey(storagePoolId));
- SolidFireUtil.SolidFireVag sfVag = SolidFireUtil.getSolidFireVag(sfConnection, Long.parseLong(vagId));
+ String vagId = clusterDetail != null ? clusterDetail.getValue() : null;
- String[] hostIqns = SolidFireUtil.getNewHostIqns(sfVag.getInitiators(), SolidFireUtil.getIqnsFromHosts(hosts));
- long[] volumeIds = SolidFireUtil.getNewVolumeIds(sfVag.getVolumeIds(), sfVolumeId, false);
+ if (vagId != null) {
+ List<HostVO> hosts = _hostDao.findByClusterId(clusterId);
- SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), hostIqns, volumeIds);
+ SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao);
+
+ SolidFireUtil.SolidFireVag sfVag = SolidFireUtil.getSolidFireVag(sfConnection, Long.parseLong(vagId));
+
+ String[] hostIqns = SolidFireUtil.getNewHostIqns(sfVag.getInitiators(), SolidFireUtil.getIqnsFromHosts(hosts));
+ long[] volumeIds = SolidFireUtil.getNewVolumeIds(sfVag.getVolumeIds(), sfVolumeId, false);
+
+ SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), hostIqns, volumeIds);
+ }
+ }
+ finally {
+ lock.unlock();
+ lock.releaseRef();
}
}