This is an automated email from the ASF dual-hosted git repository.
starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new d30a00ab53e [Chore](nereids) Remove AlterSystemStmt (#51890)
d30a00ab53e is described below
commit d30a00ab53ef890f434359e55b7db7870a02603c
Author: Jensen <[email protected]>
AuthorDate: Thu Jun 19 14:35:37 2025 +0800
[Chore](nereids) Remove AlterSystemStmt (#51890)
---
fe/fe-core/src/main/cup/sql_parser.cup | 4 -
.../main/java/org/apache/doris/alter/Alter.java | 5 -
.../org/apache/doris/analysis/AlterSystemStmt.java | 77 --------
.../main/java/org/apache/doris/catalog/Env.java | 5 -
.../main/java/org/apache/doris/qe/DdlExecutor.java | 4 -
.../apache/doris/catalog/ModifyBackendTest.java | 199 ---------------------
.../org/apache/doris/clone/DecommissionTest.java | 17 +-
.../doris/clone/TabletRepairAndBalanceTest.java | 92 ++++++----
.../doris/cluster/DecommissionBackendTest.java | 38 ++--
.../apache/doris/planner/ResourceTagQueryTest.java | 20 ++-
10 files changed, 110 insertions(+), 351 deletions(-)
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup
b/fe/fe-core/src/main/cup/sql_parser.cup
index a40c86603f7..c12d4a7499b 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -1362,10 +1362,6 @@ alter_stmt ::=
{:
RESULT = new AlterViewStmt(tbl, columns, view_def);
:}
- | KW_ALTER KW_SYSTEM alter_system_clause:clause
- {:
- RESULT = new AlterSystemStmt(clause);
- :}
| KW_ALTER KW_DATABASE ident:dbName KW_SET KW_DATA KW_QUOTA
quantity:quota_quantity
{:
RESULT = new AlterDatabaseQuotaStmt(dbName, QuotaType.DATA,
quota_quantity);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
index e6b6a870d25..079db77d24b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
@@ -21,7 +21,6 @@ import org.apache.doris.analysis.AddPartitionClause;
import org.apache.doris.analysis.AddPartitionLikeClause;
import org.apache.doris.analysis.AlterClause;
import org.apache.doris.analysis.AlterMultiPartitionClause;
-import org.apache.doris.analysis.AlterSystemStmt;
import org.apache.doris.analysis.AlterTableStmt;
import org.apache.doris.analysis.AlterViewStmt;
import org.apache.doris.analysis.ColumnRenameClause;
@@ -918,10 +917,6 @@ public class Alter {
}
}
- public void processAlterSystem(AlterSystemStmt stmt) throws UserException {
-
systemHandler.process(Collections.singletonList(stmt.getAlterClause()), null,
null);
- }
-
public void processAlterSystem(AlterSystemCommand command) throws
UserException {
systemHandler.processForNereids(Collections.singletonList(command),
null, null);
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterSystemStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterSystemStmt.java
deleted file mode 100644
index 7d52c06da50..00000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterSystemStmt.java
+++ /dev/null
@@ -1,77 +0,0 @@
-// 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.
-
-package org.apache.doris.analysis;
-
-import org.apache.doris.catalog.Env;
-import org.apache.doris.common.ErrorCode;
-import org.apache.doris.common.ErrorReport;
-import org.apache.doris.common.UserException;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
-
-import com.google.common.base.Preconditions;
-import lombok.Getter;
-
-@Getter
-public class AlterSystemStmt extends DdlStmt implements NotFallbackInParser {
-
- private final AlterClause alterClause;
-
- public AlterSystemStmt(AlterClause alterClause) {
- this.alterClause = alterClause;
- }
-
- @Override
- public void analyze(Analyzer analyzer) throws UserException {
- if
(!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(),
PrivPredicate.OPERATOR)) {
-
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR,
- "NODE");
- }
-
- Preconditions.checkState((alterClause instanceof AddBackendClause)
- || (alterClause instanceof DropBackendClause)
- || (alterClause instanceof DecommissionBackendClause)
- || (alterClause instanceof AddObserverClause)
- || (alterClause instanceof DropObserverClause)
- || (alterClause instanceof AddFollowerClause)
- || (alterClause instanceof DropFollowerClause)
- || (alterClause instanceof ModifyBrokerClause)
- || (alterClause instanceof AlterLoadErrorUrlClause)
- || (alterClause instanceof ModifyBackendClause)
- || (alterClause instanceof ModifyBackendHostNameClause)
- || (alterClause instanceof ModifyFrontendHostNameClause)
- );
-
- alterClause.analyze(analyzer);
- }
-
- @Override
- public String toSql() {
- return "ALTER SYSTEM " + alterClause.toSql();
- }
-
- @Override
- public String toString() {
- return toSql();
- }
-
- @Override
- public StmtType stmtType() {
- return StmtType.ALTER;
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 6572f435c1e..f636804df5d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -39,7 +39,6 @@ import org.apache.doris.analysis.AlterDatabasePropertyStmt;
import org.apache.doris.analysis.AlterDatabaseQuotaStmt;
import org.apache.doris.analysis.AlterDatabaseRename;
import org.apache.doris.analysis.AlterMultiPartitionClause;
-import org.apache.doris.analysis.AlterSystemStmt;
import org.apache.doris.analysis.AlterTableStmt;
import org.apache.doris.analysis.AlterViewStmt;
import org.apache.doris.analysis.BackupStmt;
@@ -5844,10 +5843,6 @@ public class Env {
* used for handling AlterSystemStmt
* (for client is the ALTER SYSTEM command).
*/
- public void alterSystem(AlterSystemStmt stmt) throws DdlException,
UserException {
- this.alter.processAlterSystem(stmt);
- }
-
public void alterSystem(AlterSystemCommand command) throws UserException {
this.alter.processAlterSystem(command);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
index a78f516745a..cd9e4439b35 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
@@ -43,7 +43,6 @@ import org.apache.doris.analysis.AlterResourceStmt;
import org.apache.doris.analysis.AlterRoleStmt;
import org.apache.doris.analysis.AlterRoutineLoadStmt;
import org.apache.doris.analysis.AlterSqlBlockRuleStmt;
-import org.apache.doris.analysis.AlterSystemStmt;
import org.apache.doris.analysis.AlterTableStmt;
import org.apache.doris.analysis.AlterViewStmt;
import org.apache.doris.analysis.AlterWorkloadGroupStmt;
@@ -230,9 +229,6 @@ public class DdlExecutor {
env.getAuth().dropRole((DropRoleStmt) ddlStmt);
} else if (ddlStmt instanceof SetUserPropertyStmt) {
env.getAuth().updateUserProperty((SetUserPropertyStmt) ddlStmt);
- } else if (ddlStmt instanceof AlterSystemStmt) {
- AlterSystemStmt stmt = (AlterSystemStmt) ddlStmt;
- env.alterSystem(stmt);
} else if (ddlStmt instanceof CancelAlterSystemStmt) {
CancelAlterSystemStmt stmt = (CancelAlterSystemStmt) ddlStmt;
env.cancelAlterSystem(stmt);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBackendTest.java
b/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBackendTest.java
deleted file mode 100644
index 9d9a4788b59..00000000000
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBackendTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-// 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.
-
-package org.apache.doris.catalog;
-
-import org.apache.doris.analysis.AlterSystemStmt;
-import org.apache.doris.analysis.AlterTableStmt;
-import org.apache.doris.analysis.CreateDbStmt;
-import org.apache.doris.analysis.CreateTableStmt;
-import org.apache.doris.common.AnalysisException;
-import org.apache.doris.common.DdlException;
-import org.apache.doris.common.ExceptionChecker;
-import org.apache.doris.common.FeConstants;
-import org.apache.doris.qe.ConnectContext;
-import org.apache.doris.qe.DdlExecutor;
-import org.apache.doris.resource.Tag;
-import org.apache.doris.system.Backend;
-import org.apache.doris.system.SystemInfoService;
-import org.apache.doris.utframe.UtFrameUtils;
-
-import com.google.common.collect.Maps;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-public class ModifyBackendTest {
-
- private static String runningDir = "fe/mocked/ModifyBackendTagTest/" +
UUID.randomUUID().toString() + "/";
- private static ConnectContext connectContext;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- FeConstants.runningUnitTest = true;
- UtFrameUtils.createDorisCluster(runningDir);
- // create connect context
- connectContext = UtFrameUtils.createDefaultCtx();
- // create database
- String createDbStmtStr = "create database test;";
- CreateDbStmt createDbStmt = (CreateDbStmt)
UtFrameUtils.parseAndAnalyzeStmt(createDbStmtStr, connectContext);
- Env.getCurrentEnv().createDb(createDbStmt);
- }
-
- @AfterClass
- public static void tearDown() {
- File file = new File(runningDir);
- file.delete();
- }
-
- @Test
- public void testModifyBackendTag() throws Exception {
- SystemInfoService infoService = Env.getCurrentSystemInfo();
- List<Backend> backends =
infoService.getAllBackendsByAllCluster().values().asList();
- Assert.assertEquals(1, backends.size());
- String beHostPort = backends.get(0).getHost() + ":" +
backends.get(0).getHeartbeatPort();
-
- // modify backend tag
- String stmtStr = "alter system modify backend \"" + beHostPort + "\"
set ('tag.location' = 'zone1')";
- AlterSystemStmt stmt = (AlterSystemStmt)
UtFrameUtils.parseAndAnalyzeStmt(stmtStr, connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
- backends = infoService.getAllBackendsByAllCluster().values().asList();
- Assert.assertEquals(1, backends.size());
-
- // create table
- String createStr = "create table test.tbl1(\n" + "k1 int\n" + ")
distributed by hash(k1)\n"
- + "buckets 3 properties(\n" + "\"replication_num\" = \"1\"\n"
+ ");";
- CreateTableStmt createStmt = (CreateTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(createStr, connectContext);
- ExceptionChecker.expectThrowsWithMsg(DdlException.class,
- "Failed to find enough backend, please check the replication
num,replication tag and storage medium and avail capacity of backends "
- + "or maybe all be on same host."
- +
Env.getCurrentSystemInfo().getDetailsForCreateReplica(new
ReplicaAllocation((short) 1)) + "\n"
- + "Create failed replications:\n"
- + "replication tag: {\"location\" : \"default\"},
replication num: 1, storage medium: HDD",
- () -> DdlExecutor.execute(Env.getCurrentEnv(), createStmt));
-
- createStr = "create table test.tbl1(\n" + "k1 int\n" + ") distributed
by hash(k1)\n" + "buckets 3 properties(\n"
- + "\"replication_allocation\" = \"tag.location.zone1: 1\"\n" +
");";
- CreateTableStmt createStmt2 = (CreateTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(createStr, connectContext);
- ExceptionChecker.expectThrowsNoException(() ->
DdlExecutor.execute(Env.getCurrentEnv(), createStmt2));
-
- // create dynamic partition tbl
- createStr = "create table test.tbl3(\n"
- + "k1 date, k2 int\n"
- + ") partition by range(k1)()\n"
- + "distributed by hash(k1)\n"
- + "buckets 3 properties(\n" + "
\"dynamic_partition.enable\" = \"true\",\n"
- + " \"dynamic_partition.time_unit\" = \"DAY\",\n" + "
\"dynamic_partition.start\" = \"-3\",\n"
- + " \"dynamic_partition.end\" = \"3\",\n" + "
\"dynamic_partition.prefix\" = \"p\",\n"
- + " \"dynamic_partition.buckets\" = \"1\",\n" + "
\"dynamic_partition.replication_num\" = \"3\"\n"
- + ");";
- CreateTableStmt createStmt3 = (CreateTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(createStr, connectContext);
- //partition create failed, because there is no BE with "default" tag
- ExceptionChecker.expectThrowsWithMsg(DdlException.class, "replication
num should be less than the number of available backends. replication num is 3,
available backend num is 1",
- () -> DdlExecutor.execute(Env.getCurrentEnv(), createStmt3));
- Database db = Env.getCurrentInternalCatalog().getDbNullable("test");
-
- createStr = "create table test.tbl4(\n" + "k1 date, k2 int\n" + ")
partition by range(k1)()\n"
- + "distributed by hash(k1)\n" + "buckets 3 properties(\n"
- + " \"dynamic_partition.enable\" = \"true\",\n" + "
\"dynamic_partition.time_unit\" = \"DAY\",\n"
- + " \"dynamic_partition.start\" = \"-3\",\n" + "
\"dynamic_partition.end\" = \"3\",\n"
- + " \"dynamic_partition.prefix\" = \"p\",\n"
- + " \"dynamic_partition.buckets\" = \"1\",\n"
- + " \"dynamic_partition.replication_allocation\" =
\"tag.location.zone1:1\"\n"
- + ");";
- CreateTableStmt createStmt4 = (CreateTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(createStr, connectContext);
- ExceptionChecker.expectThrowsNoException(() ->
DdlExecutor.execute(Env.getCurrentEnv(), createStmt4));
- OlapTable tbl = (OlapTable) db.getTableNullable("tbl4");
- PartitionInfo partitionInfo = tbl.getPartitionInfo();
- Assert.assertEquals(4, partitionInfo.idToItem.size());
- ReplicaAllocation replicaAlloc = new ReplicaAllocation();
- replicaAlloc.put(Tag.create(Tag.TYPE_LOCATION, "zone1"), (short) 1);
- for (ReplicaAllocation allocation :
partitionInfo.idToReplicaAllocation.values()) {
- Assert.assertEquals(replicaAlloc, allocation);
- }
-
- ReplicaAllocation defaultAlloc = tbl.getDefaultReplicaAllocation();
- Assert.assertEquals(ReplicaAllocation.DEFAULT_ALLOCATION,
defaultAlloc);
- TableProperty tableProperty = tbl.getTableProperty();
- Map<String, String> tblProperties = tableProperty.getProperties();
- // if replication_num or replication_allocation is not set, it will be
set to the default one
-
Assert.assertTrue(tblProperties.containsKey("default.replication_allocation"));
- Assert.assertEquals("tag.location.default: 3",
tblProperties.get("default.replication_allocation"));
-
- // modify default replica
- String alterStr = "alter table test.tbl4 set
('default.replication_allocation' = 'tag.location.zone1:1')";
- AlterTableStmt alterStmt = (AlterTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(alterStr, connectContext);
- ExceptionChecker.expectThrowsNoException(() ->
DdlExecutor.execute(Env.getCurrentEnv(), alterStmt));
- defaultAlloc = tbl.getDefaultReplicaAllocation();
- ReplicaAllocation expectedAlloc = new ReplicaAllocation();
- expectedAlloc.put(Tag.create(Tag.TYPE_LOCATION, "zone1"), (short) 1);
- Assert.assertEquals(expectedAlloc, defaultAlloc);
- tblProperties = tableProperty.getProperties();
-
Assert.assertTrue(tblProperties.containsKey("default.replication_allocation"));
-
- // modify partition replica with wrong zone
- // it will fail because of we check tag location during the analysis
process, so we check AnalysisException
- String partName = tbl.getPartitionNames().stream().findFirst().get();
- String wrongAlterStr = "alter table test.tbl4 modify partition " +
partName
- + " set ('replication_allocation' = 'tag.location.zonex:1')";
- Map<Tag, Short> allocMap = Maps.newHashMap();
- allocMap.put(Tag.create(Tag.TYPE_LOCATION, "zonex"), (short) 1);
- ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "errCode
= 2,"
- + " detailMessage = Failed to find enough backend, "
- + "please check the replication num,replication tag
and storage medium and avail capacity of backends "
- + "or maybe all be on same host."
- +
Env.getCurrentSystemInfo().getDetailsForCreateReplica(new
ReplicaAllocation(allocMap)) + "\n"
- + "Create failed replications:\n"
- + "replication tag: {\"location\" : \"zonex\"},
replication num: 1, storage medium: null",
- () -> UtFrameUtils.parseAndAnalyzeStmt(wrongAlterStr,
connectContext));
- tblProperties = tableProperty.getProperties();
-
Assert.assertTrue(tblProperties.containsKey("default.replication_allocation"));
-
- alterStr = "alter table test.tbl4 modify partition " + partName
- + " set ('replication_allocation' = 'tag.location.zone1:1')";
- AlterTableStmt alterStmt3 = (AlterTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(alterStr, connectContext);
- ExceptionChecker.expectThrowsNoException(() ->
DdlExecutor.execute(Env.getCurrentEnv(), alterStmt3));
- tblProperties = tableProperty.getProperties();
-
Assert.assertTrue(tblProperties.containsKey("default.replication_allocation"));
- }
-
- @Test
- public void testModifyBackendAvailableProperty() throws Exception {
- SystemInfoService infoService = Env.getCurrentSystemInfo();
- List<Backend> backends =
infoService.getAllBackendsByAllCluster().values().asList();
- String beHostPort = backends.get(0).getHost() + ":" +
backends.get(0).getHeartbeatPort();
- // modify backend available property
- String stmtStr = "alter system modify backend \"" + beHostPort + "\"
set ('disable_query' = 'true', 'disable_load' = 'true')";
- AlterSystemStmt stmt = (AlterSystemStmt)
UtFrameUtils.parseAndAnalyzeStmt(stmtStr, connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
- Backend backend =
infoService.getAllBackendsByAllCluster().values().asList().get(0);
- Assert.assertFalse(backend.isQueryAvailable());
- Assert.assertFalse(backend.isLoadAvailable());
-
- stmtStr = "alter system modify backend \"" + beHostPort + "\" set
('disable_query' = 'false', 'disable_load' = 'false')";
- stmt = (AlterSystemStmt) UtFrameUtils.parseAndAnalyzeStmt(stmtStr,
connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
- Assert.assertTrue(backend.isQueryAvailable());
- Assert.assertTrue(backend.isLoadAvailable());
- }
-}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/clone/DecommissionTest.java
b/fe/fe-core/src/test/java/org/apache/doris/clone/DecommissionTest.java
index 6901d3b604c..97446eca9be 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/clone/DecommissionTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/clone/DecommissionTest.java
@@ -17,7 +17,6 @@
package org.apache.doris.clone;
-import org.apache.doris.analysis.AlterSystemStmt;
import org.apache.doris.analysis.CreateDbStmt;
import org.apache.doris.analysis.CreateTableStmt;
import org.apache.doris.catalog.Env;
@@ -25,13 +24,18 @@ import org.apache.doris.catalog.TabletInvertedIndex;
import org.apache.doris.common.Config;
import org.apache.doris.common.ExceptionChecker;
import org.apache.doris.common.FeConstants;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.commands.AlterSystemCommand;
+import
org.apache.doris.nereids.trees.plans.commands.info.DecommissionBackendOp;
import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.system.Backend;
import org.apache.doris.system.SystemInfoService;
import org.apache.doris.thrift.TDisk;
import org.apache.doris.thrift.TStorageMedium;
import org.apache.doris.utframe.UtFrameUtils;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -140,11 +144,12 @@ public class DecommissionTest {
checkBalance(1, totalReplicaNum, 4);
Backend backend =
Env.getCurrentSystemInfo().getAllBackendsByAllCluster().values().asList().get(0);
- String decommissionStmtStr = "alter system decommission backend \"" +
backend.getHost()
- + ":" + backend.getHeartbeatPort() + "\"";
- AlterSystemStmt decommissionStmt =
- (AlterSystemStmt)
UtFrameUtils.parseAndAnalyzeStmt(decommissionStmtStr, connectContext);
-
Env.getCurrentEnv().getAlterInstance().processAlterSystem(decommissionStmt);
+
+ // "alter system decommission backend \"" + backend.getHost() + ":" +
backend.getHeartbeatPort() + "\"";
+ String hostPort = backend.getHost() + ":" + backend.getHeartbeatPort();
+ DecommissionBackendOp op = new
DecommissionBackendOp(ImmutableList.of(hostPort));
+ AlterSystemCommand command = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_DECOMMISSION_BACKEND);
+ command.doRun(connectContext, new StmtExecutor(connectContext, ""));
Assert.assertEquals(true, backend.isDecommissioned());
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/clone/TabletRepairAndBalanceTest.java
b/fe/fe-core/src/test/java/org/apache/doris/clone/TabletRepairAndBalanceTest.java
index c02afa1db08..0c81e8753ca 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/clone/TabletRepairAndBalanceTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/clone/TabletRepairAndBalanceTest.java
@@ -17,7 +17,6 @@
package org.apache.doris.clone;
-import org.apache.doris.analysis.AlterSystemStmt;
import org.apache.doris.analysis.AlterTableStmt;
import org.apache.doris.analysis.BackendClause;
import org.apache.doris.analysis.CancelAlterSystemStmt;
@@ -44,8 +43,13 @@ import org.apache.doris.common.FeConstants;
import org.apache.doris.common.FeMetaVersion;
import org.apache.doris.common.UserException;
import org.apache.doris.meta.MetaContext;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.commands.AlterSystemCommand;
+import
org.apache.doris.nereids.trees.plans.commands.info.DecommissionBackendOp;
+import org.apache.doris.nereids.trees.plans.commands.info.ModifyBackendOp;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.DdlExecutor;
+import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.resource.Tag;
import org.apache.doris.system.Backend;
import org.apache.doris.system.SystemInfoService;
@@ -53,6 +57,7 @@ import org.apache.doris.thrift.TDisk;
import org.apache.doris.thrift.TStorageMedium;
import org.apache.doris.utframe.UtFrameUtils;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Table;
@@ -69,6 +74,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
@@ -191,32 +197,47 @@ public class TabletRepairAndBalanceTest {
if (i > 2) {
tag = "zone2";
}
- String stmtStr = "alter system modify backend \"" + be.getHost() +
":" + be.getHeartbeatPort()
- + "\" set ('tag.location' = '" + tag + "')";
- AlterSystemStmt stmt = (AlterSystemStmt)
UtFrameUtils.parseAndAnalyzeStmt(stmtStr, connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
+ // "alter system modify backend \"" + be.getHost() + ":" +
be.getHeartbeatPort()
+ // + "\" set ('tag.location' = '" + tag + "')";
+ String hostPort = be.getHost() + ":" + be.getHeartbeatPort();
+ Map<String, String> properties = new HashMap<>();
+ properties.put("tag.location", tag);
+ ModifyBackendOp op = new
ModifyBackendOp(ImmutableList.of(hostPort), properties);
+ AlterSystemCommand command = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_MODIFY_BACKEND);
+ command.doRun(connectContext, new StmtExecutor(connectContext,
""));
}
// Test set tag without location type, expect throw exception
Backend be1 = backends.get(0);
- String alterString = "alter system modify backend \"" + be1.getHost()
+ ":" + be1.getHeartbeatPort()
- + "\" set ('tag.compute' = 'abc')";
+ String hostPort = be1.getHost() + ":" + be1.getHeartbeatPort();
+ Map<String, String> properties = new HashMap<>();
+ properties.put("tag.compution", "abc");
+ ModifyBackendOp op = new ModifyBackendOp(ImmutableList.of(hostPort),
properties);
+ AlterSystemCommand command0 = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_MODIFY_BACKEND);
ExceptionChecker.expectThrowsWithMsg(AnalysisException.class,
BackendClause.NEED_LOCATION_TAG_MSG,
- () -> UtFrameUtils.parseAndAnalyzeStmt(alterString,
connectContext));
+ () -> command0.validate(connectContext));
// Test set multi tag for a Backend when Config.enable_multi_tags is
false
Config.enable_multi_tags = false;
- String alterString2 = "alter system modify backend \"" + be1.getHost()
+ ":" + be1.getHeartbeatPort()
- + "\" set ('tag.location' = 'zone3', 'tag.compution' = 'abc')";
+ hostPort = be1.getHost() + ":" + be1.getHeartbeatPort();
+ properties = new HashMap<>();
+ properties.put("tag.location", "zone3");
+ properties.put("tag.compution", "abc");
+ op = new ModifyBackendOp(ImmutableList.of(hostPort), properties);
+ final AlterSystemCommand command = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_MODIFY_BACKEND);
ExceptionChecker.expectThrowsWithMsg(AnalysisException.class,
BackendClause.MUTLI_TAG_DISABLED_MSG,
- () -> UtFrameUtils.parseAndAnalyzeStmt(alterString2,
connectContext));
+ () -> command.validate(connectContext));
// Test set multi tag for a Backend when Config.enable_multi_tags is
true
Config.enable_multi_tags = true;
- String stmtStr3 = "alter system modify backend \"" + be1.getHost() +
":" + be1.getHeartbeatPort()
- + "\" set ('tag.location' = 'zone1', 'tag.compute' = 'c1')";
- AlterSystemStmt stmt = (AlterSystemStmt)
UtFrameUtils.parseAndAnalyzeStmt(stmtStr3, connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
+ hostPort = be1.getHost() + ":" + be1.getHeartbeatPort();
+ properties = new HashMap<>();
+ properties.put("tag.location", "zone1");
+ properties.put("tag.compute", "c1");
+ op = new ModifyBackendOp(ImmutableList.of(hostPort), properties);
+ AlterSystemCommand command1 = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_MODIFY_BACKEND);
+ command1.doRun(connectContext, new StmtExecutor(connectContext, ""));
+
Map<String, String> tagMap = be1.getTagMap();
Assert.assertEquals(2, tagMap.size());
Assert.assertEquals("zone1", tagMap.get(Tag.TYPE_LOCATION));
@@ -321,10 +342,12 @@ public class TabletRepairAndBalanceTest {
// set tag for all backends. 0-2 to zone1, 4 and 5 to zone2
// and wait all replica reallocating to correct backend
Backend be = backends.get(2);
- String stmtStr = "alter system modify backend \"" + be.getHost() + ":"
+ be.getHeartbeatPort()
- + "\" set ('tag.location' = 'zone2')";
- stmt = (AlterSystemStmt) UtFrameUtils.parseAndAnalyzeStmt(stmtStr,
connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
+ hostPort = be.getHost() + ":" + be.getHeartbeatPort();
+ Map<String, String> properties1 = new HashMap<>();
+ properties1.put("tag.location", "zone2");
+ op = new ModifyBackendOp(ImmutableList.of(hostPort), properties1);
+ AlterSystemCommand command2 = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_MODIFY_BACKEND);
+ command2.doRun(connectContext, new StmtExecutor(connectContext, ""));
Assert.assertEquals(tag2, be.getLocationTag());
Thread.sleep(5000);
checkTableReplicaAllocation(tbl);
@@ -383,10 +406,12 @@ public class TabletRepairAndBalanceTest {
// [0, 1, 4]: zone1
// [2, 3]: zone2
be = backends.get(4);
- stmtStr = "alter system modify backend \"" + be.getHost() + ":" +
be.getHeartbeatPort()
- + "\" set ('tag.location' = 'zone1')";
- stmt = (AlterSystemStmt) UtFrameUtils.parseAndAnalyzeStmt(stmtStr,
connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
+ hostPort = be.getHost() + ":" + be.getHeartbeatPort();
+ Map<String, String> properties2 = new HashMap<>();
+ properties2.put("tag.location", "zone1");
+ op = new ModifyBackendOp(ImmutableList.of(hostPort), properties2);
+ AlterSystemCommand command3 = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_MODIFY_BACKEND);
+ command3.doRun(connectContext, new StmtExecutor(connectContext, ""));
Assert.assertEquals(tag1, be.getLocationTag());
Thread.sleep(5000);
tbl.checkReplicaAllocation();
@@ -436,11 +461,14 @@ public class TabletRepairAndBalanceTest {
// set all backends' tag to default
for (int i = 0; i < backends.size(); ++i) {
Backend backend = backends.get(i);
- String backendStmt = "alter system modify backend \"" +
backend.getHost() + ":" + backend.getHeartbeatPort()
- + "\" set ('tag.location' = 'default')";
- AlterSystemStmt systemStmt = (AlterSystemStmt)
UtFrameUtils.parseAndAnalyzeStmt(backendStmt,
- connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), systemStmt);
+ // "alter system modify backend \"" + backend.getHost() + ":" +
backend.getHeartbeatPort()
+ // + "\" set ('tag.location' = 'default')";
+ hostPort = backend.getHost() + ":" + backend.getHeartbeatPort();
+ Map<String, String> properties3 = new HashMap<>();
+ properties3.put("tag.location", "default");
+ op = new ModifyBackendOp(ImmutableList.of(hostPort), properties3);
+ AlterSystemCommand command4 = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_MODIFY_BACKEND);
+ command4.doRun(connectContext, new StmtExecutor(connectContext,
""));
}
Assert.assertEquals(Tag.DEFAULT_BACKEND_TAG,
backends.get(0).getLocationTag());
Assert.assertEquals(Tag.DEFAULT_BACKEND_TAG,
backends.get(1).getLocationTag());
@@ -515,10 +543,10 @@ public class TabletRepairAndBalanceTest {
//test cancel decommission backend by ids
-
- String stmtStr4 = "alter system decommission backend \"" +
be.getHost() + ":" + be.getHeartbeatPort() + "\"";
- stmt = (AlterSystemStmt) UtFrameUtils.parseAndAnalyzeStmt(stmtStr4,
connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
+ hostPort = be.getHost() + ":" + be.getHeartbeatPort();
+ DecommissionBackendOp op1 = new
DecommissionBackendOp(ImmutableList.of(hostPort));
+ AlterSystemCommand command5 = new AlterSystemCommand(op1,
PlanType.ALTER_SYSTEM_DECOMMISSION_BACKEND);
+ command5.doRun(connectContext, new StmtExecutor(connectContext, ""));
String stmtStr5 = "cancel decommission backend \"" + be.getId() + "\"";
CancelAlterSystemStmt cancelAlterSystemStmt = (CancelAlterSystemStmt)
UtFrameUtils.parseAndAnalyzeStmt(stmtStr5, connectContext);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/cluster/DecommissionBackendTest.java
b/fe/fe-core/src/test/java/org/apache/doris/cluster/DecommissionBackendTest.java
index f5b075a231e..7f7ee401fa6 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/cluster/DecommissionBackendTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/cluster/DecommissionBackendTest.java
@@ -17,7 +17,6 @@
package org.apache.doris.cluster;
-import org.apache.doris.analysis.AlterSystemStmt;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MaterializedIndex;
@@ -30,10 +29,15 @@ import org.apache.doris.catalog.TabletMeta;
import org.apache.doris.clone.RebalancerTestUtil;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.commands.AlterSystemCommand;
+import
org.apache.doris.nereids.trees.plans.commands.info.DecommissionBackendOp;
+import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.system.Backend;
import org.apache.doris.thrift.TStorageMedium;
import org.apache.doris.utframe.TestWithFeService;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import org.junit.jupiter.api.Assertions;
@@ -101,9 +105,11 @@ public class DecommissionBackendTest extends
TestWithFeService {
}
Assertions.assertNotNull(srcBackend);
- String decommissionStmtStr = "alter system decommission backend \"" +
srcBackend.getAddress() + "\"";
- AlterSystemStmt decommissionStmt = (AlterSystemStmt)
parseAndAnalyzeStmt(decommissionStmtStr);
-
Env.getCurrentEnv().getAlterInstance().processAlterSystem(decommissionStmt);
+ // "alter system decommission backend \"" + srcBackend.getAddress() +
"\"";
+ String hostPort = srcBackend.getHost() + ":" +
srcBackend.getHeartbeatPort();
+ DecommissionBackendOp op = new
DecommissionBackendOp(ImmutableList.of(hostPort));
+ AlterSystemCommand command = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_DECOMMISSION_BACKEND);
+ command.doRun(connectContext, new StmtExecutor(connectContext, ""));
Assertions.assertTrue(srcBackend.isDecommissioned());
long startTimestamp = System.currentTimeMillis();
@@ -154,9 +160,11 @@ public class DecommissionBackendTest extends
TestWithFeService {
Assertions.assertNotNull(srcBackend);
// decommission backend by id
- String decommissionByIdStmtStr = "alter system decommission backend
\"" + srcBackend.getId() + "\"";
- AlterSystemStmt decommissionByIdStmt = (AlterSystemStmt)
parseAndAnalyzeStmt(decommissionByIdStmtStr);
-
Env.getCurrentEnv().getAlterInstance().processAlterSystem(decommissionByIdStmt);
+ // "alter system decommission backend \"" + srcBackend.getId() + "\"";
+ String hostPort = srcBackend.getHost() + ":" +
srcBackend.getHeartbeatPort();
+ DecommissionBackendOp op = new
DecommissionBackendOp(ImmutableList.of(hostPort));
+ AlterSystemCommand command = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_DECOMMISSION_BACKEND);
+ command.doRun(connectContext, new StmtExecutor(connectContext, ""));
Assertions.assertTrue(srcBackend.isDecommissioned());
long startTimestamp = System.currentTimeMillis();
@@ -241,9 +249,11 @@ public class DecommissionBackendTest extends
TestWithFeService {
// 4. query tablet num
int tabletNum =
Env.getCurrentInvertedIndex().getTabletMetaMap().size();
- String decommissionStmtStr = "alter system decommission backend \"" +
srcBackend.getAddress() + "\"";
- AlterSystemStmt decommissionStmt = (AlterSystemStmt)
parseAndAnalyzeStmt(decommissionStmtStr);
-
Env.getCurrentEnv().getAlterInstance().processAlterSystem(decommissionStmt);
+ // "alter system decommission backend \"" + srcBackend.getAddress() +
"\"";
+ String hostPort = srcBackend.getHost() + ":" +
srcBackend.getHeartbeatPort();
+ DecommissionBackendOp op = new
DecommissionBackendOp(ImmutableList.of(hostPort));
+ AlterSystemCommand command = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_DECOMMISSION_BACKEND);
+ command.doRun(connectContext, new StmtExecutor(connectContext, ""));
Assertions.assertTrue(srcBackend.isDecommissioned());
long startTimestamp = System.currentTimeMillis();
@@ -318,9 +328,11 @@ public class DecommissionBackendTest extends
TestWithFeService {
invertIndex.addTablet(fakeTabletId, fakeTabletMeta);
invertIndex.addReplica(fakeTabletId, fakeReplica);
- String decommissionStmtStr = "alter system decommission backend
\"" + srcBackend.getAddress() + "\"";
- AlterSystemStmt decommissionStmt = (AlterSystemStmt)
parseAndAnalyzeStmt(decommissionStmtStr);
-
Env.getCurrentEnv().getAlterInstance().processAlterSystem(decommissionStmt);
+ // "alter system decommission backend \"" +
srcBackend.getAddress() + "\"";
+ String hostPort = srcBackend.getHost() + ":" +
srcBackend.getHeartbeatPort();
+ DecommissionBackendOp op = new
DecommissionBackendOp(ImmutableList.of(hostPort));
+ AlterSystemCommand command = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_DECOMMISSION_BACKEND);
+ command.doRun(connectContext, new StmtExecutor(connectContext,
""));
Assertions.assertTrue(srcBackend.isDecommissioned());
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/planner/ResourceTagQueryTest.java
b/fe/fe-core/src/test/java/org/apache/doris/planner/ResourceTagQueryTest.java
index 382564425eb..00fa9c9c618 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/planner/ResourceTagQueryTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/planner/ResourceTagQueryTest.java
@@ -18,7 +18,6 @@
package org.apache.doris.planner;
import org.apache.doris.analysis.AlterDatabasePropertyStmt;
-import org.apache.doris.analysis.AlterSystemStmt;
import org.apache.doris.analysis.AlterTableStmt;
import org.apache.doris.analysis.CreateDbStmt;
import org.apache.doris.analysis.CreateTableStmt;
@@ -38,8 +37,11 @@ import org.apache.doris.common.ExceptionChecker;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.UserException;
import org.apache.doris.mysql.privilege.Auth;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.commands.AlterSystemCommand;
+import org.apache.doris.nereids.trees.plans.commands.info.ModifyBackendOp;
import org.apache.doris.qe.ConnectContext;
-import org.apache.doris.qe.DdlExecutor;
+import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.resource.Tag;
import org.apache.doris.resource.computegroup.AllBackendComputeGroup;
import org.apache.doris.resource.computegroup.ComputeGroup;
@@ -49,6 +51,7 @@ import org.apache.doris.thrift.TDisk;
import org.apache.doris.thrift.TStorageMedium;
import org.apache.doris.utframe.UtFrameUtils;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -60,6 +63,7 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -239,10 +243,14 @@ public class ResourceTagQueryTest {
if (i > 2) {
break;
}
- String stmtStr = "alter system modify backend \"" + be.getHost() +
":" + be.getHeartbeatPort()
- + "\" set ('tag.location' = '" + tag + "')";
- AlterSystemStmt stmt = (AlterSystemStmt)
UtFrameUtils.parseAndAnalyzeStmt(stmtStr, connectContext);
- DdlExecutor.execute(Env.getCurrentEnv(), stmt);
+ // "alter system modify backend \"" + be.getHost() + ":" +
be.getHeartbeatPort()
+ // + "\" set ('tag.location' = '" + tag + "')";
+ String hostPort = be.getHost() + ":" + be.getHeartbeatPort();
+ Map<String, String> properties = new HashMap<>();
+ properties.put("tag.location", tag);
+ ModifyBackendOp op = new
ModifyBackendOp(ImmutableList.of(hostPort), properties);
+ AlterSystemCommand command = new AlterSystemCommand(op,
PlanType.ALTER_SYSTEM_MODIFY_BACKEND);
+ command.doRun(connectContext, new StmtExecutor(connectContext,
""));
}
Assert.assertEquals(tag1, backends.get(0).getLocationTag());
Assert.assertEquals(tag1, backends.get(1).getLocationTag());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]