mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

boli
24.45.2007 bd4b84076b03a460e7bf3cea4109f82531ef5f26
Added property to enable or disable fair ordering for the entry lock manager. By default, fair ordering will be used.


3 files modified
56 ■■■■■ changed files
opends/src/server/org/opends/server/types/DirectoryEnvironmentConfig.java 26 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/LockManager.java 23 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/ServerConstants.java 7 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/DirectoryEnvironmentConfig.java
@@ -944,7 +944,31 @@
    }
  }
  /**
   * Retrieves whether a fair ordering should be used for the lock
   * manager.
   *
   * @return True if fair orderin should be used or false otherwise
   */
  public boolean getLockManagerFairOrdering()
  {
    String sizeStr = getProperty(PROPERTY_LOCK_MANAGER_FAIR_ORDERING);
    if (sizeStr == null)
    {
      return LockManager.DEFAULT_FAIR_ORDERING;
    }
    else
    {
      try
      {
        return Boolean.parseBoolean(sizeStr);
      }
      catch (Exception e)
      {
        return LockManager.DEFAULT_FAIR_ORDERING;
      }
    }
  }
  /**
   * Retrieves the initial table size for the server lock table.  This
opends/src/server/org/opends/server/types/LockManager.java
@@ -61,6 +61,11 @@
  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;
@@ -93,6 +98,9 @@
  private static
       ConcurrentHashMap<DN,ReentrantReadWriteLock> lockTable;
  // Whether fair ordering should be used on the locks.
  private static boolean fair;
  // Initialize the lock table.
@@ -104,6 +112,7 @@
         environmentConfig.getLockManagerTableSize(),
         DEFAULT_LOAD_FACTOR,
         environmentConfig.getLockManagerConcurrencyLevel());
    fair = environmentConfig.getLockManagerFairOrdering();
  }
@@ -158,6 +167,8 @@
      oldTable.clear();
    }
    fair = environmentConfig.getLockManagerFairOrdering();
  }
@@ -175,7 +186,8 @@
   */
  public static Lock tryLockRead(DN entryDN)
  {
    ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock();
    ReentrantReadWriteLock entryLock =
        new ReentrantReadWriteLock(fair);
    Lock readLock = entryLock.readLock();
    readLock.lock();
@@ -296,7 +308,8 @@
      return readLock;
    }
    ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock();
    ReentrantReadWriteLock entryLock =
        new ReentrantReadWriteLock(fair);
    readLock = entryLock.readLock();
    readLock.lock();
@@ -387,7 +400,8 @@
   */
  public static Lock tryLockWrite(DN entryDN)
  {
    ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock();
    ReentrantReadWriteLock entryLock =
        new ReentrantReadWriteLock(fair);
    Lock writeLock = entryLock.writeLock();
    writeLock.lock();
@@ -505,7 +519,8 @@
      return writeLock;
    }
    ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock();
    ReentrantReadWriteLock entryLock =
        new ReentrantReadWriteLock(fair);
    writeLock = entryLock.writeLock();
    writeLock.lock();
opends/src/server/org/opends/server/util/ServerConstants.java
@@ -2580,6 +2580,13 @@
  public static final String PROPERTY_ERROR_LEVEL =
      "org.opends.server.error.level";
  /**
   * The name of the system property that can be used to specify if  the entry
   * lock manager should use a fair ordering policy.
   */
  public static final String PROPERTY_LOCK_MANAGER_FAIR_ORDERING =
       "org.opends.server.LockManagerFairOrdering";
  /**