| 27 | namespace impala { |
| 28 | |
| 29 | void CacheBaseTest::SetupWithParameters(Cache::EvictionPolicy eviction_policy, |
| 30 | ShardingPolicy sharding_policy) { |
| 31 | // Disable approximate tracking of cache memory since we make specific |
| 32 | // assertions on the MemTracker in this test. |
| 33 | FLAGS_cache_memtracker_approximation_ratio = 0; |
| 34 | |
| 35 | // Using single shard makes the logic of scenarios simple for capacity- |
| 36 | // and eviction-related behavior. |
| 37 | FLAGS_cache_force_single_shard = |
| 38 | (sharding_policy == ShardingPolicy::SingleShard); |
| 39 | |
| 40 | switch (eviction_policy) { |
| 41 | case Cache::EvictionPolicy::FIFO: |
| 42 | cache_.reset(NewCache(Cache::EvictionPolicy::FIFO, cache_size(), "cache_test")); |
| 43 | kudu::MemTracker::FindTracker("cache_test-sharded_fifo_cache", &mem_tracker_); |
| 44 | break; |
| 45 | case Cache::EvictionPolicy::LRU: |
| 46 | cache_.reset(NewCache(Cache::EvictionPolicy::LRU, cache_size(), "cache_test")); |
| 47 | kudu::MemTracker::FindTracker("cache_test-sharded_lru_cache", &mem_tracker_); |
| 48 | break; |
| 49 | case Cache::EvictionPolicy::LIRS: |
| 50 | cache_.reset(NewCache(Cache::EvictionPolicy::LIRS, cache_size(), "cache_test")); |
| 51 | kudu::MemTracker::FindTracker("cache_test-sharded_lirs_cache", &mem_tracker_); |
| 52 | break; |
| 53 | default: |
| 54 | FAIL() << "unrecognized cache eviction policy"; |
| 55 | } |
| 56 | ASSERT_TRUE(mem_tracker_.get()); |
| 57 | Status status = cache_->Init(); |
| 58 | ASSERT_OK(status); |
| 59 | } |
| 60 | |
| 61 | class CacheTest : |
| 62 | public CacheBaseTest, |