duongkame commented on code in PR #4373:
URL: https://github.com/apache/ozone/pull/4373#discussion_r1136615756
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSBucketLayout.java:
##########
@@ -116,19 +118,21 @@ public static void initCluster() throws Exception {
.setNumDatanodes(3)
.build();
cluster.waitForClusterToBeReady();
- objectStore = cluster.getClient().getObjectStore();
+ client = cluster.getClient();
+ objectStore = client.getObjectStore();
rootPath = String.format("%s://%s/",
OzoneConsts.OZONE_OFS_URI_SCHEME, conf.get(OZONE_OM_ADDRESS_KEY));
// create a volume and a bucket to be used by RootedOzoneFileSystem (OFS)
volumeName =
- TestDataUtil.createVolumeAndBucket(cluster)
+ TestDataUtil.createVolumeAndBucket(client)
.getVolumeName();
volumePath = new Path(OZONE_URI_DELIMITER, volumeName);
}
@AfterClass
public static void teardown() throws IOException {
+ IOUtils.closeQuietly(client);
Review Comment:
nit: I'm not sure if `closeQuietly` is null safe (I think when a
`closeQuietly(null)` will pass a null array instead of an array of a null
object). If it is, either move this statement into the `if (cluster != null) {`
block or make `closeQuietly` null-safe.
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java:
##########
@@ -178,15 +178,6 @@ void waitForPipelineTobeReady(HddsProtos.ReplicationFactor
factor,
*/
OzoneClient getClient() throws IOException;
Review Comment:
As you're refactoring, would be nice if this is renamed to `newClient()`, so
that the client code is aware that this method creates a new client instance
and "feels" responsible to close it.
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMetrics.java:
##########
@@ -81,9 +84,10 @@ public static void init() throws Exception {
.setStreamBufferMaxSize(4) // MB
.build();
cluster.waitForClusterToBeReady();
+ client = cluster.getClient();
// create a volume and a bucket to be used by OzoneFileSystem
- bucket = TestDataUtil.createVolumeAndBucket(cluster);
+ bucket = TestDataUtil.createVolumeAndBucket(client);
Review Comment:
Programmatically, the `TestDataUtil.createVolumeAndBucket` creates and
`closes` `OzoneClient` internally is a better model. It'll be much less noisy.
--
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]