-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scheduler: move more to internaltypes.ResourceList (#4036)
- Loading branch information
1 parent
4416515
commit 43f8573
Showing
32 changed files
with
865 additions
and
683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
internal/scheduler/internaltypes/resource_list_map_util.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package internaltypes | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/armadaproject/armada/internal/scheduler/schedulerobjects" | ||
) | ||
|
||
func RlMapToString(m map[string]ResourceList) string { | ||
results := []string{} | ||
for k, v := range m { | ||
results = append(results, k+"="+v.String()) | ||
} | ||
return strings.Join(results, " ") | ||
} | ||
|
||
func RlMapSumValues(m map[string]ResourceList) ResourceList { | ||
result := ResourceList{} | ||
for _, v := range m { | ||
result = result.Add(v) | ||
} | ||
return result | ||
} | ||
|
||
func RlMapAllZero(m map[string]ResourceList) bool { | ||
for _, v := range m { | ||
if !v.AllZero() { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
|
||
func RlMapHasNegativeValues(m map[string]ResourceList) bool { | ||
for _, v := range m { | ||
if v.HasNegativeValues() { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func RlMapFromJobSchedulerObjects(m schedulerobjects.QuantityByTAndResourceType[string], rlFactory *ResourceListFactory) map[string]ResourceList { | ||
result := map[string]ResourceList{} | ||
for k, v := range m { | ||
result[k] = rlFactory.FromJobResourceListIgnoreUnknown(v.Resources) | ||
} | ||
return result | ||
} | ||
|
||
func RlMapRemoveZeros(m map[string]ResourceList) map[string]ResourceList { | ||
result := map[string]ResourceList{} | ||
for k, v := range m { | ||
if !v.AllZero() { | ||
result[k] = v | ||
} | ||
} | ||
return result | ||
} |
Oops, something went wrong.