MCPcopy Create free account
hub / github.com/apache/impala / TestTmpFileBufferPoolHelper

Method TestTmpFileBufferPoolHelper

be/src/runtime/tmp-file-mgr-test.cc:1885–1930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1883}
1884
1885void TmpFileMgrTest::TestTmpFileBufferPoolHelper(TmpFileMgr& tmp_file_mgr,
1886 unique_ptr<TmpFileGroup>* tmp_file_group,
1887 boost::scoped_ptr<io::WriteRange>& write_range,
1888 WriteRange::WriteDoneCallback& callback) {
1889 TUniqueId id;
1890 vector<string> tmp_create_dirs{{LOCAL_BUFFER_PATH}};
1891 vector<string> tmp_dirs{{Substitute(LOCAL_BUFFER_PATH + ":$0", 2048)}};
1892 RemoveAndCreateDirs(tmp_create_dirs);
1893 tmp_dirs.push_back(remote_url_);
1894 int64_t alloc_size = 1024;
1895 int64_t file_size = 1024;
1896 FLAGS_remote_tmp_file_size = "1KB";
1897 int64_t offset;
1898 TmpFile *file1, *file2, *file3;
1899 cb_counter_ = 0;
1900
1901 ASSERT_OK(tmp_file_mgr.InitCustom(tmp_dirs, false, "", false, metrics_.get()));
1902 unique_ptr<TmpFileGroup> unique_file_group =
1903 make_unique<TmpFileGroup>(&tmp_file_mgr, io_mgr(), profile_, id);
1904 auto file_group = unique_file_group.get();
1905 EXPECT_EQ(tmp_file_mgr.GetRemoteTmpFileSize(), file_size);
1906 IntGauge* dir_usage_local = metrics_->FindMetricForTesting<IntGauge>(
1907 "tmp-file-mgr.scratch-space-bytes-used.dir-0");
1908 ASSERT_TRUE(dir_usage_local != nullptr);
1909 ASSERT_OK(GroupAllocateSpace(file_group, alloc_size, &file1, &offset));
1910 EXPECT_EQ(file_size, dir_usage_local->GetValue());
1911 ASSERT_OK(GroupAllocateSpace(file_group, alloc_size, &file2, &offset));
1912 EXPECT_NE(file1, file2);
1913 EXPECT_TRUE(file1->GetWriteFile()->IsSpaceReserved());
1914 EXPECT_TRUE(file2->GetWriteFile()->IsSpaceReserved());
1915 ASSERT_OK(GroupAllocateSpace(file_group, alloc_size, &file3, &offset));
1916 EXPECT_NE(file2, file3);
1917
1918 write_range.reset(new WriteRange(
1919 file3->path(), offset, file3->AssignDiskQueue(!file3->is_local()), callback));
1920 const char* dummy_data = "dummy data";
1921 write_range->SetData((const uint8_t*)dummy_data, strlen(dummy_data));
1922 write_range->SetDiskFile(file3->GetWriteFile());
1923 SetWriteRangeContext(write_range.get(), file_group);
1924 // The space hasn't been reserved for file3 because the pool size is 2K, and there are
1925 // two files in use, we use the AsyncWriteRange() function to wait until a file is
1926 // available to be evicted, then finish the writing of file3.
1927 EXPECT_FALSE(file3->GetWriteFile()->IsSpaceReserved());
1928 ASSERT_OK(tmp_file_mgr.AsyncWriteRange(write_range.get(), file3));
1929 *tmp_file_group = move(unique_file_group);
1930}
1931
1932void TmpFileMgrTest::TestTmpFileBufferPoolTearDown(TmpFileMgr& tmp_file_mgr) {
1933 auto tmp_file_pool = tmp_file_mgr.tmp_dirs_remote_ctrl_.tmp_file_pool_.get();

Callers

nothing calls this directly

Calls 15

SubstituteFunction · 0.85
moveFunction · 0.85
push_backMethod · 0.80
InitCustomMethod · 0.80
GetRemoteTmpFileSizeMethod · 0.80
IsSpaceReservedMethod · 0.80
pathMethod · 0.80
AssignDiskQueueMethod · 0.80
SetDiskFileMethod · 0.80
AsyncWriteRangeMethod · 0.80
getMethod · 0.65
resetMethod · 0.65

Tested by

no test coverage detected