/// <summary> /// Obtains lock on store file so that we can ensure the store is not shared between database instances /// <para> /// Creates store dir if necessary, creates store lock file if necessary /// </para> /// <para> /// Please note that this lock is only valid for as long the <seealso cref="storeLockFileChannel"/> lives, so make sure the /// lock cannot be garbage collected as long as the lock should be valid. /// /// </para> /// </summary> /// <exception cref="StoreLockException"> if lock could not be acquired </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void checkLock() throws org.neo4j.kernel.StoreLockException public virtual void CheckLock() { if (HaveLockAlready()) { return; } try { if (!FileSystemAbstraction.fileExists(StoreLockFile)) { FileSystemAbstraction.mkdirs(StoreLockFile.ParentFile); } } catch (IOException e) { string message = "Unable to create path for store dir: " + StoreLockFile.Parent; throw StoreLockException(message, e); } try { if (_storeLockFileChannel == null) { _storeLockFileChannel = FileSystemAbstraction.open(StoreLockFile, OpenMode.READ_WRITE); } StoreLockFileLock = _storeLockFileChannel.tryLock(); if (StoreLockFileLock == null) { string message = "Store and its lock file has been locked by another process: " + StoreLockFile; throw StoreLockException(message, null); } } catch (Exception e) when(e is OverlappingFileLockException || e is IOException) { throw UnableToObtainLockException(); } }