github-actions[bot] commented on code in PR #29116:
URL: https://github.com/apache/doris/pull/29116#discussion_r1436712984


##########
be/src/agent/workload_sched_policy_listener.cpp:
##########
@@ -0,0 +1,61 @@
+// 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 "agent/workload_sched_policy_listener.h"
+
+#include "runtime/workload_management/workload_action.h"
+#include "runtime/workload_management/workload_condition.h"
+#include "runtime/workload_management/workload_sched_policy.h"
+#include "runtime/workload_management/workload_sched_policy_mgr.h"
+
+namespace doris {
+
+void WorkloadschedPolicyListener::handle_topic_info(const 
std::vector<TopicInfo>& topic_info_list) {

Review Comment:
   warning: method 'handle_topic_info' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static void WorkloadschedPolicyListener::handle_topic_info(const 
std::vector<TopicInfo>& topic_info_list) {
   ```
   



##########
be/src/runtime/workload_management/workload_sched_policy_mgr.cpp:
##########
@@ -0,0 +1,118 @@
+// 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::set_workload_sched_policy(

Review Comment:
   warning: method 'set_workload_sched_policy' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static void WorkloadSchedPolicyMgr::set_workload_sched_policy(
   ```
   



##########
be/src/runtime/workload_management/workload_sched_policy.cpp:
##########
@@ -0,0 +1,70 @@
+// 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.h"
+
+namespace doris {
+
+void WorkloadSchedPolicy::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) {
+    _id = id;
+    _name = name;
+    _version = version;
+    _enabled.store(enabled);
+    _priority.store(priority);
+    _condition_list = std::move(condition_list);
+    _action_list = std::move(action_list);
+
+    _first_action_type = _action_list[0]->get_action_type();
+    for (int i = 1; i < _action_list.size(); i++) {
+        WorkloadActionType cur_action_type = 
_action_list[i]->get_action_type();
+        // one policy can not both contains move and cancel
+        if (cur_action_type == WorkloadActionType::MOVE_QUERY_TO_GROUP ||
+            cur_action_type == WorkloadActionType::CANCEL_QUERY) {
+            _first_action_type = cur_action_type;
+            break;
+        }
+    }
+}
+
+bool WorkloadSchedPolicy::is_match(WorkloadQueryInfo* query_info_ptr) {

Review Comment:
   warning: method 'is_match' can be made const 
[readability-make-member-function-const]
   
   ```suggestion
   bool WorkloadSchedPolicy::is_match(WorkloadQueryInfo* query_info_ptr) const {
   ```
   
   be/src/runtime/workload_management/workload_sched_policy.h:38:
   ```diff
   -     bool is_match(WorkloadQueryInfo* query_info);
   +     bool is_match(WorkloadQueryInfo* query_info) const;
   ```
   



##########
be/src/runtime/workload_management/workload_condition.h:
##########
@@ -0,0 +1,93 @@
+// 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 <gen_cpp/BackendService_types.h>

Review Comment:
   warning: 'gen_cpp/BackendService_types.h' file not found 
[clang-diagnostic-error]
   ```cpp
   #include <gen_cpp/BackendService_types.h>
            ^
   ```
   



##########
be/src/runtime/workload_management/workload_sched_policy.cpp:
##########
@@ -0,0 +1,70 @@
+// 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.h"
+
+namespace doris {
+
+void WorkloadSchedPolicy::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) {
+    _id = id;
+    _name = name;
+    _version = version;
+    _enabled.store(enabled);
+    _priority.store(priority);
+    _condition_list = std::move(condition_list);
+    _action_list = std::move(action_list);
+
+    _first_action_type = _action_list[0]->get_action_type();
+    for (int i = 1; i < _action_list.size(); i++) {
+        WorkloadActionType cur_action_type = 
_action_list[i]->get_action_type();
+        // one policy can not both contains move and cancel
+        if (cur_action_type == WorkloadActionType::MOVE_QUERY_TO_GROUP ||
+            cur_action_type == WorkloadActionType::CANCEL_QUERY) {
+            _first_action_type = cur_action_type;
+            break;
+        }
+    }
+}
+
+bool WorkloadSchedPolicy::is_match(WorkloadQueryInfo* query_info_ptr) {
+    if (_enabled.load() == true) {

Review Comment:
   warning: redundant boolean literal supplied to boolean operator 
[readability-simplify-boolean-expr]
   
   ```suggestion
       if (_enabled.load()) {
   ```
   



##########
be/src/runtime/workload_management/workload_sched_policy.h:
##########
@@ -0,0 +1,57 @@
+// 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.load(); }

Review Comment:
   warning: method 'enabled' can be made const 
[readability-make-member-function-const]
   
   ```suggestion
       bool enabled() const { return _enabled.load(); }
   ```
   



##########
be/src/runtime/workload_management/workload_sched_policy.h:
##########
@@ -0,0 +1,57 @@
+// 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.load(); }
+    int priority() { return _priority.load(); }
+
+    bool is_match(WorkloadQueryInfo* query_info);
+
+    WorkloadActionType get_first_action_type() { return _first_action_type; }

Review Comment:
   warning: method 'get_first_action_type' can be made const 
[readability-make-member-function-const]
   
   ```suggestion
       WorkloadActionType get_first_action_type() const { return 
_first_action_type; }
   ```
   



##########
be/src/runtime/fragment_mgr.cpp:
##########
@@ -1567,4 +1568,26 @@ void 
FragmentMgr::_setup_shared_hashtable_for_broadcast_join(const TPipelineFrag
     }
 }
 
+void FragmentMgr::get_runtime_query_info(std::vector<WorkloadQueryInfo>* 
query_info_list) {

Review Comment:
   warning: method 'get_runtime_query_info' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static void 
FragmentMgr::get_runtime_query_info(std::vector<WorkloadQueryInfo>* 
query_info_list) {
   ```
   



##########
be/src/agent/workload_sched_policy_listener.h:
##########
@@ -0,0 +1,37 @@
+// 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 <glog/logging.h>

Review Comment:
   warning: 'glog/logging.h' file not found [clang-diagnostic-error]
   ```cpp
   #include <glog/logging.h>
            ^
   ```
   



##########
be/src/runtime/workload_management/workload_sched_policy.h:
##########
@@ -0,0 +1,57 @@
+// 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.load(); }
+    int priority() { return _priority.load(); }
+
+    bool is_match(WorkloadQueryInfo* query_info);
+
+    WorkloadActionType get_first_action_type() { return _first_action_type; }
+
+    void exec_action(WorkloadQueryInfo* query_info);
+
+public:

Review Comment:
   warning: redundant access specifier has the same accessibility as the 
previous access specifier [readability-redundant-access-specifiers]
   
   ```suggestion
   
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/runtime/workload_management/workload_sched_policy.h:27:** 
previously declared here
   ```cpp
   public:
   ^
   ```
   
   </details>
   



##########
be/src/runtime/workload_management/workload_action.h:
##########
@@ -0,0 +1,69 @@
+// 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 "runtime/workload_management/workload_query_info.h"
+
+namespace doris {
+
+enum WorkloadActionType { MOVE_QUERY_TO_GROUP = 0, CANCEL_QUERY = 1 };
+
+class WorkloadAction {
+public:
+    WorkloadAction() = default;
+    virtual ~WorkloadAction() = default;
+
+    virtual void exec(WorkloadQueryInfo* query_info) = 0;
+
+    virtual WorkloadActionType get_action_type() = 0;
+};
+
+class WorkloadActionCancelQuery : public WorkloadAction {
+public:
+    void exec(WorkloadQueryInfo* query_info) override;
+
+    WorkloadActionType get_action_type() override { return CANCEL_QUERY; }
+};
+
+//todo(wb) implement it
+class WorkloadActionMoveQuery : public WorkloadAction {
+public:
+    WorkloadActionMoveQuery(std::string wg_name) : _wg_name(wg_name) {}

Review Comment:
   warning: pass by value and use std::move [modernize-pass-by-value]
   
   be/src/runtime/workload_management/workload_action.h:19:
   ```diff
   - #include "runtime/workload_management/workload_query_info.h"
   + #include <utility>
   + 
   + #include "runtime/workload_management/workload_query_info.h"
   ```
   
   ```suggestion
       WorkloadActionMoveQuery(std::string wg_name) : 
_wg_name(std::move(wg_name)) {}
   ```
   



-- 
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

Reply via email to