Package com.orientechnologies.common.concur.lock

Examples of com.orientechnologies.common.concur.lock.OLockException


  public V getResource(K iKey, final long iMaxWaitMillis, Object... iAdditionalArgs) throws OLockException {

    // First, get permission to take or create a resource
    try {
      if (!sem.tryAcquire(iMaxWaitMillis, TimeUnit.MILLISECONDS))
        throw new OLockException("Can't acquire lock on requested resource: " + iKey);
    } catch (InterruptedException e) {
      throw new OLockException("Can't acquire lock on requested resource: " + iKey, e);
    }

    // Then, actually take one if available...
    V res = resources.poll();
    if (res != null) {
      listener.reuseResource(iKey, iAdditionalArgs, res);
      return res;
    }

    // ...or create one if none available
    try {
      res = listener.createNewResource(iKey, iAdditionalArgs);
      return res;
    } catch (Exception e) {
      // Don't hog the permit if we failed to create a resource!
      sem.release();
      throw new OLockException("Error on creation of the new resource in the pool", e);
    }
  }
View Full Code Here


        OMemoryWatchDog.freeMemory(LOCK_WAIT_TIME);
      }
    }

    if (fileLock == null)
      throw new OLockException(
          "File '"
              + osFile.getPath()
              + "' is locked by another process, maybe the database is in use by another process. Use the remote mode with a OrientDB server to allow multiple access to the same database.");
  }
View Full Code Here

  public void release(final CH iChannel) {
    final String address = iChannel.socket.getInetAddress().toString();

    final OResourcePool<String, CH> pool = pools.get(address);
    if (pool == null)
      throw new OLockException("Can't release a network channel not acquired before. Remote address: " + address);

    pool.returnResource(iChannel);
  }
View Full Code Here

    final String dbPooledName = iDatabase instanceof ODatabaseComplex ? ((ODatabaseComplex<?>) iDatabase).getUser().getName() + "@"
        + iDatabase.getName() : iDatabase.getName();

    final OResourcePool<String, DB> pool = pools.get(dbPooledName);
    if (pool == null)
      throw new OLockException("Can't release a database URL not acquired before. URL: " + iDatabase.getName());

    pool.returnResource(iDatabase);
  }
View Full Code Here

  public void release(final CH iChannel) {
    final String address = iChannel.socket.getInetAddress().toString();

    final OResourcePool<String, CH> pool = pools.get(address);
    if (pool == null)
      throw new OLockException("Can't release a network channel not acquired before. Remote address: " + address);

    pool.returnResource(iChannel);
  }
View Full Code Here

  public void release(final CH iChannel) {
    final String address = iChannel.socket.getInetAddress().toString();

    final OResourcePool<String, CH> pool = pools.get(address);
    if (pool == null)
      throw new OLockException("Can't release a network channel not acquired before. Remote address: " + address);

    pool.returnResource(iChannel);
  }
View Full Code Here

  public V getResource(K iKey, final long iMaxWaitMillis, String... iAdditionalArgs) throws OLockException {

    // First, get permission to take or create a resource
    try {
      if (!sem.tryAcquire(iMaxWaitMillis, TimeUnit.MILLISECONDS))
        throw new OLockException("Can't acquire lock on requested resource: " + iKey);
    } catch (InterruptedException e) {
      throw new OLockException("Can't acquire lock on requested resource: " + iKey, e);
    }

    // Then, actually take one if available...
    V res = resources.poll();
    if (res != null) {
      listener.reuseResource(iKey, iAdditionalArgs, res);
      return res;
    }

    // ...or create one if none available
    try {
      res = listener.createNewResource(iKey, iAdditionalArgs);
      return res;
    } catch (Exception e) {
      // Don't hog the permit if we failed to create a resource!
      sem.release();
      throw new OLockException("Error on creation of the new resource in the pool", e);
    }
  }
View Full Code Here

        }
      }
    }

    if (fileLock == null)
      throw new OLockException(
          "File '"
              + osFile.getPath()
              + "' is locked by another process, maybe the database is in use by another process. Use the remote mode with a OrientDB server to allow multiple access to the same database.");
  }
View Full Code Here

    final String dbPooledName = iDatabase instanceof ODatabaseComplex ? ((ODatabaseComplex<?>) iDatabase).getUser().getName() + "@"
        + iDatabase.getName() : iDatabase.getName();

    final OResourcePool<String, DB> pool = pools.get(dbPooledName);
    if (pool == null)
      throw new OLockException("Can't release a database URL not acquired before. URL: " + iDatabase.getName());

    pool.returnResource(iDatabase);
  }
View Full Code Here

        OMemoryWatchDog.freeMemory(LOCK_WAIT_TIME);
      }
    }

    if (fileLock == null)
      throw new OLockException(
          "File '"
              + osFile.getPath()
              + "' is locked by another process, maybe the database is in use by another process. Use the remote mode with a OrientDB server to allow multiple access to the same database.");
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.common.concur.lock.OLockException

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.