adoroszlai commented on code in PR #7164:
URL: https://github.com/apache/ozone/pull/7164#discussion_r1749989258


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java:
##########
@@ -2610,4 +2611,35 @@ private void deleteFiles(Path base, List<String> 
fileNames) throws IOException {
     }
   }
 
+  @Test
+  public void testSetReplication() throws IOException {

Review Comment:
   Would it be possible to implement (most of) the new test in 
`OzoneFileSystemTests` and reuse it in `AbstractOzoneFileSystemTest` and 
`AbstractRootOzoneFileSystemTest`?



##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java:
##########
@@ -811,4 +817,36 @@ public boolean setSafeMode(SafeModeAction action, boolean 
isChecked)
     return ozoneClient.getProxy().getOzoneManagerClient().setSafeMode(
         action, isChecked);
   }
+
+  @Override
+  public void setReplication(String key, short replication) throws IOException 
{
+    OzoneKeyDetails keyDetails = null;

Review Comment:
   nit: `= null` is unnecessary.



##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:
##########
@@ -392,6 +397,41 @@ protected void incrementCounter(Statistic objectsRead, 
long count) {
     //noop: Use RootedOzoneClientAdapterImpl which supports statistics.
   }
 
+  @Override
+  public void setReplication(String key, short replication) throws IOException 
{

Review Comment:
   Can we avoid duplication between the two adapter classes?



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java:
##########
@@ -2289,4 +2293,30 @@ void testSnapshotRead() throws Exception {
     assertEquals(2, f2.length);
     assertEquals(3, f3.length);
   }
+
+  @Test
+  public void testSetReplication() throws IOException {
+    String testKeyName = "testKey" + RandomStringUtils.randomNumeric(4);
+    Path testKeyPath = new Path("/" + testKeyName);
+    try (OzoneOutputStream outputStream = client.getObjectStore()
+        .getVolume(volumeName).getBucket(bucketName)
+        .createKey(testKeyName, 1,
+            
RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE),
+            new HashMap<>())) {
+      outputStream.write(RandomUtils.nextBytes(1));
+    }
+    OzoneKeyDetails key = getKey(testKeyPath, false);
+    assertEquals(HddsProtos.ReplicationType.RATIS,
+        key.getReplicationConfig().getReplicationType());
+    assertEquals(ReplicationFactor.ONE.toString(),
+        key.getReplicationConfig().getReplication());
+    o3fs.setReplication(testKeyPath, (short) 3);
+    key = getKey(testKeyPath, false);
+    assertEquals(ReplicationFactor.THREE.toString(),
+        key.getReplicationConfig().getReplication());
+    IOException exception = assertThrows(IOException.class,
+        () -> o3fs.setReplication(testKeyPath, (short) 5),
+        "Does not throw IOException");
+    assertTrue(exception.getMessage().contains("not supported"));

Review Comment:
   nit: please use `assertThat` for better failure description
   
   ```suggestion
       assertThat(exception.getMessage()).contains("not supported");
   ```
   
   (may need import, too)



-- 
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]

Reply via email to