swamirishi commented on code in PR #4340:
URL: https://github.com/apache/ozone/pull/4340#discussion_r1133440268
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfoMetrics.java:
##########
@@ -104,23 +104,26 @@ public String getMetricsSourceName() {
*/
@Metric("Returns the Used space")
public long getUsed() {
- return volume.getVolumeInfo().getScmUsed();
+ return volume.getVolumeInfo() != null ?
+ volume.getVolumeInfo().getScmUsed() : 0;
Review Comment:
nit: @ashishkumar50 Can we make volumeInfo field -> Optional<VolumeInfo>
volumeInfo; it would be better for future development?
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfoMetrics.java:
##########
@@ -104,23 +104,26 @@ public String getMetricsSourceName() {
*/
@Metric("Returns the Used space")
public long getUsed() {
- return volume.getVolumeInfo().getScmUsed();
+ return volume.getVolumeInfo() != null ?
Review Comment:
```suggestion
return volume.getVolumeInfo().map(VolumeInfo::getScmUsed).orElse(0);
```
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfoMetrics.java:
##########
@@ -104,23 +104,26 @@ public String getMetricsSourceName() {
*/
@Metric("Returns the Used space")
public long getUsed() {
- return volume.getVolumeInfo().getScmUsed();
+ return volume.getVolumeInfo() != null ?
+ volume.getVolumeInfo().getScmUsed() : 0;
Review Comment:
I see there are other functions as well using this field. It would be better
to change it to Optional.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfoMetrics.java:
##########
@@ -104,23 +104,26 @@ public String getMetricsSourceName() {
*/
@Metric("Returns the Used space")
public long getUsed() {
- return volume.getVolumeInfo().getScmUsed();
+ return volume.getVolumeInfo() != null ?
+ volume.getVolumeInfo().getScmUsed() : 0;
Review Comment:
Changes to be made to the field volumeInfo in
org.apache.hadoop.ozone.container.common.volume.StorageVolume;
--
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]