private void close(boolean emergency) throws IOException {
    if (myDoTrace) {
      LOG.info("Closed " + myStorageFile + "." + (myAppendCache == null ? "" : ("Append cache stats: " + myAppendCache.dumpStats())));
    }
    StorageStatsRegistrar.INSTANCE.unregisterMap(myStorageFile);

    getWriteLock().lock();
    try {
      if (isClosed()) return;

      if (myWal != null) {
        myWal.close();
      }

      try {
        if (!emergency && myCompactOnClose && isCompactionSupported()) {
          compact();
        }
      }
      finally {
        doClose();
      }
    }
    finally {
      getWriteLock().unlock();
    }
  }
private void close(boolean emergency)