Skip to content
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] Allow CN to run script (backport #44982) #44996

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.starrocks.rpc.BackendServiceClient;
import com.starrocks.server.GlobalStateMgr;
import com.starrocks.sql.ast.ExecuteScriptStmt;
import com.starrocks.system.Backend;
import com.starrocks.system.ComputeNode;
import com.starrocks.thrift.TNetworkAddress;
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
Expand Down Expand Up @@ -79,7 +79,7 @@ private static ShowResultSet executeFrontendScript(ExecuteScriptStmt stmt, Conne
}

private static ShowResultSet executeBackendScript(ExecuteScriptStmt stmt, ConnectContext ctx) throws UserException {
Backend be = GlobalStateMgr.getCurrentSystemInfo().getBackend(stmt.getBeId());
ComputeNode be = GlobalStateMgr.getCurrentSystemInfo().getBackendOrComputeNode(stmt.getBeId());
if (be == null) {
throw new UserException("node not found: " + stmt.getBeId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ public ComputeNode getComputeNode(long computeNodeId) {
return idToComputeNodeRef.get(computeNodeId);
}

public ComputeNode getBackendOrComputeNode(long nodeId) {
ComputeNode backend = idToBackendRef.get(nodeId);
if (backend == null) {
backend = idToComputeNodeRef.get(nodeId);
}
return backend;
}

public boolean checkBackendAvailable(long backendId) {
Backend backend = idToBackendRef.get(backendId);
return backend != null && backend.isAvailable();
Expand Down
Loading