sumitagrawl commented on code in PR #5530:
URL: https://github.com/apache/ozone/pull/5530#discussion_r1387430161


##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java:
##########
@@ -350,6 +350,10 @@ public long getExcludeNodesExpiryTime() {
     return excludeNodesExpiryTime;
   }
 
+  public void setExcludeNodesExpiryTime(long expiryTime) {

Review Comment:
   unable to find its caller in changed code, please check if this is required



##########
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/io/TestKeyOutputStream.java:
##########
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.ozone.client.io;
+
+
+import org.apache.hadoop.hdds.client.BlockID;
+import org.apache.hadoop.hdds.client.RatisReplicationConfig;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.OzoneClientConfig;
+import org.apache.hadoop.hdds.scm.XceiverClientFactory;
+import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList;
+import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.ozone.om.helpers.OpenKeySession;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.protocolPB.OzoneManagerClientProtocol;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static 
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.THREE;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test KeyOutputStream with RATIS keys.
+ */
+public class TestKeyOutputStream {
+
+  private static String testKeyString = "test";
+
+  @Test
+  public void testRATISKeyOutputStreamExpiryTime() throws Exception {
+    KeyOutputStream keyOutputStream =
+        createRATISKeyOutputStream();
+    byte[] data = testKeyString.getBytes(UTF_8);
+    keyOutputStream.write(data);
+
+    Assert.assertEquals(3,
+        keyOutputStream.getExcludeList().getDatanodes().size());
+
+    ExcludeList excludeList = spy(keyOutputStream.getExcludeList());
+    when(excludeList.getExpiryTime()).thenReturn(300 * 1000L);
+    doReturn(true).when(excludeList)
+        .isExpired(anyLong()); // mock DN in exclude list expires
+    
keyOutputStream.getBlockOutputStreamEntryPool().setExcludeList(excludeList);
+    Assert.assertEquals(0,
+        keyOutputStream.getExcludeList().getDatanodes().size());
+  }
+
+  private KeyOutputStream createRATISKeyOutputStream() throws Exception {
+    OpenKeySession openKeySession = mock(OpenKeySession.class);
+    OmKeyInfo omKeyInfo =  new OmKeyInfo.Builder()
+        .setVolumeName("testvolume")
+        .setBucketName("testbucket")
+        .setKeyName("testKey")
+        .build();
+    when(openKeySession.getKeyInfo()).thenReturn(omKeyInfo);
+
+    XceiverClientFactory xceiverClientManager
+        = mock(XceiverClientFactory.class);
+
+    OzoneManagerClientProtocol ozoneManagerClientProtocol
+        = mock(OzoneManagerClientProtocol.class);
+
+    OzoneClientConfig clientConfig = spy(new OzoneClientConfig());

Review Comment:
   we do not need spy ozone config, just need set config value with new 
configuration



##########
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/io/TestKeyOutputStream.java:
##########
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.ozone.client.io;
+
+
+import org.apache.hadoop.hdds.client.BlockID;
+import org.apache.hadoop.hdds.client.RatisReplicationConfig;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.OzoneClientConfig;
+import org.apache.hadoop.hdds.scm.XceiverClientFactory;
+import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList;
+import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.ozone.om.helpers.OpenKeySession;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.protocolPB.OzoneManagerClientProtocol;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static 
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.THREE;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test KeyOutputStream with RATIS keys.
+ */
+public class TestKeyOutputStream {
+
+  private static String testKeyString = "test";
+
+  @Test
+  public void testRATISKeyOutputStreamExpiryTime() throws Exception {
+    KeyOutputStream keyOutputStream =
+        createRATISKeyOutputStream();
+    byte[] data = testKeyString.getBytes(UTF_8);
+    keyOutputStream.write(data);
+
+    Assert.assertEquals(3,
+        keyOutputStream.getExcludeList().getDatanodes().size());
+
+    ExcludeList excludeList = spy(keyOutputStream.getExcludeList());
+    when(excludeList.getExpiryTime()).thenReturn(300 * 1000L);

Review Comment:
   do we really need this now? as now using config, we are setting same value. 
If not required, we can revert related changes.



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