Skip to content

Commit

Permalink
Merge branch 'master' into HDDS-11661
Browse files Browse the repository at this point in the history
  • Loading branch information
chungen0126 committed Dec 13, 2024
2 parents b843595 + 008f9a6 commit 9abadcd
Show file tree
Hide file tree
Showing 31 changed files with 560 additions and 584 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.hadoop.hdds.cli;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
Expand All @@ -25,6 +26,7 @@
import org.apache.hadoop.hdds.conf.OzoneConfiguration;

import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.security.UserGroupInformation;
import picocli.CommandLine;
import picocli.CommandLine.ExitCode;
import picocli.CommandLine.Model.CommandSpec;
Expand All @@ -48,25 +50,20 @@ public class GenericCli implements Callable<Void>, GenericParentCommand {
private String configurationPath;

private final CommandLine cmd;
private OzoneConfiguration conf;
private UserGroupInformation user;

public GenericCli() {
this(null);
this(CommandLine.defaultFactory());
}

public GenericCli(Class<?> type) {
this(type, CommandLine.defaultFactory());
}

public GenericCli(Class<?> type, CommandLine.IFactory factory) {
public GenericCli(CommandLine.IFactory factory) {
cmd = new CommandLine(this, factory);
cmd.setExecutionExceptionHandler((ex, commandLine, parseResult) -> {
printError(ex);
return EXECUTION_ERROR_EXIT_CODE;
});

if (type != null) {
SubcommandWithParent.addSubcommands(getCmd(), type);
}
ExtensibleParentCommand.addSubcommands(cmd);
}

Expand Down Expand Up @@ -122,6 +119,20 @@ public OzoneConfiguration createOzoneConfiguration() {
return ozoneConf;
}

public OzoneConfiguration getOzoneConf() {
if (conf == null) {
conf = createOzoneConfiguration();
}
return conf;
}

public UserGroupInformation getUser() throws IOException {
if (user == null) {
user = UserGroupInformation.getCurrentUser();
}
return user;
}

@VisibleForTesting
public picocli.CommandLine getCmd() {
return cmd;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.hadoop.hdds.utils.db.managed;

import org.apache.commons.io.FilenameUtils;
import org.rocksdb.ColumnFamilyDescriptor;
import org.rocksdb.ColumnFamilyHandle;
import org.rocksdb.DBOptions;
Expand All @@ -31,6 +32,8 @@
import java.io.IOException;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Managed {@link RocksDB}.
Expand Down Expand Up @@ -102,4 +105,14 @@ public void deleteFile(LiveFileMetaData fileToBeDeleted)
File file = new File(fileToBeDeleted.path(), fileToBeDeleted.fileName());
ManagedRocksObjectUtils.waitForFileDelete(file, Duration.ofSeconds(60));
}

public static Map<String, LiveFileMetaData> getLiveMetadataForSSTFiles(RocksDB db) {
return db.getLiveFilesMetaData().stream().collect(
Collectors.toMap(liveFileMetaData -> FilenameUtils.getBaseName(liveFileMetaData.fileName()),
liveFileMetaData -> liveFileMetaData));
}

public Map<String, LiveFileMetaData> getLiveMetadataForSSTFiles() {
return getLiveMetadataForSSTFiles(this.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import org.apache.hadoop.hdds.StringUtils;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.rocksdb.LiveFileMetaData;

import java.util.Objects;

Expand Down Expand Up @@ -128,6 +130,16 @@ public Builder setColumnFamily(String columnFamily) {
return this;
}

public Builder setValues(LiveFileMetaData fileMetaData) {
if (fileMetaData != null) {
String columnFamilyName = StringUtils.bytes2String(fileMetaData.columnFamilyName());
String startRangeValue = StringUtils.bytes2String(fileMetaData.smallestKey());
String endRangeValue = StringUtils.bytes2String(fileMetaData.largestKey());
this.setColumnFamily(columnFamilyName).setStartRange(startRangeValue).setEndRange(endRangeValue);
}
return this;
}

public CompactionFileInfo build() {
if ((startRange != null || endRange != null || columnFamily != null) &&
(startRange == null || endRange == null || columnFamily == null)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.apache.ozone.rocksdiff;

import org.apache.ozone.compaction.log.CompactionFileInfo;

/**
* Node in the compaction DAG that represents an SST file.
*/
Expand Down Expand Up @@ -48,6 +50,11 @@ public CompactionNode(String file, long numKeys, long seqNum,
this.columnFamily = columnFamily;
}

public CompactionNode(CompactionFileInfo compactionFileInfo) {
this(compactionFileInfo.getFileName(), -1, -1, compactionFileInfo.getStartKey(),
compactionFileInfo.getEndKey(), compactionFileInfo.getColumnFamily());
}

@Override
public String toString() {
return String.format("Node{%s}", fileName);
Expand Down
Loading

0 comments on commit 9abadcd

Please sign in to comment.