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-12590. Used db name as the threadNamePrefix. #8076

Merged
merged 1 commit into from
Mar 14, 2025
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 @@ -107,7 +107,6 @@ public final class DBStoreBuilder {
// number in request to avoid increase in heap memory.
private long maxDbUpdatesSizeThreshold;
private Integer maxNumberOfOpenFiles = null;
private String threadNamePrefix = "";

/**
* Create DBStoreBuilder from a generic DBDefinition.
Expand Down Expand Up @@ -233,7 +232,7 @@ public DBStore build() throws IOException {
return new RDBStore(dbFile, rocksDBOption, statistics, writeOptions, tableConfigs,
registry.build(), openReadOnly, maxFSSnapshots, dbJmxBeanNameName,
enableCompactionDag, maxDbUpdatesSizeThreshold, createCheckpointDirs,
configuration, threadNamePrefix, enableRocksDbMetrics);
configuration, enableRocksDbMetrics);
} finally {
tableConfigs.forEach(TableConfig::close);
}
Expand Down Expand Up @@ -323,11 +322,6 @@ public DBStoreBuilder setMaxNumberOfOpenFiles(Integer maxNumberOfOpenFiles) {
return this;
}

public DBStoreBuilder setThreadNamePrefix(String prefix) {
this.threadNamePrefix = prefix;
return this;
}

/**
* Converts column families and their corresponding options that have been
* registered with the builder to a set of {@link TableConfig} objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public class RDBStore implements DBStore {
private final long maxDbUpdatesSizeThreshold;
private final ManagedDBOptions dbOptions;
private final ManagedStatistics statistics;
private final String threadNamePrefix;

@SuppressWarnings("parameternumber")
public RDBStore(File dbFile, ManagedDBOptions dbOptions, ManagedStatistics statistics,
Expand All @@ -83,11 +82,10 @@ public RDBStore(File dbFile, ManagedDBOptions dbOptions, ManagedStatistics stati
String dbJmxBeanName, boolean enableCompactionDag,
long maxDbUpdatesSizeThreshold,
boolean createCheckpointDirs,
ConfigurationSource configuration, String threadNamePrefix,
ConfigurationSource configuration,
boolean enableRocksDBMetrics)

throws IOException {
this.threadNamePrefix = threadNamePrefix;
Preconditions.checkNotNull(dbFile, "DB file location cannot be null");
Preconditions.checkNotNull(families);
Preconditions.checkArgument(!families.isEmpty());
Expand Down Expand Up @@ -306,8 +304,7 @@ public <K, V> TypedTable<K, V> getTable(String name,
public <K, V> Table<K, V> getTable(String name,
Class<K> keyType, Class<V> valueType,
TableCache.CacheType cacheType) throws IOException {
return new TypedTable<>(getTable(name), codecRegistry, keyType,
valueType, cacheType, threadNamePrefix);
return new TypedTable<>(getTable(name), codecRegistry, keyType, valueType, cacheType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ public class TypedTable<KEY, VALUE> implements Table<KEY, VALUE> {
static final int BUFFER_SIZE_DEFAULT = 4 << 10; // 4 KB

private final RDBTable rawTable;
private final String info;

private final Class<KEY> keyType;
private final Codec<KEY> keyCodec;
private final Class<VALUE> valueType;
private final Codec<VALUE> valueCodec;

private final boolean supportCodecBuffer;
Expand All @@ -72,11 +71,9 @@ public class TypedTable<KEY, VALUE> implements Table<KEY, VALUE> {
* The same as this(rawTable, codecRegistry, keyType, valueType,
* CacheType.PARTIAL_CACHE).
*/
public TypedTable(RDBTable rawTable,
CodecRegistry codecRegistry, Class<KEY> keyType,
Class<VALUE> valueType) throws IOException {
this(rawTable, codecRegistry, keyType, valueType,
CacheType.PARTIAL_CACHE, "");
TypedTable(RDBTable rawTable, CodecRegistry codecRegistry, Class<KEY> keyType, Class<VALUE> valueType)
throws IOException {
this(rawTable, codecRegistry, keyType, valueType, CacheType.PARTIAL_CACHE);
}

/**
Expand All @@ -87,27 +84,28 @@ public TypedTable(RDBTable rawTable,
* @param keyType The key type.
* @param valueType The value type.
* @param cacheType How to cache the entries?
* @param threadNamePrefix
* @throws IOException if failed to iterate the raw table.
*/
public TypedTable(RDBTable rawTable,
CodecRegistry codecRegistry, Class<KEY> keyType,
Class<VALUE> valueType,
CacheType cacheType, String threadNamePrefix) throws IOException {
TypedTable(RDBTable rawTable, CodecRegistry codecRegistry, Class<KEY> keyType, Class<VALUE> valueType,
CacheType cacheType) throws IOException {
this.rawTable = Objects.requireNonNull(rawTable, "rawTable==null");
Objects.requireNonNull(codecRegistry, "codecRegistry == null");

this.keyType = Objects.requireNonNull(keyType, "keyType == null");
Objects.requireNonNull(keyType, "keyType == null");
this.keyCodec = codecRegistry.getCodecFromClass(keyType);
Objects.requireNonNull(keyCodec, "keyCodec == null");

this.valueType = Objects.requireNonNull(valueType, "valueType == null");
Objects.requireNonNull(valueType, "valueType == null");
this.valueCodec = codecRegistry.getCodecFromClass(valueType);
Objects.requireNonNull(valueCodec, "valueCodec == null");

this.info = getClassSimpleName(getClass()) + "-" + getName()
+ "(" + getClassSimpleName(keyType) + "->" + getClassSimpleName(valueType) + ")";

this.supportCodecBuffer = keyCodec.supportCodecBuffer()
&& valueCodec.supportCodecBuffer();

final String threadNamePrefix = rawTable.getName() + "_";
if (cacheType == CacheType.FULL_CACHE) {
cache = new FullTableCache<>(threadNamePrefix);
//fill cache
Expand Down Expand Up @@ -443,9 +441,7 @@ public String getName() {

@Override
public String toString() {
return getClassSimpleName(getClass()) + "-" + getName()
+ "(" + getClassSimpleName(keyType)
+ "->" + getClassSimpleName(valueType) + ")";
return info;
}

@Override
Expand Down Expand Up @@ -572,14 +568,6 @@ public KEY getKey() throws IOException {
public VALUE getValue() throws IOException {
return decodeValue(rawKeyValue.getValue());
}

public byte[] getRawKey() throws IOException {
return rawKeyValue.getKey();
}

public byte[] getRawValue() throws IOException {
return rawKeyValue.getValue();
}
}

RawIterator<CodecBuffer> newCodecBufferTableIterator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static RDBStore newRDBStore(File dbFile, ManagedDBOptions options,
throws IOException {
return new RDBStore(dbFile, options, null, new ManagedWriteOptions(), families,
CodecRegistry.newBuilder().build(), false, 1000, null, false,
maxDbUpdatesSizeThreshold, true, null, "", true);
maxDbUpdatesSizeThreshold, true, null, true);
}

public static final int MAX_DB_UPDATES_SIZE_THRESHOLD = 80;
Expand Down