Package mil.nga.giat.geowave.vector.plugin.lock

Examples of mil.nga.giat.geowave.vector.plugin.lock.LockingManagement


  @Test
  public void testReset()
      throws InterruptedException,
      IOException {
    final LockingManagement memoryLockManager = new MemoryLockManager(
        "default");
    final Transaction t1 = Transaction.AUTO_COMMIT;
    FeatureLock lock = new FeatureLock(
        "auth1",
        1 /* minute */);
    memoryLockManager.lockFeatureID(
        "sometime",
        "f1",
        t1,
        lock);
    memoryLockManager.refresh(
        "auth1",
        t1);
    assertTrue(memoryLockManager.exists("auth1"));
    memoryLockManager.release(
        "auth1",
        t1);
    assertFalse(memoryLockManager.exists("auth1"));
  }
 
View Full Code Here


  @Test
  public void testBlockinLock()
      throws InterruptedException,
      IOException {
    final LockingManagement memoryLockManager = new MemoryLockManager(
        "default");
    final DefaultTransaction t1 = new DefaultTransaction();
    memoryLockManager.lock(
        t1,
        "f1");
    final DefaultTransaction t2 = new DefaultTransaction();

    Thread commiter = new Thread(
        new Runnable() {
          @Override
          public void run() {
            try {
              Thread.sleep(4000);
          //    System.out.println("commit");
              t1.commit();
            }
            catch (InterruptedException e) {
              e.printStackTrace();
              throw new RuntimeException(
                  e);
            }
            catch (IOException e) {
              e.printStackTrace();
              throw new RuntimeException(
                  e);
            }
          }
        });

    long currentTime = System.currentTimeMillis();
    commiter.start();
    // will block\
  //  System.out.println("t2");
    memoryLockManager.lock(
        t2,
        "f1");
    assertTrue((System.currentTimeMillis() - currentTime) >= 4000);

    commiter.join();
View Full Code Here

  @Test
  public void testRelockLock()
      throws InterruptedException,
      IOException {
    final LockingManagement memoryLockManager = new MemoryLockManager(
        "default");
    final DefaultTransaction t1 = new DefaultTransaction();
    memoryLockManager.lock(
        t1,
        "f1");
    memoryLockManager.lock(
        t1,
        "f1");
    t1.commit();
    t1.close();
  }
View Full Code Here

  @Test
  public void testLockWithProperAuth()
      throws InterruptedException,
      IOException {
    final LockingManagement memoryLockManager = new MemoryLockManager(
        "default");
    final Transaction t1 = Transaction.AUTO_COMMIT;
    final DefaultTransaction t2 = new DefaultTransaction();
    t2.addAuthorization("auth1");
    FeatureLock lock = new FeatureLock(
        "auth1",
        1 /* minute */);
    memoryLockManager.lockFeatureID(
        "sometime",
        "f1",
        t1,
        lock);
    Thread commiter = new Thread(
        new Runnable() {
          @Override
          public void run() {
            try {
              Thread.sleep(4000);
              memoryLockManager.release(
                  "auth1",
                  t1);
            }
            catch (InterruptedException e) {
              e.printStackTrace();
              throw new RuntimeException(
                  e);
            }
            catch (IOException e) {
              e.printStackTrace();
              throw new RuntimeException(
                  e);
            }
          }
        });
    long currentTime = System.currentTimeMillis();
    commiter.start();
    memoryLockManager.lock(
        t2,
        "f1");
    assertTrue((System.currentTimeMillis() - currentTime) < 4000);
    commiter.join();
  }
View Full Code Here

  @Test
  public void testLockReleaseOfBulkAuthLock()
      throws InterruptedException,
      IOException {
    final LockingManagement memoryLockManager = new MemoryLockManager(
        "default");
    final Transaction t1 = Transaction.AUTO_COMMIT;
    final DefaultTransaction t2 = new DefaultTransaction();
    t2.addAuthorization("auth1");
    FeatureLock lock = new FeatureLock(
        "auth1",
        1 /* minute */);
    memoryLockManager.lockFeatureID(
        "sometime",
        "f1",
        t1,
        lock);
    memoryLockManager.lock(
        t2,
        "f1");
    t2.commit();
    // commit should not take away the lock
    assertTrue(memoryLockManager.exists("auth1"));
    memoryLockManager.release(
        "auth1",
        t1);
    assertFalse(memoryLockManager.exists("auth1"));
  }
View Full Code Here

TOP

Related Classes of mil.nga.giat.geowave.vector.plugin.lock.LockingManagement

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.