Skip to content

Commit eb96ff4

Browse files
authored
HDDS-12590. Used db name as the threadNamePrefix. (#8076)
1 parent cf5bad7 commit eb96ff4

4 files changed

Lines changed: 17 additions & 38 deletions

File tree

hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBStoreBuilder.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ public final class DBStoreBuilder {
107107
// number in request to avoid increase in heap memory.
108108
private long maxDbUpdatesSizeThreshold;
109109
private Integer maxNumberOfOpenFiles = null;
110-
private String threadNamePrefix = "";
111110

112111
/**
113112
* Create DBStoreBuilder from a generic DBDefinition.
@@ -233,7 +232,7 @@ public DBStore build() throws IOException {
233232
return new RDBStore(dbFile, rocksDBOption, statistics, writeOptions, tableConfigs,
234233
registry.build(), openReadOnly, maxFSSnapshots, dbJmxBeanNameName,
235234
enableCompactionDag, maxDbUpdatesSizeThreshold, createCheckpointDirs,
236-
configuration, threadNamePrefix, enableRocksDbMetrics);
235+
configuration, enableRocksDbMetrics);
237236
} finally {
238237
tableConfigs.forEach(TableConfig::close);
239238
}
@@ -323,11 +322,6 @@ public DBStoreBuilder setMaxNumberOfOpenFiles(Integer maxNumberOfOpenFiles) {
323322
return this;
324323
}
325324

326-
public DBStoreBuilder setThreadNamePrefix(String prefix) {
327-
this.threadNamePrefix = prefix;
328-
return this;
329-
}
330-
331325
/**
332326
* Converts column families and their corresponding options that have been
333327
* registered with the builder to a set of {@link TableConfig} objects.

hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStore.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public class RDBStore implements DBStore {
7474
private final long maxDbUpdatesSizeThreshold;
7575
private final ManagedDBOptions dbOptions;
7676
private final ManagedStatistics statistics;
77-
private final String threadNamePrefix;
7877

7978
@SuppressWarnings("parameternumber")
8079
public RDBStore(File dbFile, ManagedDBOptions dbOptions, ManagedStatistics statistics,
@@ -83,11 +82,10 @@ public RDBStore(File dbFile, ManagedDBOptions dbOptions, ManagedStatistics stati
8382
String dbJmxBeanName, boolean enableCompactionDag,
8483
long maxDbUpdatesSizeThreshold,
8584
boolean createCheckpointDirs,
86-
ConfigurationSource configuration, String threadNamePrefix,
85+
ConfigurationSource configuration,
8786
boolean enableRocksDBMetrics)
8887

8988
throws IOException {
90-
this.threadNamePrefix = threadNamePrefix;
9189
Preconditions.checkNotNull(dbFile, "DB file location cannot be null");
9290
Preconditions.checkNotNull(families);
9391
Preconditions.checkArgument(!families.isEmpty());
@@ -306,8 +304,7 @@ public <K, V> TypedTable<K, V> getTable(String name,
306304
public <K, V> Table<K, V> getTable(String name,
307305
Class<K> keyType, Class<V> valueType,
308306
TableCache.CacheType cacheType) throws IOException {
309-
return new TypedTable<>(getTable(name), codecRegistry, keyType,
310-
valueType, cacheType, threadNamePrefix);
307+
return new TypedTable<>(getTable(name), codecRegistry, keyType, valueType, cacheType);
311308
}
312309

313310
@Override

hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ public class TypedTable<KEY, VALUE> implements Table<KEY, VALUE> {
5757
static final int BUFFER_SIZE_DEFAULT = 4 << 10; // 4 KB
5858

5959
private final RDBTable rawTable;
60+
private final String info;
6061

61-
private final Class<KEY> keyType;
6262
private final Codec<KEY> keyCodec;
63-
private final Class<VALUE> valueType;
6463
private final Codec<VALUE> valueCodec;
6564

6665
private final boolean supportCodecBuffer;
@@ -72,11 +71,9 @@ public class TypedTable<KEY, VALUE> implements Table<KEY, VALUE> {
7271
* The same as this(rawTable, codecRegistry, keyType, valueType,
7372
* CacheType.PARTIAL_CACHE).
7473
*/
75-
public TypedTable(RDBTable rawTable,
76-
CodecRegistry codecRegistry, Class<KEY> keyType,
77-
Class<VALUE> valueType) throws IOException {
78-
this(rawTable, codecRegistry, keyType, valueType,
79-
CacheType.PARTIAL_CACHE, "");
74+
TypedTable(RDBTable rawTable, CodecRegistry codecRegistry, Class<KEY> keyType, Class<VALUE> valueType)
75+
throws IOException {
76+
this(rawTable, codecRegistry, keyType, valueType, CacheType.PARTIAL_CACHE);
8077
}
8178

8279
/**
@@ -87,27 +84,28 @@ public TypedTable(RDBTable rawTable,
8784
* @param keyType The key type.
8885
* @param valueType The value type.
8986
* @param cacheType How to cache the entries?
90-
* @param threadNamePrefix
9187
* @throws IOException if failed to iterate the raw table.
9288
*/
93-
public TypedTable(RDBTable rawTable,
94-
CodecRegistry codecRegistry, Class<KEY> keyType,
95-
Class<VALUE> valueType,
96-
CacheType cacheType, String threadNamePrefix) throws IOException {
89+
TypedTable(RDBTable rawTable, CodecRegistry codecRegistry, Class<KEY> keyType, Class<VALUE> valueType,
90+
CacheType cacheType) throws IOException {
9791
this.rawTable = Objects.requireNonNull(rawTable, "rawTable==null");
9892
Objects.requireNonNull(codecRegistry, "codecRegistry == null");
9993

100-
this.keyType = Objects.requireNonNull(keyType, "keyType == null");
94+
Objects.requireNonNull(keyType, "keyType == null");
10195
this.keyCodec = codecRegistry.getCodecFromClass(keyType);
10296
Objects.requireNonNull(keyCodec, "keyCodec == null");
10397

104-
this.valueType = Objects.requireNonNull(valueType, "valueType == null");
98+
Objects.requireNonNull(valueType, "valueType == null");
10599
this.valueCodec = codecRegistry.getCodecFromClass(valueType);
106100
Objects.requireNonNull(valueCodec, "valueCodec == null");
107101

102+
this.info = getClassSimpleName(getClass()) + "-" + getName()
103+
+ "(" + getClassSimpleName(keyType) + "->" + getClassSimpleName(valueType) + ")";
104+
108105
this.supportCodecBuffer = keyCodec.supportCodecBuffer()
109106
&& valueCodec.supportCodecBuffer();
110107

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

444442
@Override
445443
public String toString() {
446-
return getClassSimpleName(getClass()) + "-" + getName()
447-
+ "(" + getClassSimpleName(keyType)
448-
+ "->" + getClassSimpleName(valueType) + ")";
444+
return info;
449445
}
450446

451447
@Override
@@ -572,14 +568,6 @@ public KEY getKey() throws IOException {
572568
public VALUE getValue() throws IOException {
573569
return decodeValue(rawKeyValue.getValue());
574570
}
575-
576-
public byte[] getRawKey() throws IOException {
577-
return rawKeyValue.getKey();
578-
}
579-
580-
public byte[] getRawValue() throws IOException {
581-
return rawKeyValue.getValue();
582-
}
583571
}
584572

585573
RawIterator<CodecBuffer> newCodecBufferTableIterator(

hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static RDBStore newRDBStore(File dbFile, ManagedDBOptions options,
6262
throws IOException {
6363
return new RDBStore(dbFile, options, null, new ManagedWriteOptions(), families,
6464
CodecRegistry.newBuilder().build(), false, 1000, null, false,
65-
maxDbUpdatesSizeThreshold, true, null, "", true);
65+
maxDbUpdatesSizeThreshold, true, null, true);
6666
}
6767

6868
public static final int MAX_DB_UPDATES_SIZE_THRESHOLD = 80;

0 commit comments

Comments
 (0)