Skip to content

Commit 80b39e9

Browse files
duanxujianDarvenDuan
duanxujian
authored andcommitted
add a new enum NodeType
1 parent 392da36 commit 80b39e9

File tree

6 files changed

+36
-41
lines changed

6 files changed

+36
-41
lines changed

fe/fe-core/src/main/cup/sql_parser.cup

+10-9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import org.apache.doris.load.loadv2.LoadTask;
6060
import org.apache.doris.policy.PolicyTypeEnum;
6161
import org.apache.doris.resource.workloadschedpolicy.WorkloadConditionMeta;
6262
import org.apache.doris.resource.workloadschedpolicy.WorkloadActionMeta;
63+
import org.apache.doris.system.NodeType;
6364

6465
import com.google.common.collect.Lists;
6566
import com.google.common.collect.Maps;
@@ -4707,15 +4708,15 @@ show_param ::=
47074708
:}
47084709
| KW_FRONTEND KW_CONFIG opt_wild_where
47094710
{:
4710-
RESULT = new ShowConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, parser.wild);
4711+
RESULT = new ShowConfigStmt(NodeType.FRONTEND, parser.wild);
47114712
:}
47124713
| KW_BACKEND KW_CONFIG opt_wild_where
47134714
{:
4714-
RESULT = new ShowConfigStmt(AdminSetConfigStmt.ConfigType.BACKEND, parser.wild);
4715+
RESULT = new ShowConfigStmt(NodeType.BACKEND, parser.wild);
47154716
:}
47164717
| KW_BACKEND KW_CONFIG opt_wild_where KW_FROM INTEGER_LITERAL:backendId
47174718
{:
4718-
RESULT = new ShowConfigStmt(AdminSetConfigStmt.ConfigType.BACKEND, parser.wild, backendId);
4719+
RESULT = new ShowConfigStmt(NodeType.BACKEND, parser.wild, backendId);
47194720
:}
47204721
| KW_TABLET KW_STORAGE KW_FORMAT
47214722
{:
@@ -7854,28 +7855,28 @@ admin_stmt ::=
78547855
:}
78557856
| KW_ADMIN KW_SET KW_FRONTEND KW_CONFIG opt_key_value_map:configs
78567857
{:
7857-
RESULT = new AdminSetConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, configs, false);
7858+
RESULT = new AdminSetConfigStmt(NodeType.FRONTEND, configs, false);
78587859
:}
78597860
| KW_ADMIN KW_SET KW_ALL KW_FRONTENDS KW_CONFIG opt_key_value_map:configs
78607861
{:
7861-
RESULT = new AdminSetConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, configs, true);
7862+
RESULT = new AdminSetConfigStmt(NodeType.FRONTEND, configs, true);
78627863
:}
78637864
| KW_ADMIN KW_SET KW_FRONTEND KW_CONFIG opt_key_value_map:configs KW_ALL
78647865
{:
7865-
RESULT = new AdminSetConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, configs, true);
7866+
RESULT = new AdminSetConfigStmt(NodeType.FRONTEND, configs, true);
78667867
:}
78677868
// deprecated
78687869
| KW_ADMIN KW_SHOW KW_FRONTEND KW_CONFIG opt_wild_where
78697870
{:
7870-
RESULT = new ShowConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, parser.wild);
7871+
RESULT = new ShowConfigStmt(NodeType.FRONTEND, parser.wild);
78717872
:}
78727873
| KW_ADMIN KW_SHOW KW_BACKEND KW_CONFIG opt_wild_where
78737874
{:
7874-
RESULT = new ShowConfigStmt(AdminSetConfigStmt.ConfigType.BACKEND, parser.wild);
7875+
RESULT = new ShowConfigStmt(NodeType.BACKEND, parser.wild);
78757876
:}
78767877
| KW_ADMIN KW_SHOW KW_BACKEND KW_CONFIG opt_wild_where KW_FROM INTEGER_LITERAL:backendId
78777878
{:
7878-
RESULT = new ShowConfigStmt(AdminSetConfigStmt.ConfigType.BACKEND, parser.wild, backendId);
7879+
RESULT = new ShowConfigStmt(NodeType.BACKEND, parser.wild, backendId);
78797880
:}
78807881
| KW_ADMIN KW_CHECK KW_TABLET LPAREN integer_list:tabletIds RPAREN opt_properties:properties
78817882
{:

fe/fe-core/src/main/java/org/apache/doris/analysis/AdminSetConfigStmt.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.doris.mysql.privilege.PrivPredicate;
2727
import org.apache.doris.qe.ConnectContext;
2828
import org.apache.doris.qe.OriginStatement;
29+
import org.apache.doris.system.NodeType;
2930

3031
import com.google.common.collect.Maps;
3132

@@ -34,18 +35,13 @@
3435
// admin set frontend config ("key" = "value");
3536
public class AdminSetConfigStmt extends DdlStmt {
3637

37-
public enum ConfigType {
38-
FRONTEND,
39-
BACKEND
40-
}
41-
4238
private boolean applyToAll;
43-
private ConfigType type;
39+
private NodeType type;
4440
private Map<String, String> configs;
4541

4642
private RedirectStatus redirectStatus = RedirectStatus.NO_FORWARD;
4743

48-
public AdminSetConfigStmt(ConfigType type, Map<String, String> configs, boolean applyToAll) {
44+
public AdminSetConfigStmt(NodeType type, Map<String, String> configs, boolean applyToAll) {
4945
this.type = type;
5046
this.configs = configs;
5147
if (this.configs == null) {
@@ -62,7 +58,7 @@ public AdminSetConfigStmt(ConfigType type, Map<String, String> configs, boolean
6258
}
6359
}
6460

65-
public ConfigType getType() {
61+
public NodeType getType() {
6662
return type;
6763
}
6864

@@ -86,7 +82,7 @@ public void analyze(Analyzer analyzer) throws AnalysisException, UserException {
8682
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "ADMIN");
8783
}
8884

89-
if (type != ConfigType.FRONTEND) {
85+
if (type != NodeType.FRONTEND) {
9086
throw new AnalysisException("Only support setting Frontend configs now");
9187
}
9288
}

fe/fe-core/src/main/java/org/apache/doris/analysis/ShowConfigStmt.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717

1818
package org.apache.doris.analysis;
1919

20-
import org.apache.doris.analysis.AdminSetConfigStmt.ConfigType;
2120
import org.apache.doris.catalog.Column;
2221
import org.apache.doris.catalog.Env;
2322
import org.apache.doris.catalog.ScalarType;
24-
import org.apache.doris.common.AnalysisException;
2523
import org.apache.doris.common.ErrorCode;
2624
import org.apache.doris.common.ErrorReport;
2725
import org.apache.doris.common.UserException;
2826
import org.apache.doris.mysql.privilege.PrivPredicate;
2927
import org.apache.doris.qe.ConnectContext;
3028
import org.apache.doris.qe.ShowResultSetMetaData;
29+
import org.apache.doris.system.NodeType;
3130

3231
import com.google.common.collect.ImmutableList;
3332

@@ -39,27 +38,27 @@ public class ShowConfigStmt extends ShowStmt {
3938
public static final ImmutableList<String> BE_TITLE_NAMES = new ImmutableList.Builder<String>().add("BackendId")
4039
.add("Host").add("Key").add("Value").add("Type").add("IsMutable").build();
4140

42-
private ConfigType type;
41+
private NodeType type;
4342

4443
private String pattern;
4544

4645
private long backendId;
4746

4847
private boolean isShowSingleBackend;
4948

50-
public ShowConfigStmt(ConfigType type, String pattern) {
49+
public ShowConfigStmt(NodeType type, String pattern) {
5150
this.type = type;
5251
this.pattern = pattern;
5352
}
5453

55-
public ShowConfigStmt(ConfigType type, String pattern, long backendId) {
54+
public ShowConfigStmt(NodeType type, String pattern, long backendId) {
5655
this.type = type;
5756
this.pattern = pattern;
5857
this.backendId = backendId;
5958
this.isShowSingleBackend = true;
6059
}
6160

62-
public ConfigType getType() {
61+
public NodeType getType() {
6362
return type;
6463
}
6564

@@ -83,16 +82,12 @@ public void analyze(Analyzer analyzer) throws UserException {
8382
if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN)) {
8483
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "ADMIN");
8584
}
86-
87-
if (type != ConfigType.FRONTEND && type != ConfigType.BACKEND) {
88-
throw new AnalysisException("Only support setting Frontend and Backend configs now");
89-
}
9085
}
9186

9287
@Override
9388
public ShowResultSetMetaData getMetaData() {
9489
ShowResultSetMetaData.Builder builder = ShowResultSetMetaData.builder();
95-
if (type == ConfigType.FRONTEND) {
90+
if (type == NodeType.FRONTEND) {
9691
for (String title : FE_TITLE_NAMES) {
9792
builder.addColumn(new Column(title, ScalarType.createVarchar(30)));
9893
}
@@ -107,7 +102,7 @@ public ShowResultSetMetaData getMetaData() {
107102
@Override
108103
public RedirectStatus getRedirectStatus() {
109104
// no need forward to master for backend config
110-
if (type == ConfigType.BACKEND) {
105+
if (type == NodeType.BACKEND) {
111106
return RedirectStatus.NO_FORWARD;
112107
}
113108
if (ConnectContext.get().getSessionVariable().getForwardToMaster()) {

fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@
474474
import org.apache.doris.policy.PolicyTypeEnum;
475475
import org.apache.doris.qe.ConnectContext;
476476
import org.apache.doris.qe.SqlModeHelper;
477+
import org.apache.doris.system.NodeType;
477478

478479
import com.google.common.collect.ImmutableList;
479480
import com.google.common.collect.ImmutableMap;
@@ -487,7 +488,6 @@
487488
import org.antlr.v4.runtime.tree.ParseTree;
488489
import org.antlr.v4.runtime.tree.RuleNode;
489490
import org.antlr.v4.runtime.tree.TerminalNode;
490-
import org.apache.doris.system.NodeType;
491491

492492
import java.math.BigDecimal;
493493
import java.math.BigInteger;
@@ -3692,7 +3692,7 @@ public LogicalPlan visitShowConfig(ShowConfigContext ctx) {
36923692
String pattern = ((Literal) like.child(1)).getStringValue();
36933693
command.setPattern(pattern);
36943694
}
3695-
if (ctx.FROM() !=null && ctx.backendId != null) {
3695+
if (ctx.FROM() != null && ctx.backendId != null) {
36963696
long backendId = Long.parseLong(ctx.backendId.getText());
36973697
command.setBackendId(backendId);
36983698
}

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowConfigCommand.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.doris.nereids.trees.plans.commands;
1919

20-
import com.google.common.collect.Lists;
2120
import org.apache.doris.catalog.Column;
2221
import org.apache.doris.catalog.Env;
2322
import org.apache.doris.catalog.ScalarType;
@@ -34,9 +33,10 @@
3433
import org.apache.doris.qe.StmtExecutor;
3534
import org.apache.doris.system.Backend;
3635
import org.apache.doris.system.NodeType;
36+
import org.apache.doris.system.SystemInfoService;
3737

3838
import com.google.common.collect.ImmutableList;
39-
import org.apache.doris.system.SystemInfoService;
39+
import com.google.common.collect.Lists;
4040
import org.json.JSONArray;
4141

4242
import java.io.BufferedReader;
@@ -48,12 +48,15 @@
4848
import java.util.Comparator;
4949
import java.util.List;
5050

51-
public class ShowConfigCommand extends Command implements NoForward{
51+
/**
52+
* show frontend/backend config
53+
*/
54+
public class ShowConfigCommand extends Command implements NoForward {
5255

5356
public static final ImmutableList<String> FE_TITLE_NAMES = new ImmutableList.Builder<String>().add("Key").add(
54-
"Value").add("Type").add("IsMutable").add("MasterOnly").add("Comment").build();
57+
"Value").add("Type").add("IsMutable").add("MasterOnly").add("Comment").build();
5558
public static final ImmutableList<String> BE_TITLE_NAMES = new ImmutableList.Builder<String>().add("BackendId")
56-
.add("Host").add("Key").add("Value").add("Type").add("IsMutable").build();
59+
.add("Host").add("Key").add("Value").add("Type").add("IsMutable").build();
5760

5861
private final NodeType nodeType;
5962
private String pattern;
@@ -74,7 +77,7 @@ public void setBackendId(long backendId) {
7477
this.isShowSingleBackend = true;
7578
}
7679

77-
public ShowResultSetMetaData getMetaData(ImmutableList<String> metaNames) {
80+
private ShowResultSetMetaData getMetaData(ImmutableList<String> metaNames) {
7881
ShowResultSetMetaData.Builder builder = ShowResultSetMetaData.builder();
7982
for (String title : metaNames) {
8083
builder.addColumn(new Column(title, ScalarType.createStringType()));
@@ -94,7 +97,7 @@ private ShowResultSet handShowFrontendConfig() throws AnalysisException {
9497
return new ShowResultSet(getMetaData(FE_TITLE_NAMES), results);
9598
}
9699

97-
private ShowResultSet handShowBackendConfig() throws AnalysisException{
100+
private ShowResultSet handShowBackendConfig() throws AnalysisException {
98101
List<List<String>> results = new ArrayList<>();
99102
List<Long> backendIds;
100103
final SystemInfoService systemInfoService = Env.getCurrentSystemInfo();

fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.doris.qe;
1919

2020
import org.apache.doris.analysis.AdminCopyTabletStmt;
21-
import org.apache.doris.analysis.AdminSetConfigStmt.ConfigType;
2221
import org.apache.doris.analysis.CompoundPredicate.Operator;
2322
import org.apache.doris.analysis.DescribeStmt;
2423
import org.apache.doris.analysis.DiagnoseTabletStmt;
@@ -233,6 +232,7 @@
233232
import org.apache.doris.statistics.util.StatisticsUtil;
234233
import org.apache.doris.system.Backend;
235234
import org.apache.doris.system.Diagnoser;
235+
import org.apache.doris.system.NodeType;
236236
import org.apache.doris.system.SystemInfoService;
237237
import org.apache.doris.task.AgentBatchTask;
238238
import org.apache.doris.task.AgentClient;
@@ -2391,7 +2391,7 @@ private void handleAdminShowTabletDistribution() throws AnalysisException {
23912391

23922392
private void handleAdminShowConfig() throws AnalysisException {
23932393
ShowConfigStmt showStmt = (ShowConfigStmt) stmt;
2394-
if (showStmt.getType() == ConfigType.FRONTEND) {
2394+
if (showStmt.getType() == NodeType.FRONTEND) {
23952395
List<List<String>> results;
23962396
PatternMatcher matcher = null;
23972397
if (showStmt.getPattern() != null) {

0 commit comments

Comments
 (0)