private synchronized FileLock access(boolean shared, String mode, int timeOut) throws IOException, TimeoutException { raf = new RandomAccessFile(file, mode); fc = raf.getChannel(); final FileLock fl = get(fc, shared); if (maxHoldingTime != -1) { timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { try { if (fl.isValid()) { logger.log(Level.SEVERE, CULoggerInfo.fileLockNotReleased, file.getPath()); release(fl); } } catch (IOException e) { e.printStackTrace(); } } }, timeOut); } return fl; }
(fl = getLock(fc, shared)) == null) {
(fl = getLock(fc, shared)) == null) {
(fl = getLock(fc, shared)) == null) {
private synchronized FileLock access(boolean shared, String mode, int timeOut) throws IOException, TimeoutException { raf = new RandomAccessFile(file, mode); fc = raf.getChannel(); final FileLock fl = get(fc, shared); if (maxHoldingTime != -1) { timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { try { if (fl.isValid()) { logger.log(Level.SEVERE, CULoggerInfo.fileLockNotReleased, file.getPath()); release(fl); } } catch (IOException e) { e.printStackTrace(); } } }, timeOut); } return fl; }
private synchronized FileLock access(boolean shared, String mode, int timeOut) throws IOException, TimeoutException { raf = new RandomAccessFile(file, mode); fc = raf.getChannel(); final FileLock fl = get(fc, shared); if (maxHoldingTime != -1) { timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { try { if (fl.isValid()) { logger.severe(localStrings.getLocalString("FileLockNotReleased", "File Lock not released on {0}", file.getPath())); release(fl); } } catch (IOException e) { e.printStackTrace(); } } }, timeOut); } return fl; }
/** * Blocks for {@link ManagedFile#timeOut} milliseconds for the write access * to the managed file. * * @return the lock instance on the locked file. * @throws IOException if the file cannot be locked * @throws TimeoutException if the lock cannot be obtained before the timeOut * expiration. */ public ManagedLock accessWrite() throws IOException, TimeoutException { wl._lock(); return wl; }
/** * Blocks for {@link ManagedFile#timeOut} milliseconds for the write access * to the managed file. * * @return the lock instance on the locked file. * @throws IOException if the file cannot be locked * @throws TimeoutException if the lock cannot be obtained before the timeOut * expiration. */ public ManagedLock accessWrite() throws IOException, TimeoutException { wl._lock(); return wl; }
/** * Blocks for {@link ManagedFile#timeOut} milliseconds for the read access * to the managed file. * * @return the lock instance on the locked file. * @throws IOException if the file cannot be locked * @throws TimeoutException if the lock cannot be obtained before the timeOut * expiration. */ public ManagedLock accessRead() throws IOException, TimeoutException { rl._lock(); return rl; }
/** * Blocks for {@link ManagedFile#timeOut} milliseconds for the read access * to the managed file. * * @return the lock instance on the locked file. * @throws IOException if the file cannot be locked * @throws TimeoutException if the lock cannot be obtained before the timeOut * expiration. */ public ManagedLock accessRead() throws IOException, TimeoutException { rl._lock(); return rl; }
@Override public void unlock() { lock.unlock(); if (refs.decrementAndGet() == 0) { try { release(fileLock); } catch (IOException e) { e.printStackTrace(); } } }
/** * Blocks for {@link ManagedFile#timeOut} milliseconds for the write access * to the managed file. * * @return the lock instance on the locked file. * @throws IOException if the file cannot be locked * @throws TimeoutException if the lock cannot be obtained before the timeOut * expiration. */ public ManagedLock accessWrite() throws IOException, TimeoutException { wl._lock(); return wl; }
/** * Blocks for {@link ManagedFile#timeOut} milliseconds for the read access * to the managed file. * * @return the lock instance on the locked file. * @throws IOException if the file cannot be locked * @throws TimeoutException if the lock cannot be obtained before the timeOut * expiration. */ public ManagedLock accessRead() throws IOException, TimeoutException { rl._lock(); return rl; }
@Override public void unlock() { lock.unlock(); if (refs.decrementAndGet() == 0) { try { release(fileLock); } catch (IOException e) { e.printStackTrace(); } } }
@Override public void unlock() { lock.unlock(); if (refs.decrementAndGet() == 0) { try { release(fileLock); } catch (IOException e) { e.printStackTrace(); } } }