Skip to content

Commit

Permalink
rename (#505)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuqing Zhu <yuqing.zhu@139.com>
  • Loading branch information
shinyano and zhuyuqing authored Dec 6, 2024
1 parent f2ff37a commit ec64afa
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 37 deletions.
7 changes: 1 addition & 6 deletions antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ statement
| SHOW TRANSFORM JOB STATUS jobId = INT # showJobStatusStatement
| CANCEL TRANSFORM JOB jobId = INT # cancelJobStatement
| SHOW jobStatus TRANSFORM JOB # showEligibleJobStatement
| REMOVE HISTORYDATASOURCE removedStorageEngine (COMMA removedStorageEngine)* # removeHistoryDataSourceStatement
| REMOVE STORAGEENGINE removedStorageEngine (COMMA removedStorageEngine)* # removeStorageEngineStatement
| SET CONFIG configName = stringLiteral configValue = stringLiteral # setConfigStatement
| SHOW CONFIG (configName = stringLiteral)? # showConfigStatement
| SHOW SESSIONID # showSessionIDStatement
Expand Down Expand Up @@ -561,7 +561,6 @@ keyWords
| RANGE
| STEP
| REMOVE
| HISTORYDATASOURCE
| COMPACT
| EXPLAIN
| LOGICAL
Expand Down Expand Up @@ -997,10 +996,6 @@ REMOVE
: R E M O V E
;

HISTORYDATASOURCE
: H I S T O R Y D A T A S O U R C E
;

COMPACT
: C O M P A C T
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ private static Completer buildIginxCompleter() {
Arrays.asList("show", "functions"),
Arrays.asList("show", "sessionid"),
Arrays.asList("show", "rules"),
Arrays.asList("remove", "historydatasource"));
Arrays.asList("remove", "storageengine"));
addArgumentCompleters(iginxCompleters, withoutNullCompleters, false);

List<String> singleCompleters = Arrays.asList("quit", "exit");
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/cn/edu/tsinghua/iginx/IginxWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public QueryDataResp queryData(QueryDataReq req) {
}

@Override
public Status removeHistoryDataSource(RemoveHistoryDataSourceReq req) {
public Status removeStorageEngine(RemoveStorageEngineReq req) {
if (!sessionManager.checkSession(req.getSessionId(), AuthType.Cluster)) {
return RpcUtils.ACCESS_DENY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class StatementBuilder {
typeMap.put(StatementType.EXPORT_STREAM_FROM_SELECT, SqlType.ExportStream);
typeMap.put(StatementType.ADD_STORAGE_ENGINE, SqlType.AddStorageEngines);
typeMap.put(StatementType.ALTER_STORAGE_ENGINE, SqlType.AlterStorageEngine);
typeMap.put(StatementType.REMOVE_HISTORY_DATA_SOURCE, SqlType.RemoveHistoryDataSource);
typeMap.put(StatementType.REMOVE_HISTORY_DATA_SOURCE, SqlType.RemoveStorageEngine);
typeMap.put(StatementType.SHOW_REPLICATION, SqlType.GetReplicaNum);
typeMap.put(StatementType.COUNT_POINTS, SqlType.CountPoints);
typeMap.put(StatementType.CLEAR_DATA, SqlType.ClearData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
import cn.edu.tsinghua.iginx.sql.SqlParser.PredicateWithSubqueryContext;
import cn.edu.tsinghua.iginx.sql.SqlParser.QueryClauseContext;
import cn.edu.tsinghua.iginx.sql.SqlParser.RegisterTaskStatementContext;
import cn.edu.tsinghua.iginx.sql.SqlParser.RemoveHistoryDataSourceStatementContext;
import cn.edu.tsinghua.iginx.sql.SqlParser.SearchedCaseContext;
import cn.edu.tsinghua.iginx.sql.SqlParser.SearchedWhenClauseContext;
import cn.edu.tsinghua.iginx.sql.SqlParser.SelectClauseContext;
Expand Down Expand Up @@ -653,9 +652,9 @@ private AuthType parseAuthType(String authType) {
}

@Override
public Statement visitRemoveHistoryDataSourceStatement(
RemoveHistoryDataSourceStatementContext ctx) {
RemoveHistoryDataSourceStatement statement = new RemoveHistoryDataSourceStatement();
public Statement visitRemoveStorageEngineStatement(
SqlParser.RemoveStorageEngineStatementContext ctx) {
RemoveStorageEngineStatement statement = new RemoveStorageEngineStatement();
ctx.removedStorageEngine()
.forEach(
storageEngine -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import cn.edu.tsinghua.iginx.engine.shared.RequestContext;
import cn.edu.tsinghua.iginx.engine.shared.Result;
import cn.edu.tsinghua.iginx.engine.shared.exception.StatementExecutionException;
import cn.edu.tsinghua.iginx.thrift.RemoveHistoryDataSourceReq;
import cn.edu.tsinghua.iginx.thrift.RemoveStorageEngineReq;
import cn.edu.tsinghua.iginx.thrift.RemovedStorageEngineInfo;
import java.util.ArrayList;
import java.util.List;

public class RemoveHistoryDataSourceStatement extends SystemStatement {
public class RemoveStorageEngineStatement extends SystemStatement {

private List<RemovedStorageEngineInfo> storageEngineList;

Expand All @@ -44,16 +44,15 @@ public void addStorageEngine(RemovedStorageEngineInfo storageEngine) {
this.storageEngineList.add(storageEngine);
}

public RemoveHistoryDataSourceStatement() {
public RemoveStorageEngineStatement() {
storageEngineList = new ArrayList<>();
this.statementType = StatementType.REMOVE_HISTORY_DATA_SOURCE;
}

@Override
public void execute(RequestContext ctx) throws StatementExecutionException {
IginxWorker worker = IginxWorker.getInstance();
RemoveHistoryDataSourceReq req =
new RemoveHistoryDataSourceReq(ctx.getSessionId(), storageEngineList);
ctx.setResult(new Result(worker.removeHistoryDataSource(req)));
RemoveStorageEngineReq req = new RemoveStorageEngineReq(ctx.getSessionId(), storageEngineList);
ctx.setResult(new Result(worker.removeStorageEngine(req)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -484,17 +484,17 @@ public void addStorageEngines(List<StorageEngine> storageEngines) throws Session
}
}

public void removeHistoryDataSource(List<RemovedStorageEngineInfo> removedStorageEngineList)
public void removeStorageEngine(List<RemovedStorageEngineInfo> removedStorageEngineList)
throws SessionException {
for (int i = 0; i < RETRY; i++) {
Session session = getSession();
try {
session.removeHistoryDataSource(removedStorageEngineList);
session.removeStorageEngine(removedStorageEngineList);
putBack(session);
return;
} catch (SessionException e) {
// TException means the connection is broken, remove it and get a new one.
LOGGER.warn("removeHistoryDataSource failed", e);
LOGGER.warn("remove storage engine failed", e);
cleanSessionAndMayThrowConnectionException(session, i, e);
} catch (RuntimeException e) {
putBack(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,10 @@ public CurveMatchResult curveMatch(
return new CurveMatchResult(ref.resp.getMatchedKey(), ref.resp.getMatchedPath());
}

public void removeHistoryDataSource(List<RemovedStorageEngineInfo> removedStorageEngineList)
public void removeStorageEngine(List<RemovedStorageEngineInfo> removedStorageEngineList)
throws SessionException {
RemoveHistoryDataSourceReq req =
new RemoveHistoryDataSourceReq(sessionId, removedStorageEngineList);
executeWithCheck(() -> client.removeHistoryDataSource(req));
RemoveStorageEngineReq req = new RemoveStorageEngineReq(sessionId, removedStorageEngineList);
executeWithCheck(() -> client.removeStorageEngine(req));
}

public String getUsername() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ protected void testUpdateEngineParams() throws SessionException {
SQLTestTools.executeAndCompare(session, statement, pathList, valuesList);

// 删除,不影响后续测试
session.removeHistoryDataSource(
session.removeStorageEngine(
Collections.singletonList(
new RemovedStorageEngineInfo("127.0.0.1", readOnlyPort, prefix, "")));

Expand Down Expand Up @@ -689,7 +689,7 @@ private void testAddAndRemoveStorageEngineWithPrefix() {
removedStorageEngineList.add(
new RemovedStorageEngineInfo("127.0.0.1", expPort, "p3" + schemaPrefixSuffix, dataPrefix1));
try {
session.removeHistoryDataSource(removedStorageEngineList);
session.removeStorageEngine(removedStorageEngineList);
testShowClusterInfo(4);
} catch (SessionException e) {
LOGGER.error("remove history data source through session api error: ", e);
Expand All @@ -709,7 +709,7 @@ private void testAddAndRemoveStorageEngineWithPrefix() {
SQLTestTools.executeAndCompare(session, statement, pathListAns, EXP_VALUES_LIST2);

// 通过 sql 语句测试移除节点
String removeStatement = "remove historydatasource (\"127.0.0.1\", %d, \"%s\", \"%s\");";
String removeStatement = "remove storageengine (\"127.0.0.1\", %d, \"%s\", \"%s\");";
try {
session.executeSql(
String.format(removeStatement, expPort, "p1" + schemaPrefixSuffix, dataPrefix1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public void commitPythonExportBinaryToIginxTest() {
LOGGER.error("Remove test resource dir failed:", e);
}
try {
session.removeHistoryDataSource(
session.removeStorageEngine(
Collections.singletonList(new RemovedStorageEngineInfo("127.0.0.1", 6660, "", "")));
} catch (SessionException e) {
LOGGER.error("Remove read-only dummy engine failed:", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ private void init() throws SessionException {
public void close() throws SessionException {
RemovedStorageEngineInfo info =
new RemovedStorageEngineInfo(ip, port, schemaPrefix, dataPrefix);
session.removeHistoryDataSource(Collections.singletonList(info));
session.removeStorageEngine(Collections.singletonList(info));
}
}
6 changes: 3 additions & 3 deletions test/src/test/resources/pySessionIT/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def addStorageEngine(self):
cluster_info = self.session.get_cluster_info()
retStr += str(cluster_info) + "\n"
# 删除加入的存储引擎
self.session.execute_sql('REMOVE HISTORYDATASOURCE ("127.0.0.1", 6670, "", "");')
self.session.execute_sql('REMOVE STORAGEENGINE ("127.0.0.1", 6670, "", "");')
# 删除后输出所有存储引擎
cluster_info = self.session.get_cluster_info()
retStr += str(cluster_info) + "\n"
Expand Down Expand Up @@ -102,8 +102,8 @@ def addStorageEngine(self):
cluster_info = self.session.get_cluster_info()
retStr += str(cluster_info) + "\n"
# 删除加入的存储引擎
self.session.execute_sql('REMOVE HISTORYDATASOURCE ("127.0.0.1", 6670, "", "");')
self.session.execute_sql('REMOVE HISTORYDATASOURCE ("127.0.0.1", 6671, "", "");')
self.session.execute_sql('REMOVE STORAGEENGINE ("127.0.0.1", 6670, "", "");')
self.session.execute_sql('REMOVE STORAGEENGINE ("127.0.0.1", 6671, "", "");')
# 删除新建的parquet文件
os.remove('pq/dummy/example.parquet')
# 删除新建的文件夹
Expand Down
6 changes: 3 additions & 3 deletions thrift/src/main/thrift/rpc.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum SqlType {
ShowJobStatus,
CancelJob,
ShowEligibleJob,
RemoveHistoryDataSource,
RemoveStorageEngine,
SetConfig,
ShowConfig,
Compact,
Expand Down Expand Up @@ -699,7 +699,7 @@ struct RemovedStorageEngineInfo {
4: required string dataPrefix
}

struct RemoveHistoryDataSourceReq {
struct RemoveStorageEngineReq {
1: required i64 sessionId
2: required list<RemovedStorageEngineInfo> removedStorageEngineInfoList
}
Expand Down Expand Up @@ -751,7 +751,7 @@ service IService {

Status alterStorageEngine(1: AlterStorageEngineReq req);

Status removeHistoryDataSource(1: RemoveHistoryDataSourceReq req);
Status removeStorageEngine(1: RemoveStorageEngineReq req);

AggregateQueryResp aggregateQuery(1: AggregateQueryReq req);

Expand Down

0 comments on commit ec64afa

Please sign in to comment.