-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Add cluster idle HTTP api #53850
Changes from 4 commits
f9df7a8
4e50f1a
ca88d9f
1914583
aeef4af
4f458c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// Licensed 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 | ||
// | ||
// https://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. | ||
|
||
package com.starrocks.http.rest; | ||
|
||
import com.starrocks.http.ActionController; | ||
import com.starrocks.http.BaseRequest; | ||
import com.starrocks.http.BaseResponse; | ||
import com.starrocks.http.IllegalArgException; | ||
import com.starrocks.persist.gson.GsonUtils; | ||
import com.starrocks.server.GlobalStateMgr; | ||
import com.starrocks.warehouse.IdleStatus; | ||
import io.netty.handler.codec.http.HttpMethod; | ||
|
||
/** | ||
* API to check whether the cluster is idle | ||
* { | ||
* "isClusterIdle": true, | ||
* "clusterIdleTime": 1734113878006, | ||
* "warehouses": [ | ||
* { | ||
* "id": 0, | ||
* "name": "default_warehouse", | ||
* "isIdle": true, | ||
* "idleTime": 1734113878006 | ||
* } | ||
* ] | ||
* } | ||
*/ | ||
public class IdleAction extends RestBaseAction { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please indicate what the Idle content is. The name of this class cannot express the meaning of the content. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
public IdleAction(ActionController controller) { | ||
super(controller); | ||
} | ||
|
||
public static void registerAction(ActionController controller) throws IllegalArgException { | ||
controller.registerHandler(HttpMethod.GET, "/api/idle_status", new IdleAction(controller)); | ||
} | ||
|
||
@Override | ||
public void execute(BaseRequest request, BaseResponse response) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this api endpoint be protected by authentication? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not need, there is no secret info There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be a security concern but I would defer it to you guys decision. |
||
IdleStatus idleStatus = GlobalStateMgr.getCurrentState().getWarehouseIdleChecker().getIdleStatus(); | ||
String content = GsonUtils.GSON.toJson(idleStatus); | ||
response.getContent().append(content); | ||
sendResult(request, response); | ||
} | ||
} | ||
kevincai marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider set this to 0 in open source version to disable the check by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new config
warehouse_idle_check_enable
, because thewarehouse_idle_check_interval_seconds
is also used to check the last job finish time.