File tree Expand file tree Collapse file tree 5 files changed +9
-13
lines changed Expand file tree Collapse file tree 5 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -262,7 +262,7 @@ message TaskInfo {
262
262
string username = 15 ;
263
263
string qos = 16 ;
264
264
ResourceView res_view = 17 ;
265
- string licenses = 18 ;
265
+ map < string , uint32 > licenses_count = 18 ;
266
266
repeated string req_nodes = 19 ;
267
267
repeated string exclude_nodes = 20 ;
268
268
Original file line number Diff line number Diff line change @@ -600,14 +600,10 @@ struct TaskInCtld {
600
600
task_info->set_partition (partition_id);
601
601
task_info->set_qos (qos);
602
602
603
- // lic_map -> "lic1:1,lic2:3"
604
- auto license_strings =
605
- licenses_count | ranges::views::transform ([](const auto & pair) {
606
- return pair.first + " :" + std::to_string (pair.second );
607
- });
608
- std::string licenses_view =
609
- license_strings | ranges::views::join (' ,' ) | ranges::to<std::string>();
610
- task_info->set_licenses (licenses_view);
603
+ for (const auto & [license_name, license_count] : licenses_count) {
604
+ task_info->mutable_licenses_count ()->insert (
605
+ {license_name, license_count});
606
+ }
611
607
612
608
task_info->mutable_time_limit ()->set_seconds (ToInt64Seconds (time_limit));
613
609
task_info->mutable_submit_time ()->CopyFrom (runtime_attr.submit_time ());
Original file line number Diff line number Diff line change @@ -73,13 +73,13 @@ bool LicensesManager::CheckLicenseCountSufficient(
73
73
return true ;
74
74
}
75
75
76
- result::result <void , std::string> LicensesManager::CheckLicensesLegal (
76
+ std::expected <void , std::string> LicensesManager::CheckLicensesLegal (
77
77
const ::google::protobuf::Map<std::string, uint32_t >& lic_id_to_count_map) {
78
78
util::read_lock_guard readLock (rw_mutex_);
79
79
for (auto & [lic_id, count] : lic_id_to_count_map) {
80
80
auto it = lic_id_to_lic_map_.find (lic_id);
81
81
if (it == lic_id_to_lic_map_.end () || count > it->second .total ) {
82
- return result::fail (" Invalid license specification" );
82
+ return std::unexpected (" Invalid license specification" );
83
83
}
84
84
}
85
85
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ class LicensesManager {
41
41
bool CheckLicenseCountSufficient (
42
42
const std::unordered_map<LicenseId, uint32_t > &lic_id_to_count_map);
43
43
44
- result::result <void , std::string> CheckLicensesLegal (
44
+ std::expected <void , std::string> CheckLicensesLegal (
45
45
const ::google::protobuf::Map<std::string, uint32_t >
46
46
&lic_id_to_count_map);
47
47
Original file line number Diff line number Diff line change @@ -2561,7 +2561,7 @@ CraneErr TaskScheduler::AcquireTaskAttributes(TaskInCtld* task) {
2561
2561
2562
2562
auto check_licenses_result = g_licenses_manager->CheckLicensesLegal (
2563
2563
task->TaskToCtld ().licenses_count ());
2564
- if (check_licenses_result. has_error () ) {
2564
+ if (! check_licenses_result) {
2565
2565
CRANE_ERROR (" Failed to call CheckLicensesLegal: {}" ,
2566
2566
check_licenses_result.error ());
2567
2567
You can’t perform that action at this time.
0 commit comments