private static DatabaseMetadata resolveDatabaseMetadata(final File metadataFile)
      throws IOException {
    try {
      try {
        return tryReadAndMigrateV1(metadataFile);
      } catch (DatabindException dbe) {
        return tryReadV2(metadataFile);
      }
    } catch (FileNotFoundException fnfe) {
      throw new StorageException(
          "Database exists but metadata file "
              + metadataFile.toString()
              + " not found, without it there is no safe way to open the database",
          fnfe);
    } catch (JsonProcessingException jpe) {
      throw new IllegalStateException(
          String.format("Invalid metadata file %s", metadataFile.getAbsolutePath()), jpe);
    }
  }
Write to directory.

@param dataDir the data dir
@throws IOException the io exception
plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java