Package info.aduna.concurrent.locks

Examples of info.aduna.concurrent.locks.Lock


  }

  public boolean addInferredStatement(Resource subj, URI pred, Value obj, Resource... contexts)
    throws StoreException
  {
    Lock conLock = getSharedConnectionLock();
    try {
      Lock txnLock = getTransactionLock();
      try {
        return getDelegate().addInferredStatement(subj, pred, obj, contexts);
      }
      finally {
        txnLock.release();
      }
    }
    finally {
      conLock.release();
    }
View Full Code Here


  }

  public boolean removeInferredStatements(Resource subj, URI pred, Value obj, Resource... contexts)
    throws StoreException
  {
    Lock conLock = getSharedConnectionLock();
    try {
      Lock txnLock = getTransactionLock();
      try {
        return getDelegate().removeInferredStatements(subj, pred, obj, contexts);
      }
      finally {
        txnLock.release();
      }
    }
    finally {
      conLock.release();
    }
View Full Code Here

  }

  public void flushUpdates()
    throws StoreException
  {
    Lock conLock = getSharedConnectionLock();
    try {
      Lock txnLock = getTransactionLock();
      try {
        getDelegate().flushUpdates();
      }
      finally {
        txnLock.release();
      }
    }
    finally {
      conLock.release();
    }
View Full Code Here

    if (!lockDir.mkdir()) {
      return null;
    }

    Lock lock = null;

    try {
      File infoFile = new File(lockDir, INFO_FILE_NAME);
      File lockedFile = new File(lockDir, LOCK_FILE_NAME);

      RandomAccessFile raf = new RandomAccessFile(lockedFile, "rw");
      try {
        FileLock fileLock = raf.getChannel().lock();
        lock = createLock(raf, fileLock);
        sign(infoFile);
      }
      catch (IOException e) {
        if (lock != null) {
          // Also closes raf
          lock.release();
        }
        else {
          raf.close();
        }
        throw e;
View Full Code Here

   *         if the directory is already locked.
   */
  public Lock lockOrFail()
    throws SailLockedException
  {
    Lock lock = tryLock();

    if (lock != null) {
      return lock;
    }

View Full Code Here

      return null;
    }
  }

  private Lock createLock(final RandomAccessFile raf, final FileLock fileLock) {
    return new Lock() {

      private boolean active = true;

      private Thread hook = new Thread(new Runnable() {
View Full Code Here

  public void close()
    throws StoreException
  {
    // obtain an exclusive lock so that any further operations on this
    // connection (including those from any concurrent threads) are blocked.
    Lock conLock = getExclusiveConnectionLock();

    try {
      super.close();
    }
    finally {
      // Release the exclusive lock. Any threads waiting to obtain a
      // non-exclusive read lock will get one and then fail with an
      // IllegalStateException, because the connection is no longer open.
      conLock.release();
    }
  }
View Full Code Here

  @Override
  public Cursor<? extends BindingSet> evaluate(QueryModel query, BindingSet bindings, boolean includeInferred)
    throws StoreException
  {
    Lock conLock = getSharedConnectionLock();
    try {
      return super.evaluate(query, bindings, includeInferred);
    }
    finally {
      conLock.release();
    }
  }
View Full Code Here

  @Override
  public Cursor<? extends Resource> getContextIDs()
    throws StoreException
  {
    Lock conLock = getSharedConnectionLock();
    try {
      return super.getContextIDs();
    }
    finally {
      conLock.release();
    }
  }
View Full Code Here

  @Override
  public Cursor<? extends Statement> getStatements(Resource subj, URI pred, Value obj,
      boolean includeInferred, Resource... contexts)
    throws StoreException
  {
    Lock conLock = getSharedConnectionLock();
    try {
      return super.getStatements(subj, pred, obj, includeInferred, contexts);
    }
    finally {
      conLock.release();
    }
  }
View Full Code Here

TOP

Related Classes of info.aduna.concurrent.locks.Lock

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.