Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-9781. Limited maxOpenFiles, disabled enableCompactionDag, and createCheckpointDirs when creating OMMetadataManager instance for bootstrapping #7095

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
aswinshakil marked this conversation as resolved.
Show resolved Hide resolved
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);
}
}
}