2022-01-17 11:52:51 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Core/Types.h>
|
|
|
|
#include <optional>
|
|
|
|
#include <memory>
|
|
|
|
#include <Common/ZooKeeper/ZooKeeperLock.h>
|
|
|
|
#include <Common/ZooKeeper/ZooKeeper.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Very simple wrapper for zookeeper ephemeral lock. It's better to have it
|
2022-01-17 11:54:51 +00:00
|
|
|
/// because due to bad abstraction we use it in MergeTreeData.
|
2022-01-17 11:52:51 +00:00
|
|
|
struct ZeroCopyLock
|
|
|
|
{
|
2023-05-03 21:54:24 +00:00
|
|
|
static inline const auto ZERO_COPY_LOCK_NAME = "part_exclusive_lock";
|
2023-05-03 19:28:33 +00:00
|
|
|
|
2023-01-20 03:04:36 +00:00
|
|
|
ZeroCopyLock(const zkutil::ZooKeeperPtr & zookeeper, const std::string & lock_path, const std::string & lock_message);
|
2022-01-17 11:52:51 +00:00
|
|
|
|
2023-03-15 21:29:24 +00:00
|
|
|
bool isLocked() const { return lock->isLocked(); }
|
2022-01-17 11:52:51 +00:00
|
|
|
/// Actual lock
|
|
|
|
std::unique_ptr<zkutil::ZooKeeperLock> lock;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|