Skip to content

Commit 6f64dae

Browse files
author
Eugenio Grosso
committed
flasharray: drop array-capacity cache per review
winterhazel noted the array-total-capacity cache is unnecessary: getManagedStorageStats() is polled only every 60s by default, so the extra GET /arrays?space=true per poll (only when a pod has no quota) is negligible and not worth the static shared-state cache. Remove the cache and its helper class; getArrayTotalCapacity() now does a direct lookup. Signed-off-by: Eugenio Grosso <eugenio.grosso@gmail.com>
1 parent dca606b commit 6f64dae

1 file changed

Lines changed: 1 addition & 33 deletions

File tree

  • plugins/storage/volume/flasharray/src/main/java/org/apache/cloudstack/storage/datastore/adapter/flasharray

plugins/storage/volume/flasharray/src/main/java/org/apache/cloudstack/storage/datastore/adapter/flasharray/FlashArrayAdapter.java

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import java.text.SimpleDateFormat;
2727
import java.util.ArrayList;
2828
import java.util.HashMap;
29-
import java.util.concurrent.ConcurrentHashMap;
30-
import java.util.concurrent.ConcurrentMap;
3129
import java.util.Map;
3230

3331
import javax.net.ssl.HostnameVerifier;
@@ -478,45 +476,15 @@ public ProviderVolumeStorageStats getManagedStorageStats() {
478476
return stats;
479477
}
480478

481-
/**
482-
* Cache of array total capacity keyed by FlashArray URL. The capacity of a
483-
* physical FlashArray changes only when hardware is added or removed, so a
484-
* several-minute TTL is safe and avoids an extra REST call on every
485-
* storage stats refresh for every pool that has no pod quota set.
486-
*/
487-
private static final ConcurrentMap<String, CachedCapacity> ARRAY_CAPACITY_CACHE = new ConcurrentHashMap<>();
488-
private static final long ARRAY_CAPACITY_CACHE_TTL_MS = 5L * 60L * 1000L;
489-
490-
private static final class CachedCapacity {
491-
final long capacityBytes;
492-
final long expiresAtMs;
493-
494-
CachedCapacity(long capacityBytes, long ttlMs) {
495-
this.capacityBytes = capacityBytes;
496-
this.expiresAtMs = System.currentTimeMillis() + ttlMs;
497-
}
498-
499-
boolean isExpired() {
500-
return System.currentTimeMillis() > expiresAtMs;
501-
}
502-
}
503-
504479
private Long getArrayTotalCapacity() {
505-
CachedCapacity cached = ARRAY_CAPACITY_CACHE.get(this.url);
506-
if (cached != null && !cached.isExpired()) {
507-
return cached.capacityBytes;
508-
}
509480
try {
510481
FlashArrayList<Map<String, Object>> list = GET("/arrays?space=true",
511482
new TypeReference<FlashArrayList<Map<String, Object>>>() {
512483
});
513484
if (list != null && CollectionUtils.isNotEmpty(list.getItems())) {
514485
Object cap = list.getItems().get(0).get("capacity");
515486
if (cap instanceof Number) {
516-
long capacityBytes = ((Number) cap).longValue();
517-
ARRAY_CAPACITY_CACHE.put(this.url,
518-
new CachedCapacity(capacityBytes, ARRAY_CAPACITY_CACHE_TTL_MS));
519-
return capacityBytes;
487+
return ((Number) cap).longValue();
520488
}
521489
}
522490
} catch (Exception e) {

0 commit comments

Comments
 (0)