github-actions[bot] commented on code in PR #29116: URL: https://github.com/apache/doris/pull/29116#discussion_r1437010338
########## be/src/runtime/workload_management/workload_sched_policy.h: ########## @@ -0,0 +1,59 @@ +// 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. + +#pragma once + +#include <vector> + +#include "runtime/workload_management/workload_action.h" +#include "runtime/workload_management/workload_condition.h" + +namespace doris { + +class WorkloadSchedPolicy { +public: + WorkloadSchedPolicy() = default; + ~WorkloadSchedPolicy() = default; + + void init(int64_t id, std::string name, int version, bool enabled, int priority, + std::vector<std::unique_ptr<WorkloadCondition>> condition_list, + std::vector<std::unique_ptr<WorkloadAction>> action_list); + + bool enabled() { return _enabled; } Review Comment: warning: method 'enabled' can be made const [readability-make-member-function-const] ```suggestion bool enabled() const { return _enabled; } ``` ########## be/src/runtime/workload_management/workload_sched_policy_mgr.cpp: ########## @@ -0,0 +1,131 @@ +// 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 "runtime/workload_management/workload_sched_policy_mgr.h" + +#include "runtime/fragment_mgr.h" + +namespace doris { + +void WorkloadSchedPolicyMgr::start(ExecEnv* exec_env) { + _stop_latch.reset(1); + _exec_env = exec_env; + + Status st; + st = Thread::create( + "workload", "workload_scheduler", [this]() { this->_schedule_workload(); }, &_thread); + if (!st.ok()) { + LOG(WARNING) << "create workload scheduler thread failed"; + } else { + LOG(INFO) << "start workload scheduler "; + } +} + +void WorkloadSchedPolicyMgr::stop() { + std::lock_guard<std::shared_mutex> write_lock(_stop_lock); + if (_stop_latch.count() == 0) { + LOG(INFO) << "workload schedule manager is already stopped. "; + return; + } + _stop_latch.count_down(); + if (_thread) { + _thread->join(); + } + LOG(INFO) << "workload schedule manager stopped, thread is finished. "; +} + +void WorkloadSchedPolicyMgr::update_workload_sched_policy( Review Comment: warning: method 'update_workload_sched_policy' can be made static [readability-convert-member-functions-to-static] ```suggestion static void WorkloadSchedPolicyMgr::update_workload_sched_policy( ``` ########## be/src/runtime/workload_management/workload_sched_policy.h: ########## @@ -0,0 +1,59 @@ +// 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. + +#pragma once + +#include <vector> + +#include "runtime/workload_management/workload_action.h" +#include "runtime/workload_management/workload_condition.h" + +namespace doris { + +class WorkloadSchedPolicy { +public: + WorkloadSchedPolicy() = default; + ~WorkloadSchedPolicy() = default; + + void init(int64_t id, std::string name, int version, bool enabled, int priority, + std::vector<std::unique_ptr<WorkloadCondition>> condition_list, + std::vector<std::unique_ptr<WorkloadAction>> action_list); + + bool enabled() { return _enabled; } + int priority() { return _priority; } Review Comment: warning: method 'priority' can be made const [readability-make-member-function-const] ```suggestion int priority() const { return _priority; } ``` ########## be/src/runtime/workload_management/workload_sched_policy.h: ########## @@ -0,0 +1,59 @@ +// 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. + +#pragma once + +#include <vector> + +#include "runtime/workload_management/workload_action.h" +#include "runtime/workload_management/workload_condition.h" + +namespace doris { + +class WorkloadSchedPolicy { +public: + WorkloadSchedPolicy() = default; + ~WorkloadSchedPolicy() = default; + + void init(int64_t id, std::string name, int version, bool enabled, int priority, + std::vector<std::unique_ptr<WorkloadCondition>> condition_list, + std::vector<std::unique_ptr<WorkloadAction>> action_list); + + bool enabled() { return _enabled; } + int priority() { return _priority; } + + bool is_match(WorkloadQueryInfo* query_info); + + WorkloadActionType get_first_action_type() { return _first_action_type; } + + void exec_action(WorkloadQueryInfo* query_info); + + int version() { return _version; } Review Comment: warning: method 'version' can be made const [readability-make-member-function-const] ```suggestion int version() const { return _version; } ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org