levy5307 commented on code in PR #1477:
URL:
https://github.com/apache/incubator-pegasus/pull/1477#discussion_r1201888318
##########
src/common/fs_manager.cpp:
##########
@@ -359,5 +395,77 @@ bool fs_manager::is_dir_node_available(const std::string
&data_dir, const std::s
return false;
}
+dir_node *fs_manager::find_replica_dir(const char *app_type, gpid pid)
+{
+ std::string replica_dir;
+ dir_node *replica_dn = nullptr;
+ {
+ zauto_read_lock l(_lock);
+ for (const auto &dn : _dir_nodes) {
+ const auto dir = dn->replica_dir(app_type, pid);
+ if (utils::filesystem::directory_exists(dir)) {
+ // Check if there are duplicate replica instance directories.
+ CHECK(replica_dir.empty(), "replica dir conflict: {} <--> {}",
dir, replica_dir);
+ replica_dir = dir;
+ replica_dn = dn.get();
+ }
+ }
+ }
+
+ return replica_dn;
+}
+
+dir_node *fs_manager::create_replica_dir_if_necessary(const char *app_type,
gpid pid)
+{
+ // Try to find the replica directory.
+ dir_node *replica_dn = find_replica_dir(app_type, pid);
Review Comment:
auto replica_dn
##########
src/replica/disk_cleaner.cpp:
##########
@@ -67,14 +68,14 @@ const std::string kFolderSuffixBak = ".bak";
const std::string kFolderSuffixOri = ".ori";
const std::string kFolderSuffixTmp = ".tmp";
-error_s disk_remove_useless_dirs(const std::vector<std::string> &data_dirs,
+error_s disk_remove_useless_dirs(const std::vector<std::shared_ptr<dir_node>>
&dir_nodes,
Review Comment:
What about using `weak_ptr` instead of shared_ptr?
--
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]