public static void closePmfIfNeeded(boolean forCompactor, boolean shouldClose) {
    pmfWriteLock.lock();
    try {
      PersistenceManagerFactory factory = forCompactor ? compactorPmf : pmf;
      if (factory != null && shouldClose) {
        clearOutPmfClassLoaderCache(factory);
        if (!forTwoMetastoreTesting) {
          closePmfInternal(factory);
        }
        if (forCompactor) {
          compactorPmf = null;
        } else {
          pmf = null;
        }
      }
    } finally {
      pmfWriteLock.unlock();
    }
  }
Close the corresponding PersistenceManagerFactory
@param forCompactor true for compactorPmf, otherwise pmf
@param shouldClose close the PersistenceManagerFactory if true
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java