/** * Performs an exclusive lock on a file, that * this lock instance was constructed with. * * @throws IgniteCheckedException If failed to perform locking. The file remains open. */ public void lock() throws IgniteCheckedException { lock(false); }
/** * Returns a new instance of {@link GridFileLock}, that * can be used to synchronize on a lock file, which resides * in a temporary directory. * <p> * If a lock file does not exist, it is created. * <p> * If a temporary directory does not exist, an exception is * thrown. * * @return An file lock instance. Calling {@link GridFileLock#lock()} * will perform actual locking. * @throws RuntimeException If a temporary directory is not found. */ public static GridFileLock fileLock() { try { return new GridFileLock(LOCK_FILE); } catch (FileNotFoundException e) { throw new RuntimeException("tmp.dir not found", e); } } }
/** * Unlocks and closes the file. */ public void close() { unlock(); U.closeQuiet(raFile); }