[ 
https://issues.apache.org/jira/browse/HDDS-1865?focusedWorklogId=290875&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-290875
 ]

ASF GitHub Bot logged work on HDDS-1865:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Aug/19 23:53
            Start Date: 07/Aug/19 23:53
    Worklog Time Spent: 10m 
      Work Description: xiaoyuyao commented on pull request #1184: HDDS-1865. 
Use "ozone.network.topology.aware.read" to control both RPC client and server 
side logic
URL: https://github.com/apache/hadoop/pull/1184#discussion_r311808404
 
 

 ##########
 File path: 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientWithRatis.java
 ##########
 @@ -91,60 +94,59 @@ public void testGetKeyAndFileWithNetworkTopology() throws 
IOException {
     String keyName = UUID.randomUUID().toString();
 
     // Write data into a key
-    OzoneOutputStream out = bucket.createKey(keyName,
+    try (OzoneOutputStream out = bucket.createKey(keyName,
         value.getBytes().length, ReplicationType.RATIS,
-        THREE, new HashMap<>());
-    out.write(value.getBytes());
-    out.close();
+        THREE, new HashMap<>())) {
+      out.write(value.getBytes());
+    }
 
     // Since the rpc client is outside of cluster, then getFirstNode should be
     // equal to getClosestNode.
     OmKeyArgs.Builder builder = new OmKeyArgs.Builder();
     builder.setVolumeName(volumeName).setBucketName(bucketName)
         .setKeyName(keyName).setRefreshPipeline(true);
 
-    // read key with topology aware read enabled(default)
-    try {
-      OzoneInputStream is = bucket.readKey(keyName);
+    // read key with topology aware read enabled
+    try (OzoneInputStream is = bucket.readKey(keyName)) {
       byte[] b = new byte[value.getBytes().length];
       is.read(b);
       Assert.assertTrue(Arrays.equals(b, value.getBytes()));
     } catch (OzoneChecksumException e) {
-      fail("Reading key should success");
+      fail("Read key should succeed");
     }
-    // read file with topology aware read enabled(default)
-    try {
-      OzoneInputStream is = bucket.readFile(keyName);
+
+    // read file with topology aware read enabled
+    try (OzoneInputStream is = bucket.readKey(keyName)) {
       byte[] b = new byte[value.getBytes().length];
       is.read(b);
       Assert.assertTrue(Arrays.equals(b, value.getBytes()));
     } catch (OzoneChecksumException e) {
-      fail("Reading file should success");
+      fail("Read file should succeed");
     }
 
     // read key with topology aware read disabled
-    conf.set(ScmConfigKeys.DFS_NETWORK_TOPOLOGY_AWARE_READ_ENABLED, "false");
-    OzoneClient newClient = OzoneClientFactory.getRpcClient(conf);
-    ObjectStore newStore = newClient.getObjectStore();
-    OzoneBucket newBucket =
-        newStore.getVolume(volumeName).getBucket(bucketName);
-    try {
-      OzoneInputStream is = newBucket.readKey(keyName);
-      byte[] b = new byte[value.getBytes().length];
-      is.read(b);
-      Assert.assertTrue(Arrays.equals(b, value.getBytes()));
-    } catch (OzoneChecksumException e) {
-      fail("Reading key should success");
-    }
-    // read file with topology aware read disabled
+    conf.setBoolean(OzoneConfigKeys.OZONE_NETWORK_TOPOLOGY_AWARE_READ_KEY,
+        false);
+    try (OzoneClient newClient = OzoneClientFactory.getRpcClient(conf)) {
 
 Review comment:
   I'm glad you fix this OzoneClient leak here in this tests.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 290875)
    Time Spent: 1h 40m  (was: 1.5h)

> Use "ozone.network.topology.aware.read" to control both RPC client and server 
> side logic 
> -----------------------------------------------------------------------------------------
>
>                 Key: HDDS-1865
>                 URL: https://issues.apache.org/jira/browse/HDDS-1865
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>            Reporter: Sammi Chen
>            Assignee: Sammi Chen
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to