| 1486 | } |
| 1487 | |
| 1488 | bool DataCache::StoreInternal(const CacheKey& key, const uint8_t* buffer, |
| 1489 | int64_t buffer_len) { |
| 1490 | // Here, a shared lock is acquired with try_to_lock, while a unique lock is acquired in |
| 1491 | // SetDataCacheReadOnly(). Therefore, when setting the read-only status, the lock |
| 1492 | // acquisition here can quickly fail, then return. |
| 1493 | kudu::shared_lock<shared_mutex> lock(readonly_lock_, std::try_to_lock); |
| 1494 | if (UNLIKELY(!lock.owns_lock() || readonly_.Load())) return false; |
| 1495 | |
| 1496 | int idx = key.Hash() % partitions_.size(); |
| 1497 | bool start_reclaim; |
| 1498 | bool stored = partitions_[idx]->Store(key, buffer, buffer_len, &start_reclaim); |
| 1499 | if (VLOG_IS_ON(3)) { |
| 1500 | stringstream ss; |
| 1501 | ss << std::hex << reinterpret_cast<int64_t>(buffer); |
| 1502 | LOG(INFO) << Substitute("Storing $0 mtime: $1 offset: $2 bytes_to_read: $3 " |
| 1503 | "buffer: 0x$4 stored: $5", key.filename().ToString(), key.mtime(), key.offset(), |
| 1504 | buffer_len, ss.str(), stored); |
| 1505 | } |
| 1506 | if (start_reclaim) file_deleter_pool_->Offer(idx); |
| 1507 | return stored; |
| 1508 | } |
| 1509 | |
| 1510 | void DataCache::Partition::Trace( |
| 1511 | const trace::EventType& type, const DataCache::CacheKey& key, |
nothing calls this directly
no test coverage detected