xichen01 commented on code in PR #6682:
URL: https://github.com/apache/ozone/pull/6682#discussion_r1601965801
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -1669,21 +1670,27 @@ public void start() throws IOException {
}
// Set metrics and start metrics back ground thread
- metrics.setNumVolumes(metadataManager.countRowsInTable(metadataManager
- .getVolumeTable()));
- metrics.setNumBuckets(metadataManager.countRowsInTable(metadataManager
- .getBucketTable()));
-
- if (getMetricsStorageFile().exists()) {
- OmMetricsInfo metricsInfo = READER.readValue(getMetricsStorageFile());
- metrics.setNumKeys(metricsInfo.getNumKeys());
- }
+ CompletableFuture.runAsync(() -> {
+ try {
+ metrics.setNumVolumes(
+
metadataManager.countRowsInTable(metadataManager.getVolumeTable()));
+ metrics.setNumBuckets(
+
metadataManager.countRowsInTable(metadataManager.getBucketTable()));
+
+ if (getMetricsStorageFile().exists()) {
+ OmMetricsInfo metricsInfo =
READER.readValue(getMetricsStorageFile());
+ metrics.setNumKeys(metricsInfo.getNumKeys());
+ }
- // FSO(FILE_SYSTEM_OPTIMIZED)
- metrics.setNumDirs(metadataManager
- .countEstimatedRowsInTable(metadataManager.getDirectoryTable()));
- metrics.setNumFiles(metadataManager
- .countEstimatedRowsInTable(metadataManager.getFileTable()));
+ // FSO(FILE_SYSTEM_OPTIMIZED)
+ metrics.setNumDirs(metadataManager.countEstimatedRowsInTable(
+ metadataManager.getDirectoryTable()));
+ metrics.setNumFiles(metadataManager.countEstimatedRowsInTable(
+ metadataManager.getFileTable()));
+ } catch (IOException e) {
+ LOG.warn("Async set om metrics fail.", e);
+ }
+ });
Review Comment:
It may be necessary to continue to throw the Exception here.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -1669,21 +1670,27 @@ public void start() throws IOException {
}
// Set metrics and start metrics back ground thread
- metrics.setNumVolumes(metadataManager.countRowsInTable(metadataManager
- .getVolumeTable()));
- metrics.setNumBuckets(metadataManager.countRowsInTable(metadataManager
- .getBucketTable()));
-
- if (getMetricsStorageFile().exists()) {
- OmMetricsInfo metricsInfo = READER.readValue(getMetricsStorageFile());
- metrics.setNumKeys(metricsInfo.getNumKeys());
- }
+ CompletableFuture.runAsync(() -> {
+ try {
+ metrics.setNumVolumes(
+
metadataManager.countRowsInTable(metadataManager.getVolumeTable()));
+ metrics.setNumBuckets(
+
metadataManager.countRowsInTable(metadataManager.getBucketTable()));
+
+ if (getMetricsStorageFile().exists()) {
+ OmMetricsInfo metricsInfo =
READER.readValue(getMetricsStorageFile());
+ metrics.setNumKeys(metricsInfo.getNumKeys());
+ }
Review Comment:
I think we can also move the `ScheduleOMMetricsWriteTask` scheduling code to
this `runAsync` , So the order of the `metrics.numKeys` init would be the same
as before.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]