Examples of tryLock()


Examples of edu.emory.mathcs.backport.java.util.concurrent.locks.Lock.tryLock()

            logger.debug("Scheduling file " + file + " for processing");
        }
        getExecutor().execute(new Runnable() {
            public void run() {
                final Lock lock = lockManager.getLock(file);
                if (lock.tryLock()) {
                    boolean unlock = true;
                    try {
                        unlock = processFileAndDelete(file);
                    }
                    finally {
View Full Code Here

Examples of java.nio.channels.FileChannel.tryLock()

            boolean writable;

            try {
                fos = new FileOutputStream(file, true);
                FileChannel channel = fos.getChannel();
                lock = channel.tryLock();
            } catch (IOException e) {
                log.warn("Error while attempting to lock the file: " + file.getName(), e);
                writable = false;
            } finally {
                if (lock != null) {
View Full Code Here

Examples of java.nio.channels.FileChannel.tryLock()

      // Try acquiring the lock without blocking. This method returns
      // null or throws an exception if the file is already locked.
      FileLock lock;
      try {
        lock = channel.tryLock();
      } catch (OverlappingFileLockException e) {
        // File is already locked in this thread or virtual machine
        return; // give up
      }
      if (lock == null) return;
View Full Code Here

Examples of java.nio.channels.FileChannel.tryLock()

        // We got an IOException while trying to open the file.
        // Try the next file.
        continue;
    }
    try {
        FileLock fl = fc.tryLock();
        if (fl == null) {
            // We failed to get the lock.  Try next file.
      continue;
        }
        // We got the lock OK.
View Full Code Here

Examples of java.nio.channels.FileChannel.tryLock()

    // randomFile = new RandomAccessFile(this.strFileName, pstrAccessMode);
    randomFile = new RandomAccessFile(this, pstrAccessMode);
    FileChannel channel = randomFile.getChannel();
    FileLock fleLock = null;
    try {
      fleLock = channel.tryLock();
    }
    catch (OverlappingFileLockException e) {
      flgFileIsLocked = true;
    }
    catch (Exception e) {
View Full Code Here

Examples of java.nio.channels.FileChannel.tryLock()

      FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel();
      // Try acquiring the lock without blocking. This method returns
      // null or throws an exception if the file is already locked.
      try
      {
        lock = channel.tryLock();
      }
      catch (OverlappingFileLockException e)
      {
        // File is already locked in this thread or virtual machine
        return;
View Full Code Here

Examples of java.nio.channels.FileChannel.tryLock()

                case LOCK_EX | LOCK_NB:
                    if (currentLock != null) {
                        currentLock.release();
                        currentLock = null;
                    }
                    currentLock = fileChannel.tryLock();
                    if (currentLock != null) {
                        return RubyFixnum.zero(context.getRuntime());
                    }

                    break;
View Full Code Here

Examples of java.nio.channels.FileChannel.tryLock()

                    if (currentLock != null) {
                        currentLock.release();
                        currentLock = null;
                    }

                    currentLock = fileChannel.tryLock(0L, Long.MAX_VALUE, true);
                    if (currentLock != null) {
                        return RubyFixnum.zero(context.getRuntime());
                    }

                    break;
View Full Code Here

Examples of java.nio.channels.FileChannel.tryLock()

        FileLock lock = null;
        ByteBuffer bb = null;
        try {
            channel = fos.getChannel();
            if (channel != null) {
                lock = channel.tryLock();
            }
            bb = getTempByteBuffer();
        } catch (Throwable t) {
        }
        if (lock == null || bb == null || !bb.hasArray()) {
View Full Code Here

Examples of java.util.concurrent.locks.Lock.tryLock()

        int totalLocked = 0;
        for(String path : _relativePaths) {
            ReadWriteLock lock = lockManager.obtainLock(path);
            final Lock rlock = lock.readLock();
            if(rlock.tryLock()) {
                localExecResources.add(new Pair<String, Lock>(path, rlock));
            } else {
                totalLocked++;
                final byte[] k = StringUtils.getBytes(path);
                final GridNodeValueCollector collector = new GridNodeValueCollector(_excludeNodeList);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.