Skip to content

Commit

Permalink
add purr scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
darkgrey1554 committed Jan 31, 2025
1 parent b43c31a commit dee819a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,42 @@
"vip": "10.0.0.3",
"proto": "udp",
"vport": "80",
"scheduler": "rr",
"pure_round_robin": true,
"scheduler": "purr",
"ops": true,
"reals": [
{
"ip": "2000::1",
"port": "80"
"port": "80",
"weight": "1"
},
{
"ip": "2000::2",
"port": "80"
"port": "80",
"weight": "1"
},
{
"ip": "2000::3",
"port": "80"
"port": "80",
"weight": "1"
}
]
},
{
"vip": "10.0.0.3",
"proto": "udp",
"vport": "81",
"scheduler": "rr",
"scheduler": "wrr",
"ops": true,
"reals": [
{
"ip": "2000::1",
"port": "81"
"port": "81",
"weight": "1"
},
{
"ip": "2000::2",
"port": "81"
"port": "81",
"weight": "1"
}
]
}
Expand Down
14 changes: 7 additions & 7 deletions controlplane/configparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,7 @@ void config_parser_t::loadConfig_balancer_services(controlplane::base_t& baseNex

balancer::scheduler scheduler{};
balancer::scheduler_params scheduler_params{};
uint8_t flags = 0;
if (scheduler_string == "rr")
{
scheduler = balancer::scheduler::rr;
Expand All @@ -1667,7 +1668,12 @@ void config_parser_t::loadConfig_balancer_services(controlplane::base_t& baseNex
scheduler_params.wlc_power = std::stoll(service_json["scheduler_params"]["wlc_power"].get<std::string>(), nullptr, 10);
}
}
else
else if(scheduler_string == "purr")
{
scheduler = balancer::scheduler::wrr;
flags |= YANET_BALANCER_PURE_ROUND_ROBIN;
}
else
{
throw error_result_t(eResult::invalidConfigurationFile, "unknown scheduler: " + scheduler_string);
}
Expand Down Expand Up @@ -1725,7 +1731,6 @@ void config_parser_t::loadConfig_balancer_services(controlplane::base_t& baseNex
throw error_result_t(eResult::invalidConfigurationFile, "unknown proto");
}

uint8_t flags = 0;
if (service_json.value("mss_fix", false) == true)
{
flags |= YANET_BALANCER_FIX_MSS_FLAG;
Expand All @@ -1743,11 +1748,6 @@ void config_parser_t::loadConfig_balancer_services(controlplane::base_t& baseNex
flags |= YANET_BALANCER_OPS_FLAG;
}

if (service_json.value("pure_round_robin", false))
{
flags |= YANET_BALANCER_PURE_ROUND_ROBIN;
}

balancer.services.emplace_back(baseNext.services_count + 1, ///< 0 is invalid id
service_json["vip"].get<std::string>(),
proto,
Expand Down

0 comments on commit dee819a

Please sign in to comment.