Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.InterProcessLock


    ZKInterProcessReadWriteLock clientLock1
      = new ZKInterProcessReadWriteLock(zkWatcher1, znode, null);
    ZKInterProcessReadWriteLock clientLock2
      = new ZKInterProcessReadWriteLock(zkWatcher2, znode, null);

    InterProcessLock lock1 = clientLock1.readLock(Bytes.toBytes("client1"));
    lock1.acquire();

    //try to acquire, but it will timeout. We are testing whether this will cause any problems
    //due to the read lock being from another client
    InterProcessLock lock2 = clientLock2.writeLock(Bytes.toBytes("client2"));
    assertFalse(lock2.tryAcquire(1000));

    lock1.release();

    //this time it will acquire
    assertTrue(lock2.tryAcquire(5000));
    lock2.release();
    zkWatcher1.close();
    zkWatcher2.close();
  }
View Full Code Here


    ZKInterProcessReadWriteLock clientLock1
      = new ZKInterProcessReadWriteLock(zkWatcher1, znode, null);
    ZKInterProcessReadWriteLock clientLock2
      = new ZKInterProcessReadWriteLock(zkWatcher2, znode, null);

    InterProcessLock lock1 = clientLock1.readLock(Bytes.toBytes("client1"));
    lock1.acquire();

    //try to acquire, but it will timeout. We are testing whether this will cause any problems
    //due to the read lock being from another client
    InterProcessLock lock2 = clientLock2.writeLock(Bytes.toBytes("client2"));
    assertFalse(lock2.tryAcquire(1000));

    lock1.release();

    //this time it will acquire
    assertTrue(lock2.tryAcquire(5000));
    lock2.release();
    zkWatcher1.close();
    zkWatcher2.close();
  }
View Full Code Here

    ZKInterProcessReadWriteLock clientLock1
      = new ZKInterProcessReadWriteLock(zkWatcher1, znode, null);
    ZKInterProcessReadWriteLock clientLock2
      = new ZKInterProcessReadWriteLock(zkWatcher2, znode, null);

    InterProcessLock lock1 = clientLock1.readLock(Bytes.toBytes("client1"));
    lock1.acquire();

    //try to acquire, but it will timeout. We are testing whether this will cause any problems
    //due to the read lock being from another client
    InterProcessLock lock2 = clientLock2.writeLock(Bytes.toBytes("client2"));
    assertFalse(lock2.tryAcquire(1000));

    lock1.release();

    //this time it will acquire
    assertTrue(lock2.tryAcquire(5000));
    lock2.release();
    zkWatcher1.close();
    zkWatcher2.close();
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.InterProcessLock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.