sureshanaparti commented on code in PR #8557:
URL: https://github.com/apache/cloudstack/pull/8557#discussion_r1464336958
##########
engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java:
##########
@@ -179,52 +179,24 @@ public DataStore getRandomImageStore(List<DataStore>
imageStores) {
@Override
public DataStore getImageStoreWithFreeCapacity(List<DataStore>
imageStores) {
- if (imageStores.size() > 1) {
- imageStores.sort(new Comparator<DataStore>() { // Sort data stores
based on free capacity
- @Override
- public int compare(DataStore store1, DataStore store2) {
- return
Long.compare(_statsCollector.imageStoreCurrentFreeCapacity(store1),
-
_statsCollector.imageStoreCurrentFreeCapacity(store2));
- }
- });
- for (DataStore imageStore : imageStores) {
- // Return image store if used percentage is less then
threshold value i.e. 90%.
- if (_statsCollector.imageStoreHasEnoughCapacity(imageStore)) {
- return imageStore;
- }
- }
- } else if (imageStores.size() == 1) {
- if
(_statsCollector.imageStoreHasEnoughCapacity(imageStores.get(0))) {
- return imageStores.get(0);
- }
+ List<DataStore> orderedImageStores =
orderImageStoresOnFreeCapacity(imageStores);
Review Comment:
@GaOrtiga see if you can return image store with enough capacity as soon as
one found (as earlier at line#193), no need to check all the stores for enough
capacity.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]