empiredan commented on code in PR #1272:
URL:
https://github.com/apache/incubator-pegasus/pull/1272#discussion_r1042888650
##########
src/meta/test/meta_app_operation_test.cpp:
##########
@@ -795,5 +809,37 @@ TEST_F(meta_app_operation_test,
recover_from_max_replica_count_env)
verify_app_max_replica_count(APP_NAME, new_max_replica_count);
}
+TEST_F(meta_app_operation_test, rename_app)
+{
+ const std::string app_name_1 = APP_NAME + "_rename_1";
+ create_app(app_name_1);
+ auto app = find_app(app_name_1);
+ CHECK(app, "app({}) does not exist", app_name_1);
+ auto app_id_1 = app->app_id;
+
+ const std::string app_name_2 = APP_NAME + "_rename_2";
+ create_app(app_name_2);
+ app = find_app(app_name_2);
+ CHECK(app, "app({}) does not exist", app_name_2);
+ auto app_id_2 = app->app_id;
+
+ const std::string app_name_3 = APP_NAME + "_rename_3";
+
+ // case 1: new_app_name table exist
+ auto resp = rename_app(app_name_1, app_name_2);
+ ASSERT_EQ(ERR_INVALID_PARAMETERS, resp.err);
+
Review Comment:
Could add a case that if the new app name has invalid character.
##########
src/meta/server_state.cpp:
##########
@@ -1259,6 +1259,105 @@ void server_state::drop_app(dsn::message_ex *msg)
}
}
+void server_state::do_app_rename(configuration_rename_app_rpc rpc)
+{
+ zauto_write_lock l(_lock);
+
+ const auto &old_app_name = rpc.request().old_app_name;
+ const auto &new_app_name = rpc.request().new_app_name;
+
+ auto target_app = get_app(old_app_name);
+ auto app_id = target_app->app_id;
+
+ auto ainfo = *(reinterpret_cast<app_info *>(target_app.get()));
+ ainfo.app_name = new_app_name;
+ auto app_path = get_app_path(*target_app);
+
+ target_app->app_name = new_app_name;
+ _exist_apps.emplace(new_app_name, target_app);
Review Comment:
Why not add new app name after updating remote storage ? That will be an
atomic operation including both adding new table name and removing old table
name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]