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

refactor: mv session_timeout to cluster router options and rename to it #1965

Merged
merged 1 commit into from
Jun 15, 2022
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 @@ -64,7 +64,7 @@ public SqlClusterExecutor(SdkOption option, String libraryPath) throws SqlExcept

if (option.isClusterMode()) {
SQLRouterOptions sqlOpt = new SQLRouterOptions();
sqlOpt.setSession_timeout(option.getSessionTimeout());
sqlOpt.setZk_session_timeout(option.getSessionTimeout());
sqlOpt.setZk_cluster(option.getZkCluster());
sqlOpt.setZk_path(option.getZkPath());
sqlOpt.setEnable_debug(option.getEnableDebug());
Expand All @@ -73,7 +73,6 @@ public SqlClusterExecutor(SdkOption option, String libraryPath) throws SqlExcept
sqlOpt.delete();
} else {
StandaloneOptions sqlOpt = new StandaloneOptions();
sqlOpt.setSession_timeout(option.getSessionTimeout());
sqlOpt.setEnable_debug(option.getEnableDebug());
sqlOpt.setRequest_timeout(option.getRequestTimeout());
sqlOpt.setHost(option.getHost());
Expand Down
2 changes: 1 addition & 1 deletion python/openmldb/sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OpenMLDBClusterSdkOptions(object):
def __init__(self, zk_cluster, zk_path, session_timeout=3000):
self.zk_cluster = zk_cluster
self.zk_path = zk_path
self.session_timeout = session_timeout
self.zk_session_timeout = session_timeout


class OpenMLDBStandaloneSdkOptions(object):
Expand Down
2 changes: 1 addition & 1 deletion src/apiserver/api_server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class APIServerTestEnv : public testing::Environment {
ASSERT_TRUE(queue_svc->Init(cluster_sdk));

sdk::SQLRouterOptions sql_opt;
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.zk_cluster = mc->GetZkCluster();
sql_opt.zk_path = mc->GetZkPath();
// sql_opt.enable_debug = true;
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/sql_cluster_router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ bool SQLClusterRouter::Init() {
ClusterOptions coptions;
coptions.zk_cluster = options_.zk_cluster;
coptions.zk_path = options_.zk_path;
coptions.zk_session_timeout = options_.session_timeout;
coptions.zk_session_timeout = options_.zk_session_timeout;
cluster_sdk_ = new ClusterSDK(coptions);
bool ok = cluster_sdk_->Init();
if (!ok) {
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/sql_cluster_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ TEST_F(SQLSDKQueryTest, GetTabletClient) {
" index(key=col2, ts=col3)) "
"options(partitionnum=2);";
SQLRouterOptions sql_opt;
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
Expand Down Expand Up @@ -677,7 +677,7 @@ static std::shared_ptr<SQLRouter> GetNewSQLRouter() {
SQLRouterOptions sql_opt;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.session_timeout = 60000;
sql_opt.zk_session_timeout = 60000;
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
auto router = NewClusterSQLRouter(sql_opt);
SetOnlineMode(router);
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/sql_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ namespace sdk {

struct BasicRouterOptions {
bool enable_debug = false;
uint32_t session_timeout = 2000;
uint32_t max_sql_cache_size = 10;
uint32_t request_timeout = 60000;
};

struct SQLRouterOptions : BasicRouterOptions {
std::string zk_cluster;
std::string zk_path;
uint32_t zk_session_timeout = 2000;
};

struct StandaloneOptions : BasicRouterOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/sql_router_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ TEST_F(SQLRouterTest, bad_zk) {
SQLRouterOptions sql_opt;
sql_opt.zk_cluster = "127.0.0.1:1111";
sql_opt.zk_path = "/path";
sql_opt.session_timeout = 10;
sql_opt.zk_session_timeout = 10;
auto router = NewClusterSQLRouter(sql_opt);
ASSERT_TRUE(router == nullptr);
}
Expand Down
18 changes: 9 additions & 9 deletions src/sdk/sql_sdk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static std::shared_ptr<SQLRouter> GetNewSQLRouter() {
SQLRouterOptions sql_opt;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.session_timeout = 60000;
sql_opt.zk_session_timeout = 60000;
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
auto router = NewClusterSQLRouter(sql_opt);
SetOnlineMode(router);
Expand Down Expand Up @@ -94,7 +94,7 @@ TEST_P(SQLSDKTest, SqlSdkBatchTest) {
return;
}
SQLRouterOptions sql_opt;
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.enable_debug = sql_case.debug() || hybridse::sqlcase::SqlCase::IsDebug();
Expand Down Expand Up @@ -216,7 +216,7 @@ TEST_F(SQLSDKQueryTest, ExecuteLatestWhereTest) {
"create table latest_table(c1 string, c2 int, c3 timestamp, c4 timestamp, "
"index(key=(c1),ts=c4,ttl_type=latest, ttl=2));";
SQLRouterOptions sql_opt;
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
Expand Down Expand Up @@ -280,7 +280,7 @@ TEST_F(SQLSDKQueryTest, ExecuteWhereTest) {
" index(key=pay_card_no, ts=txn_time),\n"
" index(key=merch_id, ts=txn_time));";
SQLRouterOptions sql_opt;
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
Expand Down Expand Up @@ -357,7 +357,7 @@ TEST_F(SQLSDKQueryTest, ExecuteInsertLoopsTest) {
int64_t error_cnt = 0;
int64_t cnt = 0;
SQLRouterOptions sql_opt;
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
Expand Down Expand Up @@ -410,7 +410,7 @@ TEST_F(SQLSDKQueryTest, CreateNoTs) {
" c2 bigint,\n"
" index(key=c1, ttl=14400m, ttl_type=absolute));";
SQLRouterOptions sql_opt;
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
Expand Down Expand Up @@ -454,7 +454,7 @@ TEST_F(SQLSDKQueryTest, RequestProcedureTest) {
SQLRouterOptions sql_opt;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
auto router = NewClusterSQLRouter(sql_opt);
if (!router) {
Expand Down Expand Up @@ -586,7 +586,7 @@ TEST_F(SQLSDKQueryTest, DropTableWithProcedureTest) {
SQLRouterOptions sql_opt;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
auto router = NewClusterSQLRouter(sql_opt);
if (!router) {
Expand Down Expand Up @@ -791,7 +791,7 @@ TEST_F(SQLSDKQueryTest, ExecuteWhereWithParameter) {
" index(key=pay_card_no, ts=txn_time),\n"
" index(key=merch_id, ts=txn_time));";
SQLRouterOptions sql_opt;
sql_opt.session_timeout = 30000;
sql_opt.zk_session_timeout = 30000;
sql_opt.zk_cluster = mc_->GetZkCluster();
sql_opt.zk_path = mc_->GetZkPath();
sql_opt.enable_debug = hybridse::sqlcase::SqlCase::IsDebug();
Expand Down