Revert HDDS-1829 On OM reload/restart OmMetrics#numKeys should be updated. (#1183)
This commit is contained in:
parent
4d07134b13
commit
68f9f2d833
|
@ -183,14 +183,4 @@ class RDBTable implements Table<byte[], byte[]> {
|
|||
public void close() throws Exception {
|
||||
// Nothing do for a Column Family.
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEstimatedKeyCount() throws IOException {
|
||||
try {
|
||||
return db.getLongProperty(handle, "rocksdb.estimate-num-keys");
|
||||
} catch (RocksDBException e) {
|
||||
throw toIOException(
|
||||
"Failed to get estimated key count of table " + getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,13 +111,6 @@ public interface Table<KEY, VALUE> extends AutoCloseable {
|
|||
*/
|
||||
String getName() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the key count of this Table. Note the result can be inaccurate.
|
||||
* @return Estimated key count of this Table
|
||||
* @throws IOException on failure
|
||||
*/
|
||||
long getEstimatedKeyCount() throws IOException;
|
||||
|
||||
/**
|
||||
* Add entry to the table cache.
|
||||
*
|
||||
|
|
|
@ -205,11 +205,6 @@ public class TypedTable<KEY, VALUE> implements Table<KEY, VALUE> {
|
|||
return rawTable.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEstimatedKeyCount() throws IOException {
|
||||
return rawTable.getEstimatedKeyCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
rawTable.close();
|
||||
|
|
|
@ -51,8 +51,7 @@ public class TestRDBTableStore {
|
|||
Arrays.asList(DFSUtil.bytes2String(RocksDB.DEFAULT_COLUMN_FAMILY),
|
||||
"First", "Second", "Third",
|
||||
"Fourth", "Fifth",
|
||||
"Sixth", "Seventh",
|
||||
"Eighth");
|
||||
"Sixth", "Seventh");
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
private RDBStore rdbStore = null;
|
||||
|
@ -248,22 +247,4 @@ public class TestRDBTableStore {
|
|||
Assert.assertFalse(testTable.isExist(invalidKey));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountEstimatedRowsInTable() throws Exception {
|
||||
try (Table<byte[], byte[]> testTable = rdbStore.getTable("Eighth")) {
|
||||
// Add a few keys
|
||||
final int numKeys = 12345;
|
||||
for (int i = 0; i < numKeys; i++) {
|
||||
byte[] key =
|
||||
RandomStringUtils.random(10).getBytes(StandardCharsets.UTF_8);
|
||||
byte[] value =
|
||||
RandomStringUtils.random(10).getBytes(StandardCharsets.UTF_8);
|
||||
testTable.put(key, value);
|
||||
}
|
||||
long count = testTable.getEstimatedKeyCount();
|
||||
// The result should be larger than zero but not exceed(?) numKeys
|
||||
Assert.assertTrue(count > 0 && count <= numKeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,8 +55,7 @@ public class TestTypedRDBTableStore {
|
|||
Arrays.asList(DFSUtil.bytes2String(RocksDB.DEFAULT_COLUMN_FAMILY),
|
||||
"First", "Second", "Third",
|
||||
"Fourth", "Fifth",
|
||||
"Sixth", "Seven", "Eighth",
|
||||
"Ninth");
|
||||
"Sixth", "Seven", "Eighth");
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
private RDBStore rdbStore = null;
|
||||
|
@ -352,22 +351,4 @@ public class TestTypedRDBTableStore {
|
|||
Assert.assertFalse(testTable.isExist(key));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountEstimatedRowsInTable() throws Exception {
|
||||
try (Table<String, String> testTable = createTypedTable(
|
||||
"Ninth")) {
|
||||
// Add a few keys
|
||||
final int numKeys = 12345;
|
||||
for (int i = 0; i < numKeys; i++) {
|
||||
String key =
|
||||
RandomStringUtils.random(10);
|
||||
String value = RandomStringUtils.random(10);
|
||||
testTable.put(key, value);
|
||||
}
|
||||
long count = testTable.getEstimatedKeyCount();
|
||||
// The result should be larger than zero but not exceed(?) numKeys
|
||||
Assert.assertTrue(count > 0 && count <= numKeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,15 +316,4 @@ public interface OMMetadataManager {
|
|||
*/
|
||||
<KEY, VALUE> long countRowsInTable(Table<KEY, VALUE> table)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an estimated number of rows in a table. This is much quicker
|
||||
* than {@link OMMetadataManager#countRowsInTable} but the result can be
|
||||
* inaccurate.
|
||||
* @param table Table
|
||||
* @return long Estimated number of rows in the table.
|
||||
* @throws IOException
|
||||
*/
|
||||
<KEY, VALUE> long countEstimatedRowsInTable(Table<KEY, VALUE> table)
|
||||
throws IOException;
|
||||
}
|
||||
|
|
|
@ -802,16 +802,6 @@ public class OmMetadataManagerImpl implements OMMetadataManager {
|
|||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <KEY, VALUE> long countEstimatedRowsInTable(Table<KEY, VALUE> table)
|
||||
throws IOException {
|
||||
long count = 0;
|
||||
if (table != null) {
|
||||
count = table.getEstimatedKeyCount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Table<String, S3SecretValue> getS3SecretTable() {
|
||||
return s3SecretTable;
|
||||
|
|
|
@ -3267,8 +3267,6 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl
|
|||
.getVolumeTable()));
|
||||
metrics.setNumBuckets(metadataManager.countRowsInTable(metadataManager
|
||||
.getBucketTable()));
|
||||
metrics.setNumKeys(metadataManager.countEstimatedRowsInTable(metadataManager
|
||||
.getKeyTable()));
|
||||
|
||||
// Delete the omMetrics file if it exists and save the a new metrics file
|
||||
// with new data
|
||||
|
|
Loading…
Reference in New Issue