Skip to content

Commit 5bcb6ec

Browse files
author
Mike Tutkowski
committed
Changes related to Review Board comments
1 parent 8f4575e commit 5bcb6ec

3 files changed

Lines changed: 130 additions & 36 deletions

File tree

‎plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java‎

Lines changed: 74 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.apache.cloudstack.storage.datastore.driver;
1818

1919
import java.util.List;
20-
import java.util.Set;
2120

2221
import javax.inject.Inject;
2322

@@ -29,15 +28,13 @@
2928
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
3029
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
3130
import org.apache.cloudstack.storage.datastore.util.SolidFireUtil;
32-
import org.apache.log4j.Logger;
31+
import org.apache.commons.lang.StringUtils;
3332

3433
import com.cloud.agent.api.Answer;
3534
import com.cloud.agent.api.to.DataObjectType;
3635
import com.cloud.agent.api.to.DataStoreTO;
3736
import com.cloud.agent.api.to.DataTO;
3837
import com.cloud.dc.dao.DataCenterDao;
39-
import com.cloud.utils.exception.CloudRuntimeException;
40-
import com.cloud.exception.StorageUnavailableException;
4138
import com.cloud.storage.Storage.StoragePoolType;
4239
import com.cloud.storage.VolumeVO;
4340
import com.cloud.storage.dao.VolumeDao;
@@ -48,8 +45,6 @@
4845
import com.cloud.user.dao.AccountDao;
4946

5047
public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
51-
private static final Logger s_logger = Logger.getLogger(SolidfirePrimaryDataStoreDriver.class);
52-
5348
@Inject private PrimaryDataStoreDao _storagePoolDao;
5449
@Inject private StoragePoolDetailsDao _storagePoolDetailsDao;
5550
@Inject private VolumeDao _volumeDao;
@@ -220,6 +215,32 @@ public ChapInfo getChapInfo(VolumeInfo volumeInfo) {
220215
chapTargetUsername, chapTargetSecret);
221216
}
222217

218+
private long getDefaultMinIops(long storagePoolId) {
219+
StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS);
220+
221+
String clusterDefaultMinIops = storagePoolDetail.getValue();
222+
223+
return Long.parseLong(clusterDefaultMinIops);
224+
}
225+
226+
private long getDefaultMaxIops(long storagePoolId) {
227+
StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS);
228+
229+
String clusterDefaultMaxIops = storagePoolDetail.getValue();
230+
231+
return Long.parseLong(clusterDefaultMaxIops);
232+
}
233+
234+
private long getDefaultBurstIops(long storagePoolId, long maxIops) {
235+
StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS);
236+
237+
String clusterDefaultBurstIopsPercentOfMaxIops = storagePoolDetail.getValue();
238+
239+
float fClusterDefaultBurstIopsPercentOfMaxIops = Float.parseFloat(clusterDefaultBurstIopsPercentOfMaxIops);
240+
241+
return (long)(maxIops * fClusterDefaultBurstIopsPercentOfMaxIops);
242+
}
243+
223244
private SolidFireUtil.SolidFireVolume createSolidFireVolume(VolumeInfo volumeInfo, SolidFireConnection sfConnection)
224245
{
225246
String mVip = sfConnection.getManagementVip();
@@ -230,46 +251,72 @@ private SolidFireUtil.SolidFireVolume createSolidFireVolume(VolumeInfo volumeInf
230251
AccountDetailVO accountDetail = _accountDetailsDao.findDetail(volumeInfo.getAccountId(), SolidFireUtil.ACCOUNT_ID);
231252
long sfAccountId = Long.parseLong(accountDetail.getValue());
232253

254+
long storagePoolId = volumeInfo.getDataStore().getId();
255+
233256
final Iops iops;
234257

235258
Long minIops = volumeInfo.getMinIops();
236259
Long maxIops = volumeInfo.getMaxIops();
237260

238261
if (minIops == null || minIops <= 0 ||
239262
maxIops == null || maxIops <= 0) {
240-
iops = new Iops(100, 15000);
263+
long defaultMaxIops = getDefaultMaxIops(storagePoolId);
264+
265+
iops = new Iops(getDefaultMinIops(storagePoolId), defaultMaxIops, getDefaultBurstIops(storagePoolId, defaultMaxIops));
241266
}
242267
else {
243-
iops = new Iops(volumeInfo.getMinIops(), volumeInfo.getMaxIops());
268+
iops = new Iops(volumeInfo.getMinIops(), volumeInfo.getMaxIops(), getDefaultBurstIops(storagePoolId, volumeInfo.getMaxIops()));
244269
}
245270

246271
long sfVolumeId = SolidFireUtil.createSolidFireVolume(mVip, mPort, clusterAdminUsername, clusterAdminPassword,
247-
volumeInfo.getName(), sfAccountId, volumeInfo.getSize(), true,
272+
getSolidFireVolumeName(volumeInfo.getName()), sfAccountId, volumeInfo.getSize(), true,
248273
iops.getMinIops(), iops.getMaxIops(), iops.getBurstIops());
249274

250275
return SolidFireUtil.getSolidFireVolume(mVip, mPort, clusterAdminUsername, clusterAdminPassword, sfVolumeId);
251276
}
252277

278+
private String getSolidFireVolumeName(String strCloudStackVolumeName) {
279+
final String specialChar = "-";
280+
281+
StringBuilder strSolidFireVolumeName = new StringBuilder();
282+
283+
for (int i = 0; i < strCloudStackVolumeName.length(); i++) {
284+
String strChar = strCloudStackVolumeName.substring(i, i + 1);
285+
286+
if (StringUtils.isAlphanumeric(strChar)) {
287+
strSolidFireVolumeName.append(strChar);
288+
}
289+
else {
290+
strSolidFireVolumeName.append(specialChar);
291+
}
292+
}
293+
294+
return strSolidFireVolumeName.toString();
295+
}
296+
253297
private static class Iops
254298
{
255-
private final long _minIops;
256-
private final long _maxIops;
257-
private final long _burstIops;
299+
private final long _minIops;
300+
private final long _maxIops;
301+
private final long _burstIops;
258302

259-
public Iops(long minIops, long maxIops) throws IllegalArgumentException
260-
{
261-
if (minIops <= 0 || maxIops <= 0) {
262-
throw new IllegalArgumentException("The 'Min IOPS' and 'Max IOPS' values must be greater than 0.");
263-
}
303+
public Iops(long minIops, long maxIops, long burstIops) throws IllegalArgumentException
304+
{
305+
if (minIops <= 0 || maxIops <= 0) {
306+
throw new IllegalArgumentException("The 'Min IOPS' and 'Max IOPS' values must be greater than 0.");
307+
}
264308

265309
if (minIops > maxIops) {
266310
throw new IllegalArgumentException("The 'Min IOPS' value cannot exceed the 'Max IOPS' value.");
267311
}
268312

313+
if (maxIops > burstIops) {
314+
throw new IllegalArgumentException("The 'Max IOPS' value cannot exceed the 'Burst IOPS' value.");
315+
}
316+
269317
_minIops = minIops;
270318
_maxIops = maxIops;
271-
272-
_burstIops = getBurstIops(_maxIops);
319+
_burstIops = burstIops;
273320
}
274321

275322
public long getMinIops()
@@ -286,11 +333,6 @@ public long getBurstIops()
286333
{
287334
return _burstIops;
288335
}
289-
290-
private static long getBurstIops(long maxIops)
291-
{
292-
return (long)(maxIops * 1.5);
293-
}
294336
}
295337

296338
private void deleteSolidFireVolume(VolumeInfo volumeInfo, SolidFireConnection sfConnection)
@@ -448,14 +490,14 @@ public void deleteAsync(DataStore dataStore, DataObject dataObject,
448490

449491
_volumeDao.deleteVolumesByInstance(volumeInfo.getId());
450492

451-
if (!sfAccountHasVolume(sfAccountId, sfConnection)) {
452-
// delete the account from the SolidFire SAN
453-
deleteSolidFireAccount(sfAccountId, sfConnection);
454-
455-
// delete the info in the account_details table
456-
// that's related to the SolidFire account
457-
_accountDetailsDao.deleteDetails(account.getAccountId());
458-
}
493+
// if (!sfAccountHasVolume(sfAccountId, sfConnection)) {
494+
// // delete the account from the SolidFire SAN
495+
// deleteSolidFireAccount(sfAccountId, sfConnection);
496+
//
497+
// // delete the info in the account_details table
498+
// // that's related to the SolidFire account
499+
// _accountDetailsDao.deleteDetails(account.getAccountId());
500+
// }
459501

460502
StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);
461503

‎plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java‎

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,55 @@ public DataStore initialize(Map<String, Object> dsInfos) {
108108

109109
details.put(SolidFireUtil.CLUSTER_ADMIN_USERNAME, clusterAdminUsername);
110110
details.put(SolidFireUtil.CLUSTER_ADMIN_PASSWORD, clusterAdminPassword);
111-
111+
112+
long lClusterDefaultMinIops = 100;
113+
long lClusterDefaultMaxIops = 15000;
114+
float fClusterDefaultBurstIopsPercentOfMaxIops = 1.5f;
115+
116+
try {
117+
String clusterDefaultMinIops = getValue(SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS, url);
118+
119+
if (clusterDefaultMinIops != null && clusterDefaultMinIops.trim().length() > 0) {
120+
lClusterDefaultMinIops = Long.parseLong(clusterDefaultMinIops);
121+
}
122+
}
123+
catch (Exception ex) {
124+
}
125+
126+
try {
127+
String clusterDefaultMaxIops = getValue(SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS, url);
128+
129+
if (clusterDefaultMaxIops != null && clusterDefaultMaxIops.trim().length() > 0) {
130+
lClusterDefaultMaxIops = Long.parseLong(clusterDefaultMaxIops);
131+
}
132+
}
133+
catch (Exception ex) {
134+
}
135+
136+
try {
137+
String clusterDefaultBurstIopsPercentOfMaxIops = getValue(SolidFireUtil.CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS, url);
138+
139+
if (clusterDefaultBurstIopsPercentOfMaxIops != null && clusterDefaultBurstIopsPercentOfMaxIops.trim().length() > 0) {
140+
fClusterDefaultBurstIopsPercentOfMaxIops = Float.parseFloat(clusterDefaultBurstIopsPercentOfMaxIops);
141+
}
142+
}
143+
catch (Exception ex) {
144+
}
145+
146+
if (lClusterDefaultMinIops > lClusterDefaultMaxIops) {
147+
throw new CloudRuntimeException("The parameter '" + SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS + "' must be less than " +
148+
"or equal to the parameter '" + SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS + "'.");
149+
}
150+
151+
if (Float.compare(fClusterDefaultBurstIopsPercentOfMaxIops, 1.0f) < 0) {
152+
throw new CloudRuntimeException("The parameter '" + SolidFireUtil.CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS +
153+
"' must be greater than or equal to 1.");
154+
}
155+
156+
details.put(SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS, String.valueOf(lClusterDefaultMinIops));
157+
details.put(SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS, String.valueOf(lClusterDefaultMaxIops));
158+
details.put(SolidFireUtil.CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS, String.valueOf(fClusterDefaultBurstIopsPercentOfMaxIops));
159+
112160
// this adds a row in the cloud.storage_pool table for this SolidFire cluster
113161
return dataStoreHelper.createPrimaryDataStore(parameters);
114162
}
@@ -123,10 +171,10 @@ private String getModifiedUrl(String originalUrl)
123171
StringTokenizer st = new StringTokenizer(originalUrl, delimiter);
124172

125173
while (st.hasMoreElements()) {
126-
String token = st.nextElement().toString();
174+
String token = st.nextElement().toString().toUpperCase();
127175

128-
if (!token.startsWith(SolidFireUtil.CLUSTER_ADMIN_USERNAME) &&
129-
!token.startsWith(SolidFireUtil.CLUSTER_ADMIN_PASSWORD)) {
176+
if (token.startsWith(SolidFireUtil.MANAGEMENT_VIP.toUpperCase()) ||
177+
token.startsWith(SolidFireUtil.STORAGE_VIP.toUpperCase())) {
130178
sb.append(token).append(delimiter);
131179
}
132180
}

‎plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public class SolidFireUtil
6363
public static final String CLUSTER_ADMIN_USERNAME = "clusterAdminUsername";
6464
public static final String CLUSTER_ADMIN_PASSWORD = "clusterAdminPassword";
6565

66+
public static final String CLUSTER_DEFAULT_MIN_IOPS = "clusterDefaultMinIops";
67+
public static final String CLUSTER_DEFAULT_MAX_IOPS = "clusterDefaultMaxIops";
68+
public static final String CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS = "clusterDefaultBurstIopsPercentOfMaxIops";
69+
6670
public static final String ACCOUNT_ID = "accountId";
6771

6872
public static final String CHAP_INITIATOR_USERNAME = "chapInitiatorUsername";

0 commit comments

Comments
 (0)