| 1 | #include <iostream> | 
|---|---|
| 2 | #include <Common/ZooKeeper/Lock.h> | 
| 3 | |
| 4 | int main() | 
| 5 | { | 
| 6 | |
| 7 | try | 
| 8 | { | 
| 9 | auto zookeeper_holder = std::make_shared<zkutil::ZooKeeperHolder>(); | 
| 10 | zookeeper_holder->init( "localhost:2181"); | 
| 11 | |
| 12 | zkutil::Lock l(zookeeper_holder, "/test", "test_lock"); | 
| 13 | std::cout << "check "<< l.tryCheck() << std::endl; | 
| 14 | std::cout << "lock tryLock() "<< l.tryLock() << std::endl; | 
| 15 | std::cout << "check "<< l.tryCheck() << std::endl; | 
| 16 | } | 
| 17 | catch (const Poco::Exception & e) | 
| 18 | { | 
| 19 | std::cout << e.message() << std::endl; | 
| 20 | } | 
| 21 | return 0; | 
| 22 | } | 
| 23 | 
