blob: 360864208c445e9bc61e49ef6552fb01f3315ec4 [file]
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "cloud/cloud_ms_rpc_rate_limit_services.h"
#include "cloud/cloud_ms_backpressure_handler.h"
#include "cloud/cloud_ms_rpc_rate_limiters.h"
namespace doris {
MSRpcRateLimitServices::MSRpcRateLimitServices()
: _host_level_ms_rpc_rate_limiters(std::make_unique<cloud::HostLevelMSRpcRateLimiters>()),
_table_rpc_qps_registry(std::make_unique<cloud::TableRpcQpsRegistry>()),
_table_rpc_throttler(std::make_unique<cloud::TableRpcThrottler>()),
_ms_backpressure_handler(std::make_unique<cloud::MSBackpressureHandler>(
_table_rpc_qps_registry.get(), _table_rpc_throttler.get())) {}
MSRpcRateLimitServices::~MSRpcRateLimitServices() = default;
void MSRpcRateLimitServices::reset_host_level_rate_limiters() {
_host_level_ms_rpc_rate_limiters->reset_all();
}
void MSRpcRateLimitServices::update_backpressure_throttle_params(int top_k, double ratio,
double floor_qps) {
_ms_backpressure_handler->update_throttle_params({
.top_k = top_k,
.ratio = ratio,
.floor_qps = floor_qps,
});
}
void MSRpcRateLimitServices::update_backpressure_coordinator_params(int upgrade_cooldown_ticks,
int downgrade_after_ticks) {
_ms_backpressure_handler->update_coordinator_params({
.upgrade_cooldown_ticks = upgrade_cooldown_ticks,
.downgrade_after_ticks = downgrade_after_ticks,
});
}
} // namespace doris