Skip to content

Commit

Permalink
HDDS-9781. Limited maxOpenFiles, disabled enableCompactionDag, and cr…
Browse files Browse the repository at this point in the history
…eateCheckpointDirs when creating OMMetadataManager instance for bootstrapping (apache#7095)
  • Loading branch information
hemantk-12 authored Nov 13, 2024
1 parent 9dd6a83 commit aa6da3e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_FS_SNAPSHOT_MAX_LIMIT_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_DB_MAX_OPEN_FILES;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_DB_MAX_OPEN_FILES_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_SNAPSHOT_CHECKPOINT_DIR_CREATION_POLL_TIMEOUT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_SNAPSHOT_CHECKPOINT_DIR_CREATION_POLL_TIMEOUT_DEFAULT;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.BUCKET_NOT_FOUND;
Expand Down Expand Up @@ -401,8 +403,9 @@ private OmMetadataManagerImpl(OzoneConfiguration conf, File dir, String name)
throws IOException {
lock = new OmReadOnlyLock();
omEpoch = 0;
setStore(loadDB(conf, dir, name, true,
java.util.Optional.of(Boolean.TRUE), Optional.empty()));
int maxOpenFiles = conf.getInt(OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES, OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES_DEFAULT);

setStore(loadDB(conf, dir, name, true, Optional.of(Boolean.TRUE), maxOpenFiles, false, false));
initializeOmTables(CacheType.PARTIAL_CACHE, false);
perfMetrics = null;
}
Expand Down Expand Up @@ -435,8 +438,7 @@ private OmMetadataManagerImpl(OzoneConfiguration conf, File dir, String name)
checkSnapshotDirExist(checkpoint);
}
setStore(loadDB(conf, metaDir, dbName, false,
java.util.Optional.of(Boolean.TRUE),
Optional.of(maxOpenFiles), false, false));
java.util.Optional.of(Boolean.TRUE), maxOpenFiles, false, false));
initializeOmTables(CacheType.PARTIAL_CACHE, false);
} catch (IOException e) {
stop();
Expand Down Expand Up @@ -578,41 +580,23 @@ public void start(OzoneConfiguration configuration) throws IOException {
int maxOpenFiles = configuration.getInt(OZONE_OM_DB_MAX_OPEN_FILES,
OZONE_OM_DB_MAX_OPEN_FILES_DEFAULT);

this.store = loadDB(configuration, metaDir, Optional.of(maxOpenFiles));
this.store = loadDB(configuration, metaDir, maxOpenFiles);

initializeOmTables(CacheType.FULL_CACHE, true);
}

snapshotChainManager = new SnapshotChainManager(this);
}

public static DBStore loadDB(OzoneConfiguration configuration, File metaDir)
throws IOException {
return loadDB(configuration, metaDir, Optional.empty());
}

public static DBStore loadDB(OzoneConfiguration configuration, File metaDir, Optional<Integer> maxOpenFiles)
throws IOException {
return loadDB(configuration, metaDir, OM_DB_NAME, false,
java.util.Optional.empty(), maxOpenFiles, true, true);
}

public static DBStore loadDB(OzoneConfiguration configuration, File metaDir,
String dbName, boolean readOnly,
java.util.Optional<Boolean>
disableAutoCompaction,
java.util.Optional<Integer> maxOpenFiles)
throws IOException {
return loadDB(configuration, metaDir, dbName, readOnly,
disableAutoCompaction, maxOpenFiles, true, true);
public static DBStore loadDB(OzoneConfiguration configuration, File metaDir, int maxOpenFiles) throws IOException {
return loadDB(configuration, metaDir, OM_DB_NAME, false, java.util.Optional.empty(), maxOpenFiles, true, true);
}

@SuppressWarnings("checkstyle:parameternumber")
public static DBStore loadDB(OzoneConfiguration configuration, File metaDir,
String dbName, boolean readOnly,
java.util.Optional<Boolean>
disableAutoCompaction,
java.util.Optional<Integer> maxOpenFiles,
java.util.Optional<Boolean> disableAutoCompaction,
int maxOpenFiles,
boolean enableCompactionDag,
boolean createCheckpointDirs)
throws IOException {
Expand All @@ -626,10 +610,10 @@ public static DBStore loadDB(OzoneConfiguration configuration, File metaDir,
.setPath(Paths.get(metaDir.getPath()))
.setMaxFSSnapshots(maxFSSnapshots)
.setEnableCompactionDag(enableCompactionDag)
.setCreateCheckpointDirs(createCheckpointDirs);
.setCreateCheckpointDirs(createCheckpointDirs)
.setMaxNumberOfOpenFiles(maxOpenFiles);
disableAutoCompaction.ifPresent(
dbStoreBuilder::disableDefaultCFAutoCompaction);
maxOpenFiles.ifPresent(dbStoreBuilder::setMaxNumberOfOpenFiles);
return addOMTablesAndCodecs(dbStoreBuilder).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,48 @@
import org.junit.jupiter.api.io.TempDir;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
* Test that all the tables are covered both by OMDBDefinition
* as well as OmMetadataManagerImpl.
* Test that all the tables are covered both by OMDBDefinition and OmMetadataManagerImpl.
*/
public class TestOMDBDefinition {

@TempDir
private Path folder;

@Test
public void testDBDefinition() throws Exception {
public void testDBDefinition() throws IOException {
OzoneConfiguration configuration = new OzoneConfiguration();
File metaDir = folder.toFile();
DBStore store = OmMetadataManagerImpl.loadDB(configuration, metaDir);
OMDBDefinition dbDef = OMDBDefinition.get();

// Get list of tables from DB Definitions
final Collection<DBColumnFamilyDefinition<?, ?>> columnFamilyDefinitions
= OMDBDefinition.get().getColumnFamilies();
final Collection<DBColumnFamilyDefinition<?, ?>> columnFamilyDefinitions = dbDef.getColumnFamilies();
final int countOmDefTables = columnFamilyDefinitions.size();
ArrayList<String> missingDBDefTables = new ArrayList<>();
List<String> missingDBDefTables = new ArrayList<>();

// Get list of tables from the RocksDB Store
final Collection<String> missingOmDBTables = new ArrayList<>(store.getTableNames().values());
missingOmDBTables.remove("default");
int countOmDBTables = missingOmDBTables.size();
// Remove the file if it is found in both the datastructures
for (DBColumnFamilyDefinition definition : columnFamilyDefinitions) {
if (!missingOmDBTables.remove(definition.getName())) {
missingDBDefTables.add(definition.getName());
try (DBStore store = OmMetadataManagerImpl.loadDB(configuration, metaDir, -1)) {
// Get list of tables from the RocksDB Store
final Collection<String> missingOmDBTables = new ArrayList<>(store.getTableNames().values());
missingOmDBTables.remove("default");
int countOmDBTables = missingOmDBTables.size();
// Remove the file if it is found in both the datastructures
for (DBColumnFamilyDefinition definition : columnFamilyDefinitions) {
if (!missingOmDBTables.remove(definition.getName())) {
missingDBDefTables.add(definition.getName());
}
}
}

assertEquals(0, missingDBDefTables.size(),
"Tables in OmMetadataManagerImpl are:" + missingDBDefTables);
assertEquals(0, missingOmDBTables.size(),
"Tables missing in OMDBDefinition are:" + missingOmDBTables);
assertEquals(countOmDBTables, countOmDefTables);
assertEquals(0, missingDBDefTables.size(),
"Tables in OmMetadataManagerImpl are:" + missingDBDefTables);
assertEquals(0, missingOmDBTables.size(),
"Tables missing in OMDBDefinition are:" + missingOmDBTables);
assertEquals(countOmDBTables, countOmDefTables);
}
}
}

0 comments on commit aa6da3e

Please sign in to comment.