MCPcopy Create free account
hub / github.com/apache/kudu / CreateInitialFileSystemLayout

Method CreateInitialFileSystemLayout

src/kudu/fs/fs_manager.cc:853–923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

851}
852
853Status FsManager::CreateInitialFileSystemLayout(optional<string> uuid,
854 optional<string> tenant_name,
855 optional<string> tenant_id,
856 optional<string> encryption_key,
857 optional<string> encryption_key_iv,
858 optional<string> encryption_key_version) {
859 CHECK(!opts_.read_only);
860
861 RETURN_NOT_OK(Init());
862
863 // In the event of failure, delete everything we created.
864 vector<string> created_dirs;
865 vector<string> created_files;
866 auto deleter = MakeScopedCleanup([&]() {
867 // Delete files first so that the directories will be empty when deleted.
868 for (const auto& f : created_files) {
869 WARN_NOT_OK(GetEnv()->DeleteFile(f), "Could not delete file " + f);
870 }
871 // Delete directories in reverse order since parent directories will have
872 // been added before child directories.
873 for (auto it = created_dirs.rbegin(); it != created_dirs.rend(); it++) {
874 WARN_NOT_OK(GetEnv()->DeleteDir(*it), "Could not delete dir " + *it);
875 }
876 });
877
878 // Create the filesystem roots.
879 //
880 // Files/directories created will NOT be synchronized to disk.
881 InstanceMetadataPB metadata;
882 string tid = tenant_id ? *tenant_id : fs::kDefaultTenantID;
883 RETURN_NOT_OK_PREPEND(CreateInstanceMetadata(std::move(uuid),
884 std::move(tenant_name),
885 std::move(tenant_id),
886 std::move(encryption_key),
887 std::move(encryption_key_iv),
888 std::move(encryption_key_version),
889 &metadata),
890 "unable to create instance metadata");
891 RETURN_NOT_OK_PREPEND(FsManager::CreateFileSystemRoots(
892 canonicalized_all_fs_roots_, metadata, &created_dirs, &created_files),
893 "unable to create file system roots");
894
895 // Create ancillary directories.
896 vector<string> ancillary_dirs = { GetWalsRootDir(),
897 GetTabletMetadataDir(),
898 GetConsensusMetadataDir() };
899 for (const string& dir : ancillary_dirs) {
900 bool created;
901 RETURN_NOT_OK_PREPEND(env_util::CreateDirIfMissing(GetEnv(), dir, &created),
902 Substitute("Unable to create directory $0", dir));
903 if (created) {
904 created_dirs.emplace_back(dir);
905 }
906 }
907
908 // Create the directory manager.
909 //
910 // All files/directories created will be synchronized to disk.

Callers 15

TEST_FFunction · 0.80
FormatFunction · 0.80
TEST_FFunction · 0.80
TEST_FFunction · 0.80
SetUpMethod · 0.80
SetUpMethod · 0.80
CreateMethod · 0.80
SetUpMethod · 0.80
SetUpMethod · 0.80
SetUpMethod · 0.80
InitMethod · 0.80
SetUpMethod · 0.80

Calls 11

InitFunction · 0.85
MakeScopedCleanupFunction · 0.85
CreateDirIfMissingFunction · 0.85
SubstituteFunction · 0.85
SyncAllParentDirsFunction · 0.85
OKFunction · 0.85
rbeginMethod · 0.80
rendMethod · 0.80
DeleteDirMethod · 0.80
cancelMethod · 0.80
DeleteFileMethod · 0.45

Tested by 15

TEST_FFunction · 0.64
TEST_FFunction · 0.64
TEST_FFunction · 0.64
SetUpMethod · 0.64
SetUpMethod · 0.64
SetUpMethod · 0.64
SetUpMethod · 0.64
SetUpMethod · 0.64
SetUpMethod · 0.64
SetUpMethod · 0.64
SetUpMethod · 0.64
SetUpMethod · 0.64