MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GcsFileSystem

Method GcsFileSystem

tensorflow/core/platform/cloud/gcs_file_system.cc:730–880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

728} // namespace
729
730GcsFileSystem::GcsFileSystem(bool make_default_cache) {
731 uint64 value;
732 block_size_ = kDefaultBlockSize;
733 size_t max_bytes = kDefaultMaxCacheSize;
734 uint64 max_staleness = kDefaultMaxStaleness;
735
736 http_request_factory_ = std::make_shared<CurlHttpRequest::Factory>();
737 compute_engine_metadata_client_ =
738 std::make_shared<ComputeEngineMetadataClient>(http_request_factory_);
739 auth_provider_ = std::unique_ptr<AuthProvider>(
740 new GoogleAuthProvider(compute_engine_metadata_client_));
741 zone_provider_ = std::unique_ptr<ZoneProvider>(
742 new ComputeEngineZoneProvider(compute_engine_metadata_client_));
743
744 // Apply the sys env override for the readahead buffer size if it's provided.
745 if (GetEnvVar(kReadaheadBufferSize, strings::safe_strtou64, &value)) {
746 block_size_ = value;
747 }
748
749 // Apply the overrides for the block size (MB), max bytes (MB), and max
750 // staleness (seconds) if provided.
751 if (GetEnvVar(kBlockSize, strings::safe_strtou64, &value)) {
752 block_size_ = value * 1024 * 1024;
753 }
754
755 if (GetEnvVar(kMaxCacheSize, strings::safe_strtou64, &value)) {
756 max_bytes = value * 1024 * 1024;
757 }
758
759 if (GetEnvVar(kMaxStaleness, strings::safe_strtou64, &value)) {
760 max_staleness = value;
761 }
762 if (!make_default_cache) {
763 max_bytes = 0;
764 }
765 VLOG(1) << "GCS cache max size = " << max_bytes << " ; "
766 << "block size = " << block_size_ << " ; "
767 << "max staleness = " << max_staleness;
768 file_block_cache_ = MakeFileBlockCache(block_size_, max_bytes, max_staleness);
769 // Apply overrides for the stat cache max age and max entries, if provided.
770 uint64 stat_cache_max_age = kStatCacheDefaultMaxAge;
771 size_t stat_cache_max_entries = kStatCacheDefaultMaxEntries;
772 if (GetEnvVar(kStatCacheMaxAge, strings::safe_strtou64, &value)) {
773 stat_cache_max_age = value;
774 }
775 if (GetEnvVar(kStatCacheMaxEntries, strings::safe_strtou64, &value)) {
776 stat_cache_max_entries = value;
777 }
778 stat_cache_.reset(new ExpiringLRUCache<GcsFileStat>(stat_cache_max_age,
779 stat_cache_max_entries));
780 // Apply overrides for the matching paths cache max age and max entries, if
781 // provided.
782 uint64 matching_paths_cache_max_age = kMatchingPathsCacheDefaultMaxAge;
783 size_t matching_paths_cache_max_entries =
784 kMatchingPathsCacheDefaultMaxEntries;
785 if (GetEnvVar(kMatchingPathsCacheMaxAge, strings::safe_strtou64, &value)) {
786 matching_paths_cache_max_age = value;
787 }

Callers

nothing calls this directly

Calls 5

SetConfigMethod · 0.80
GetEnvVarFunction · 0.70
resetMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected