| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | |
| | | |
| | | |
| | | // A map between the filenames and the lock files for exclusive locks. |
| | | /** A map between the filenames and the lock files for exclusive locks. */ |
| | | private static HashMap<String,FileLock> exclusiveLocks = |
| | | new HashMap<String,FileLock>(); |
| | | |
| | | // A map between the filenames and the lock files for shared locks. |
| | | /** A map between the filenames and the lock files for shared locks. */ |
| | | private static HashMap<String,FileLock> sharedLocks = |
| | | new HashMap<String,FileLock>(); |
| | | |
| | | // A map between the filenames and reference counts for shared locks. |
| | | /** A map between the filenames and reference counts for shared locks. */ |
| | | private static HashMap<String,Integer> sharedLockReferences = |
| | | new HashMap<String,Integer>(); |
| | | |
| | | // The lock providing threadsafe access to the lock map data. |
| | | /** The lock providing threadsafe access to the lock map data. */ |
| | | private static Object mapLock = new Object(); |
| | | |
| | | |
| | |
| | | |
| | | failureReason.append(ERR_FILELOCKER_LOCK_SHARED_FAILED_OPEN.get( |
| | | lockFile, getExceptionMessage(e))); |
| | | |
| | | if (raf != null) |
| | | { |
| | | try |
| | | { |
| | | raf.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(raf); |
| | | return false; |
| | | } |
| | | |
| | |
| | | failureReason.append( |
| | | ERR_FILELOCKER_LOCK_SHARED_FAILED_LOCK.get( |
| | | lockFile, getExceptionMessage(e))); |
| | | if (channel != null) |
| | | { |
| | | try |
| | | { |
| | | channel.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | if (raf != null) |
| | | { |
| | | try |
| | | { |
| | | raf.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(channel, raf); |
| | | return false; |
| | | } |
| | | |
| | |
| | | { |
| | | failureReason.append( |
| | | ERR_FILELOCKER_LOCK_SHARED_NOT_GRANTED.get(lockFile)); |
| | | if (channel != null) |
| | | { |
| | | try |
| | | { |
| | | channel.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | if (raf != null) |
| | | { |
| | | try |
| | | { |
| | | raf.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(channel, raf); |
| | | return false; |
| | | } |
| | | else |
| | |
| | | |
| | | failureReason.append(ERR_FILELOCKER_LOCK_EXCLUSIVE_FAILED_OPEN.get( |
| | | lockFile, getExceptionMessage(e))); |
| | | if (raf != null) |
| | | { |
| | | try |
| | | { |
| | | raf.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(raf); |
| | | return false; |
| | | } |
| | | |
| | |
| | | failureReason.append( |
| | | ERR_FILELOCKER_LOCK_EXCLUSIVE_FAILED_LOCK.get(lockFile, |
| | | getExceptionMessage(e))); |
| | | if (channel != null) |
| | | { |
| | | try |
| | | { |
| | | channel.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | if (raf != null) |
| | | { |
| | | try |
| | | { |
| | | raf.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | close(channel, raf); |
| | | return false; |
| | | } |
| | | |
| | |
| | | { |
| | | failureReason.append( |
| | | ERR_FILELOCKER_LOCK_EXCLUSIVE_NOT_GRANTED.get(lockFile)); |
| | | if (channel != null) |
| | | { |
| | | try |
| | | { |
| | | channel.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | if (raf != null) |
| | | { |
| | | try |
| | | { |
| | | raf.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(channel, raf); |
| | | return false; |
| | | } |
| | | else |