diff --git a/src/replica/replication_app_base.cpp b/src/replica/replication_app_base.cpp
index 0455772599..9301174307 100644
--- a/src/replica/replication_app_base.cpp
+++ b/src/replica/replication_app_base.cpp
@@ -72,6 +72,11 @@ const std::string replica_app_info::kAppInfo = ".app-info";
const std::string replica_init_info::kInitInfo = ".init-info";
const std::string kms_info::kKmsInfo = ".kms-info";
+blob replica_init_info::serialize() const
+{
+ return dsn::json::json_forwarder::encode(*this);
+}
+
std::string replica_init_info::to_string() const
{
return fmt::format(
@@ -96,7 +101,7 @@ error_code replica_app_info::load(const std::string &fname)
return ERR_OK;
}
-error_code replica_app_info::store(const std::string &fname)
+blob replica_app_info::serialize() const
{
binary_writer writer;
int magic = 0xdeadbeef;
@@ -107,6 +112,8 @@ error_code replica_app_info::store(const std::string &fname)
} else {
// for most envs, do not persistent them to app info file
// ROCKSDB_ALLOW_INGEST_BEHIND should be persistent
+ // TODO(yingchun): Add SPLIT_VALIDATE_PARTITION_HASH to avoid data re-appears after backup
+ // and restore.
app_info tmp = *_app;
tmp.envs.clear();
const auto &iter = _app->envs.find(replica_envs::ROCKSDB_ALLOW_INGEST_BEHIND);
@@ -116,8 +123,13 @@ error_code replica_app_info::store(const std::string &fname)
marshall(writer, tmp, DSF_THRIFT_JSON);
}
- return dsn::utils::write_data_to_file(
- fname, writer.get_buffer(), dsn::utils::FileDataType::kSensitive);
+ // TODO(yingchun): Is there data copy?
+ return writer.get_buffer();
+}
+
+error_code replica_app_info::store(const std::string &fname)
+{
+ return dsn::utils::write_data_to_file(fname, serialize(), dsn::utils::FileDataType::kSensitive);
}
const std::string replication_app_base::kDataDir = "data";
diff --git a/src/replica/replication_app_base.h b/src/replica/replication_app_base.h
index c3559c095d..a9d3e136a0 100644
--- a/src/replica/replication_app_base.h
+++ b/src/replica/replication_app_base.h
@@ -70,6 +70,8 @@ class replica_init_info
static const std::string kInitInfo;
+ blob serialize() const;
+
private:
std::string to_string() const;
};
@@ -79,6 +81,8 @@ class replica_app_info
public:
static const std::string kAppInfo;
+ blob serialize() const;
+
private:
app_info *_app;
diff --git a/src/shell/commands.h b/src/shell/commands.h
index 24754aa84d..212b5f8cec 100644
--- a/src/shell/commands.h
+++ b/src/shell/commands.h
@@ -288,3 +288,7 @@ bool detect_hotkey(command_executor *e, shell_context *sc, arguments args);
// == local partition split (see 'commands/local_partition_split.cpp') == //
extern const std::string local_partition_split_help;
bool local_partition_split(command_executor *e, shell_context *sc, arguments args);
+
+// == local partition split (see 'commands/files_operations.cpp') == //
+extern const std::string update_info_file_help;
+bool update_info_file(command_executor *e, shell_context *sc, arguments args);
diff --git a/src/shell/commands/files_operations.cpp b/src/shell/commands/files_operations.cpp
new file mode 100644
index 0000000000..08d58368fc
--- /dev/null
+++ b/src/shell/commands/files_operations.cpp
@@ -0,0 +1,282 @@
+// 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.
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include