Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c38ead2
added ops per sec and average pagination metric for listkeys
Dec 7, 2023
36ca4fa
updated test cases
Dec 12, 2023
1818a49
Updated all test cases
Dec 13, 2023
f731a19
refactored code
Dec 13, 2023
6d3d979
refactored code
Dec 13, 2023
18e1e00
fixed errors
Dec 14, 2023
6744486
fixed import errors
Dec 14, 2023
a8c1c0a
Merge branch 'master' into HDDS-9874
muskan1012 Dec 18, 2023
3375fce
rearranged imports and refactored code
muskan1012 Dec 18, 2023
68b8238
Merge branch 'master' into HDDS-9874
muskan1012 Jan 4, 2024
e879fc9
removed duplicate code
muskan1012 Jan 8, 2024
94545b6
code change to avoid build failure
muskan1012 Jan 10, 2024
860247b
Merge branch 'master' into HDDS-9874
muskan1012 Jan 28, 2024
3c15956
fixed test cases
muskan1012 Feb 7, 2024
2a3a512
Merge branch 'HDDS-9874' of github.com:muskan1012/ozone into HDDS-9874
muskan1012 Feb 7, 2024
7fb39c6
Merge branch 'apache:master' into HDDS-9874
muskan1012 Feb 7, 2024
1bd6fd7
fixed checkstyle and other issues
muskan1012 Feb 7, 2024
31f8a3c
checkstyle issue resolved
muskan1012 Feb 7, 2024
3a73859
unit test resolution
muskan1012 Feb 7, 2024
6bf2a5e
unit test case failures resolutions
muskan1012 Feb 8, 2024
8671712
listKeysReadFromRocksDbLatency metric added
muskan1012 Feb 8, 2024
a0397eb
removed irrelevant code
muskan1012 Feb 8, 2024
dfd427b
refactored code to avoid null pointer exception
muskan1012 Feb 8, 2024
cf5f43d
Merge branch 'master' into HDDS-9874
muskan1012 Mar 26, 2024
570bc36
Merge branch 'master' into HDDS-9874
muskan1012 Jun 18, 2024
364de9b
updated code to avoid npe
muskan1012 Jun 18, 2024
d26e986
npe resolution for integration-recon
muskan1012 Jun 18, 2024
2bb0cda
refactored code as per review comments
muskan1012 Jun 24, 2024
bf9d575
minor nits fixed
muskan1012 Jun 25, 2024
b0a5832
changes as per the review comment
muskan1012 Jul 1, 2024
1c83093
Apply suggestions from code review
muskan1012 Jul 1, 2024
8139ae7
changed naming convention as per the review comment
muskan1012 Jul 8, 2024
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 @@ -113,12 +113,21 @@ public static void unregister() {
@Metric(about = "Ratis local command execution latency in nano seconds")
private MutableRate validateAndUpdateCacheLatencyNs;

@Metric(about = "average pagination for listKeys")
private MutableRate listKeysAveragePagination;

@Metric(about = "ops per second for listKeys")
private MutableRate listKeysOpsPerSec;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the Latency metric listKeysLatencyNs, maybe we just need to add a cumulative number of listKeys metric(such as: listKeysSize), which we can calculate to get listKeysOpsPerSec and listKeysAveragePagination.

@Metric(about = "listKeys latency in nanoseconds")
private MutableRate listKeysLatencyNs;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented the cumulative number of listKeys using keyCount, which is set to maxKeys if truncated or cacheKeyMap.size() otherwise.
listKeysAveragePagination is set using keyCount.
listKeysOpsPerSec is calculated as keyCount / ((Time.monotonicNowNanos() - startNanos) / 1_000_000_000.0f).
Added latency tracking with addListKeysReadFromRocksDbLatencyNs.
This approach captures the metrics as you suggested.


@Metric(about = "ACLs check latency in listKeys")
private MutableRate listKeysAclCheckLatencyNs;

@Metric(about = "resolveBucketLink latency in listKeys")
private MutableRate listKeysResolveBucketLatencyNs;

@Metric(about = "readFromRockDb latency in listKeys")
private MutableRate listKeysReadFromRocksDbLatencyNs;

public void addLookupLatency(long latencyInNs) {
lookupLatencyNs.add(latencyInNs);
}
Expand Down Expand Up @@ -216,11 +225,23 @@ public MutableRate getValidateAndUpdateCacheLatencyNs() {
return validateAndUpdateCacheLatencyNs;
}

public void setListKeysAveragePagination(long averagePagination) {
listKeysAveragePagination.add(averagePagination);
}

public void setListKeysOpsPerNs(long opsPerNs) {
listKeysOpsPerSec.add(opsPerNs);
}

MutableRate getListKeysAclCheckLatencyNs() {
return listKeysAclCheckLatencyNs;
}

MutableRate getListKeysResolveBucketLatencyNs() {
return listKeysResolveBucketLatencyNs;
}

public void addListKeysReadFromRocksDbLatencyNs(long latencyInNs) {
listKeysReadFromRocksDbLatencyNs.add(latencyInNs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ public class OmMetadataManagerImpl implements OMMetadataManager,
private final Map<String, TableCacheMetrics> tableCacheMetricsMap =
new HashMap<>();
private SnapshotChainManager snapshotChainManager;
private final OMPerformanceMetrics perfMetrics;
private final S3Batcher s3Batcher = new S3SecretBatcher();

/**
Expand All @@ -328,28 +329,46 @@ public class OmMetadataManagerImpl implements OMMetadataManager,
*/
public OmMetadataManagerImpl(OzoneConfiguration conf,
OzoneManager ozoneManager) throws IOException {
this.ozoneManager = ozoneManager;
init(conf, ozoneManager);
this.lock = new OzoneManagerLock(conf);
this.omEpoch = OmUtils.getOMEpoch(isRatisEnabled);
this.perfMetrics = null;
start(conf);
}

public OmMetadataManagerImpl(OzoneConfiguration conf,
OzoneManager ozoneManager,
OMPerformanceMetrics perfMetrics)
throws IOException {
init(conf, ozoneManager);
Comment thread
tanvipenumudy marked this conversation as resolved.
Outdated
this.lock = new OzoneManagerLock(conf);
// TODO: This is a temporary check. Once fully implemented, all OM state
// change should go through Ratis - be it standalone (for non-HA) or
// replicated (for HA).
isRatisEnabled = conf.getBoolean(
OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY,
OMConfigKeys.OZONE_OM_RATIS_ENABLE_DEFAULT);
this.omEpoch = OmUtils.getOMEpoch(isRatisEnabled);
this.perfMetrics = perfMetrics;
// For test purpose only
ignorePipelineinKey = conf.getBoolean(
"ozone.om.ignore.pipeline", Boolean.TRUE);
"ozone.om.ignore.pipeline", Boolean.TRUE);
Comment thread
muskan1012 marked this conversation as resolved.
Outdated
start(conf);
}
Comment thread
muskan1012 marked this conversation as resolved.

private void init(OzoneConfiguration conf, OzoneManager manager) {
this.ozoneManager = manager;
// TODO: This is a temporary check. Once fully implemented, all OM state
// change should go through Ratis - be it standalone (for non-HA) or
// replicated (for HA).
Comment thread
tanvipenumudy marked this conversation as resolved.
Outdated
isRatisEnabled = conf.getBoolean(
OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY,
OMConfigKeys.OZONE_OM_RATIS_ENABLE_DEFAULT);
// For test purpose only
ignorePipelineinKey = conf.getBoolean(
"ozone.om.ignore.pipeline", Boolean.TRUE);
}
/**
* For subclass overriding.
*/
protected OmMetadataManagerImpl() {
OzoneConfiguration conf = new OzoneConfiguration();
this.lock = new OzoneManagerLock(conf);
this.omEpoch = 0;
perfMetrics = null;
}

public static OmMetadataManagerImpl createCheckpointMetadataManager(
Expand Down Expand Up @@ -384,6 +403,7 @@ private OmMetadataManagerImpl(OzoneConfiguration conf, File dir, String name)
setStore(loadDB(conf, dir, name, true,
java.util.Optional.of(Boolean.TRUE), Optional.empty()));
initializeOmTables(CacheType.PARTIAL_CACHE, false);
perfMetrics = null;
}


Expand Down Expand Up @@ -421,6 +441,7 @@ private OmMetadataManagerImpl(OzoneConfiguration conf, File dir, String name)
stop();
throw e;
}
perfMetrics = null;
}

@Override
Expand Down Expand Up @@ -1163,7 +1184,7 @@ public List<OmBucketInfo> listBuckets(final String volumeName,
public ListKeysResult listKeys(String volumeName, String bucketName,
String startKey, String keyPrefix, int maxKeys)
throws IOException {

long startNanos = Time.monotonicNowNanos();
List<OmKeyInfo> result = new ArrayList<>();
if (maxKeys <= 0) {
return new ListKeysResult(result, false);
Expand Down Expand Up @@ -1232,11 +1253,11 @@ public ListKeysResult listKeys(String volumeName, String bucketName,
cacheKeyMap.put(key, omKeyInfo);
}
}

long readFromRDbStartNs, readFromRDbStopNs = 0;
// Get maxKeys from DB if it has.

try (TableIterator<String, ? extends KeyValue<String, OmKeyInfo>>
keyIter = getKeyTable(getBucketLayout()).iterator()) {
readFromRDbStartNs = Time.monotonicNowNanos();
KeyValue< String, OmKeyInfo > kv;
keyIter.seek(seekKey);
// we need to iterate maxKeys + 1 here because if skipStartKey is true,
Expand All @@ -1259,10 +1280,24 @@ public ListKeysResult listKeys(String volumeName, String bucketName,
break;
}
}
readFromRDbStopNs = Time.monotonicNowNanos();
}

boolean isTruncated = cacheKeyMap.size() > maxKeys;

if (perfMetrics != null) {
long averagePagination;
Comment thread
tanvipenumudy marked this conversation as resolved.
Outdated
if (isTruncated) {
averagePagination = maxKeys;
} else {
averagePagination = cacheKeyMap.size();
}
perfMetrics.setListKeysAveragePagination(averagePagination);
long opsPerNs =
averagePagination / (Time.monotonicNowNanos() - startNanos);
perfMetrics.setListKeysOpsPerNs(opsPerNs);
Comment thread
tanvipenumudy marked this conversation as resolved.
Outdated
perfMetrics.addListKeysReadFromRocksDbLatencyNs(readFromRDbStopNs - readFromRDbStartNs);
}
// Finally DB entries and cache entries are merged, then return the count
// of maxKeys from the sorted map.
currentCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ private void addBucketToMetaTable(OmBucketInfo bucketInfo)
* @throws IOException if I/O error occurs in setting up data store for the
* metadata manager.
*/
private OMMetadataManager createOMMetadataManagerSpy() throws IOException {
private OmMetadataManagerImpl createOMMetadataManagerSpy()
throws IOException {
Comment thread
muskan1012 marked this conversation as resolved.
Outdated
OzoneConfiguration conf = new OzoneConfiguration();
File newFolder = folder.toFile();
if (!newFolder.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ public void parse(String vol, String buck, String db,

OzoneConfiguration conf = new OzoneConfiguration();
conf.set(OMConfigKeys.OZONE_OM_DB_DIRS, db);

OmMetadataManagerImpl metadataManager =
new OmMetadataManagerImpl(conf, null);

metadataManager.start(conf);
Comment thread
muskan1012 marked this conversation as resolved.

org.apache.hadoop.fs.Path effectivePath =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public static void main(String[] args) throws IOException {
}
OmMetadataManagerImpl metadataManager =
new OmMetadataManagerImpl(configuration, null);
return getBlockIdDetailsUtils(metadataManager);
}

private static Map<Long, List<Map<Long, BlockIdDetails>>> getBlockIdDetailsUtils(
OmMetadataManagerImpl metadataManager) throws IOException {
Comment thread
muskan1012 marked this conversation as resolved.
Outdated
try {
Table<String, OmKeyInfo> keyTable =
metadataManager.getKeyTable(getBucketLayout());
Expand Down