lockFile = lockFile(); lockRaf = new RandomAccessFile(lockFile, "rw"); try {
/** * If the pyramid file exists (which the constructor guarantees) then we * assume that even if a lock file is present, that it's no longer valid. */ protected synchronized void initializeReader() throws IOException, FormatException { File lockFile = lockFile(); if (readerFile.exists() && lockFile.exists()) { // note: we double checked readerFile exists just in case. lockFile.delete(); } reader = new OmeroPixelsPyramidReader(); delegate = new BfPixelBuffer(readerFile.getAbsolutePath(), reader); byteOrder = delegate.isLittleEndian()? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN; }
protected void acquireLock() { try { lockFile = lockFile(); lockRaf = new RandomAccessFile(lockFile, "rw"); fileLock = lockRaf.getChannel().lock(); // THROWS! } catch (OverlappingFileLockException overlap) { closeRaf(); throw new LockTimeout("Already locked! " + lockFile.getAbsolutePath(), 15*1000, 0); } catch (IOException e) { closeRaf(); throw new LockTimeout("IOException while locking " + lockFile.getAbsolutePath(), 15*1000, 0); } }