Skip to content

Commit 68f9f2d

Browse files
Revert HDDS-1829 On OM reload/restart OmMetrics#numKeys should be updated. (#1183)
1 parent 4d07134 commit 68f9f2d

8 files changed

Lines changed: 2 additions & 85 deletions

File tree

hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/RDBTable.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,4 @@ public String getName() throws IOException {
183183
public void close() throws Exception {
184184
// Nothing do for a Column Family.
185185
}
186-
187-
@Override
188-
public long getEstimatedKeyCount() throws IOException {
189-
try {
190-
return db.getLongProperty(handle, "rocksdb.estimate-num-keys");
191-
} catch (RocksDBException e) {
192-
throw toIOException(
193-
"Failed to get estimated key count of table " + getName(), e);
194-
}
195-
}
196186
}

hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/Table.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ void putWithBatch(BatchOperation batch, KEY key, VALUE value)
111111
*/
112112
String getName() throws IOException;
113113

114-
/**
115-
* Returns the key count of this Table. Note the result can be inaccurate.
116-
* @return Estimated key count of this Table
117-
* @throws IOException on failure
118-
*/
119-
long getEstimatedKeyCount() throws IOException;
120-
121114
/**
122115
* Add entry to the table cache.
123116
*

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ public String getName() throws IOException {
205205
return rawTable.getName();
206206
}
207207

208-
@Override
209-
public long getEstimatedKeyCount() throws IOException {
210-
return rawTable.getEstimatedKeyCount();
211-
}
212-
213208
@Override
214209
public void close() throws Exception {
215210
rawTable.close();

hadoop-hdds/common/src/test/java/org/apache/hadoop/utils/db/TestRDBTableStore.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public class TestRDBTableStore {
5151
Arrays.asList(DFSUtil.bytes2String(RocksDB.DEFAULT_COLUMN_FAMILY),
5252
"First", "Second", "Third",
5353
"Fourth", "Fifth",
54-
"Sixth", "Seventh",
55-
"Eighth");
54+
"Sixth", "Seventh");
5655
@Rule
5756
public TemporaryFolder folder = new TemporaryFolder();
5857
private RDBStore rdbStore = null;
@@ -248,22 +247,4 @@ public void testIsExist() throws Exception {
248247
Assert.assertFalse(testTable.isExist(invalidKey));
249248
}
250249
}
251-
252-
@Test
253-
public void testCountEstimatedRowsInTable() throws Exception {
254-
try (Table<byte[], byte[]> testTable = rdbStore.getTable("Eighth")) {
255-
// Add a few keys
256-
final int numKeys = 12345;
257-
for (int i = 0; i < numKeys; i++) {
258-
byte[] key =
259-
RandomStringUtils.random(10).getBytes(StandardCharsets.UTF_8);
260-
byte[] value =
261-
RandomStringUtils.random(10).getBytes(StandardCharsets.UTF_8);
262-
testTable.put(key, value);
263-
}
264-
long count = testTable.getEstimatedKeyCount();
265-
// The result should be larger than zero but not exceed(?) numKeys
266-
Assert.assertTrue(count > 0 && count <= numKeys);
267-
}
268-
}
269250
}

hadoop-hdds/common/src/test/java/org/apache/hadoop/utils/db/TestTypedRDBTableStore.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public class TestTypedRDBTableStore {
5555
Arrays.asList(DFSUtil.bytes2String(RocksDB.DEFAULT_COLUMN_FAMILY),
5656
"First", "Second", "Third",
5757
"Fourth", "Fifth",
58-
"Sixth", "Seven", "Eighth",
59-
"Ninth");
58+
"Sixth", "Seven", "Eighth");
6059
@Rule
6160
public TemporaryFolder folder = new TemporaryFolder();
6261
private RDBStore rdbStore = null;
@@ -352,22 +351,4 @@ public void testIsExistCache() throws Exception {
352351
Assert.assertFalse(testTable.isExist(key));
353352
}
354353
}
355-
356-
@Test
357-
public void testCountEstimatedRowsInTable() throws Exception {
358-
try (Table<String, String> testTable = createTypedTable(
359-
"Ninth")) {
360-
// Add a few keys
361-
final int numKeys = 12345;
362-
for (int i = 0; i < numKeys; i++) {
363-
String key =
364-
RandomStringUtils.random(10);
365-
String value = RandomStringUtils.random(10);
366-
testTable.put(key, value);
367-
}
368-
long count = testTable.getEstimatedKeyCount();
369-
// The result should be larger than zero but not exceed(?) numKeys
370-
Assert.assertTrue(count > 0 && count <= numKeys);
371-
}
372-
}
373354
}

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,4 @@ String getMultipartKey(String volume, String bucket, String key, String
316316
*/
317317
<KEY, VALUE> long countRowsInTable(Table<KEY, VALUE> table)
318318
throws IOException;
319-
320-
/**
321-
* Returns an estimated number of rows in a table. This is much quicker
322-
* than {@link OMMetadataManager#countRowsInTable} but the result can be
323-
* inaccurate.
324-
* @param table Table
325-
* @return long Estimated number of rows in the table.
326-
* @throws IOException
327-
*/
328-
<KEY, VALUE> long countEstimatedRowsInTable(Table<KEY, VALUE> table)
329-
throws IOException;
330319
}

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -802,16 +802,6 @@ public <KEY, VALUE> long countRowsInTable(Table<KEY, VALUE> table)
802802
return count;
803803
}
804804

805-
@Override
806-
public <KEY, VALUE> long countEstimatedRowsInTable(Table<KEY, VALUE> table)
807-
throws IOException {
808-
long count = 0;
809-
if (table != null) {
810-
count = table.getEstimatedKeyCount();
811-
}
812-
return count;
813-
}
814-
815805
@Override
816806
public Table<String, S3SecretValue> getS3SecretTable() {
817807
return s3SecretTable;

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,8 +3267,6 @@ void reloadOMState(long newSnapshotIndex) throws IOException {
32673267
.getVolumeTable()));
32683268
metrics.setNumBuckets(metadataManager.countRowsInTable(metadataManager
32693269
.getBucketTable()));
3270-
metrics.setNumKeys(metadataManager.countEstimatedRowsInTable(metadataManager
3271-
.getKeyTable()));
32723270

32733271
// Delete the omMetrics file if it exists and save the a new metrics file
32743272
// with new data

0 commit comments

Comments
 (0)