| | |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | |
| | | /** |
| | | * The default setting for the use of fair ordering locks. |
| | | */ |
| | | public static final boolean DEFAULT_FAIR_ORDERING = true; |
| | | |
| | | /** |
| | | * The default initial size to use for the lock table. |
| | | */ |
| | | public static final int DEFAULT_INITIAL_TABLE_SIZE = 64; |
| | |
| | | private static |
| | | ConcurrentHashMap<DN,ReentrantReadWriteLock> lockTable; |
| | | |
| | | // Whether fair ordering should be used on the locks. |
| | | private static boolean fair; |
| | | |
| | | |
| | | |
| | | // Initialize the lock table. |
| | |
| | | environmentConfig.getLockManagerTableSize(), |
| | | DEFAULT_LOAD_FACTOR, |
| | | environmentConfig.getLockManagerConcurrencyLevel()); |
| | | fair = environmentConfig.getLockManagerFairOrdering(); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | oldTable.clear(); |
| | | } |
| | | |
| | | fair = environmentConfig.getLockManagerFairOrdering(); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public static Lock tryLockRead(DN entryDN) |
| | | { |
| | | ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock(); |
| | | ReentrantReadWriteLock entryLock = |
| | | new ReentrantReadWriteLock(fair); |
| | | Lock readLock = entryLock.readLock(); |
| | | readLock.lock(); |
| | | |
| | |
| | | return readLock; |
| | | } |
| | | |
| | | ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock(); |
| | | ReentrantReadWriteLock entryLock = |
| | | new ReentrantReadWriteLock(fair); |
| | | readLock = entryLock.readLock(); |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public static Lock tryLockWrite(DN entryDN) |
| | | { |
| | | ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock(); |
| | | ReentrantReadWriteLock entryLock = |
| | | new ReentrantReadWriteLock(fair); |
| | | Lock writeLock = entryLock.writeLock(); |
| | | writeLock.lock(); |
| | | |
| | |
| | | return writeLock; |
| | | } |
| | | |
| | | ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock(); |
| | | ReentrantReadWriteLock entryLock = |
| | | new ReentrantReadWriteLock(fair); |
| | | writeLock = entryLock.writeLock(); |
| | | writeLock.lock(); |
| | | |