This is an automated email from the ASF dual-hosted git repository.
bharat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 4669043 HDDS-4329. Expose Ratis retry config cache in OM. (#1659)
4669043 is described below
commit 46690430d7c093b9859592057fbaab569ea570cc
Author: Bharat Viswanadham <[email protected]>
AuthorDate: Tue Dec 8 10:23:47 2020 -0800
HDDS-4329. Expose Ratis retry config cache in OM. (#1659)
---
.../org/apache/hadoop/ozone/om/OMConfigKeys.java | 2 +
.../hadoop/ozone/TestOzoneConfigurationFields.java | 3 +-
.../apache/hadoop/ozone/om/TestOzoneManagerHA.java | 14 ++++++
.../ozone/om/TestOzoneManagerHAMetadataOnly.java | 24 +++++++++-
.../ozone/om/ratis/OzoneManagerRatisServer.java | 18 ++++++++
.../om/ratis/OzoneManagerRatisServerConfig.java | 54 ++++++++++++++++++++++
6 files changed, 112 insertions(+), 3 deletions(-)
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
index a5f2d57..2c09282 100644
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
+++
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
@@ -239,4 +239,6 @@ public final class OMConfigKeys {
"ozone.om.enable.filesystem.paths";
public static final boolean OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT =
false;
+
+ public static final String OZONE_OM_HA_PREFIX = "ozone.om.ha";
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestOzoneConfigurationFields.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestOzoneConfigurationFields.java
index 16604f9..da2a63c 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestOzoneConfigurationFields.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestOzoneConfigurationFields.java
@@ -77,7 +77,8 @@ public class TestOzoneConfigurationFields extends
TestConfigurationFieldsBase {
ReconServerConfigKeys.RECON_OM_SNAPSHOT_TASK_INITIAL_DELAY,
ReconServerConfigKeys.RECON_OM_SNAPSHOT_TASK_INTERVAL_DELAY,
ReconServerConfigKeys.RECON_OM_SNAPSHOT_TASK_FLUSH_PARAM,
- OMConfigKeys.OZONE_OM_RATIS_SNAPSHOT_AUTO_TRIGGER_THRESHOLD_KEY
+ OMConfigKeys.OZONE_OM_RATIS_SNAPSHOT_AUTO_TRIGGER_THRESHOLD_KEY,
+ OMConfigKeys.OZONE_OM_HA_PREFIX
// TODO HDDS-2856
));
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
index 4a2ccbb..effe32f 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.ozone.client.io.OzoneInputStream;
import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
import org.apache.hadoop.ozone.client.rpc.RpcClient;
import org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider;
+import org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServerConfig;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.Before;
import org.junit.After;
@@ -46,6 +47,7 @@ import org.junit.rules.Timeout;
import java.io.IOException;
import java.net.ConnectException;
+import java.time.Duration;
import java.util.UUID;
import java.util.HashMap;
@@ -77,6 +79,7 @@ public abstract class TestOzoneManagerHA {
private static final int OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS = 5;
private static final int IPC_CLIENT_CONNECT_MAX_RETRIES = 4;
private static final long SNAPSHOT_THRESHOLD = 50;
+ private static final Duration RETRY_CACHE_DURATION = Duration.ofSeconds(30);
@Rule
public ExpectedException exception = ExpectedException.none();
@@ -116,6 +119,10 @@ public abstract class TestOzoneManagerHA {
return OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS;
}
+ public static Duration getRetryCacheDuration() {
+ return RETRY_CACHE_DURATION;
+ }
+
/**
* Create a MiniDFSCluster for testing.
* <p>
@@ -144,6 +151,13 @@ public abstract class TestOzoneManagerHA {
OMConfigKeys.OZONE_OM_RATIS_SNAPSHOT_AUTO_TRIGGER_THRESHOLD_KEY,
SNAPSHOT_THRESHOLD);
+ OzoneManagerRatisServerConfig omHAConfig =
+ conf.getObject(OzoneManagerRatisServerConfig.class);
+
+ omHAConfig.setRetryCacheTimeout(RETRY_CACHE_DURATION);
+
+ conf.setFromObject(omHAConfig);
+
/**
* config for key deleting service.
*/
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAMetadataOnly.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAMetadataOnly.java
index fbe1762..bfdcefe 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAMetadataOnly.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAMetadataOnly.java
@@ -419,8 +419,28 @@ public class TestOzoneManagerHAMetadataOnly extends
TestOzoneManagerHA {
// As second time with same client id and call id, this request should
// not be executed ratis server should return from cache.
- Assert.assertFalse(logCapturer.getOutput().contains("created volume:"
- + volumeName));
+ // If 2nd time executed, it will fail with Volume creation failed. check
+ // for that.
+ Assert.assertFalse(logCapturer.getOutput().contains(
+ "Volume creation failed"));
+
+ //Sleep for little above retry cache duration to get cache clear.
+ Thread.sleep(getRetryCacheDuration().toMillis() + 5000);
+
+ raftClientReply =
+ raftServer.submitClientRequest(new RaftClientRequest(clientId,
+ raftServer.getId(), ozoneManagerRatisServer.getRaftGroup()
+ .getGroupId(), callId, Message.valueOf(
+ OMRatisHelper.convertRequestToByteString(omRequest)),
+ RaftClientRequest.writeRequestType(), null));
+
+ Assert.assertTrue(raftClientReply.isSuccess());
+
+ // As second time with same client id and call id, this request should
+ // be executed by ratis server as we are sending this request after cache
+ // expiry duration.
+ Assert.assertTrue(logCapturer.getOutput().contains(
+ "Volume creation failed"));
}
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java
index 0f9e20b..dc83330 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java
@@ -26,6 +26,7 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@@ -81,6 +82,7 @@ import org.slf4j.LoggerFactory;
import static org.apache.hadoop.ipc.RpcConstants.DUMMY_CLIENT_ID;
import static org.apache.hadoop.ipc.RpcConstants.INVALID_CALL_ID;
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_HA_PREFIX;
/**
* Creates a Ratis server endpoint for OM.
@@ -538,9 +540,25 @@ public final class OzoneManagerRatisServer {
RaftServerConfigKeys.Snapshot.setAutoTriggerThreshold(properties,
snapshotAutoTriggerThreshold);
+
+ createRaftServerProperties(conf, properties);
return properties;
}
+ private void createRaftServerProperties(ConfigurationSource ozoneConf,
+ RaftProperties raftProperties) {
+ Map<String, String> ratisServerConf =
+ getOMHAConfigs(ozoneConf);
+ ratisServerConf.forEach((key, val) -> {
+ raftProperties.set(key, val);
+ });
+ }
+
+ private static Map<String, String> getOMHAConfigs(
+ ConfigurationSource configuration) {
+ return configuration.getPropsWithPrefix(OZONE_OM_HA_PREFIX + ".");
+ }
+
/**
* Defines RaftServer Status.
*/
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServerConfig.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServerConfig.java
new file mode 100644
index 0000000..c681289
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServerConfig.java
@@ -0,0 +1,54 @@
+/**
+ * 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.om.ratis;
+
+import org.apache.hadoop.hdds.conf.Config;
+import org.apache.hadoop.hdds.conf.ConfigGroup;
+import org.apache.hadoop.hdds.conf.ConfigType;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.ratis.server.RaftServerConfigKeys;
+
+import java.time.Duration;
+
+import static org.apache.hadoop.hdds.conf.ConfigTag.OM;
+import static org.apache.hadoop.hdds.conf.ConfigTag.OZONE;
+import static org.apache.hadoop.hdds.conf.ConfigTag.RATIS;
+
+/**
+ * Class which defines OzoneManager Ratis Server config.
+ */
+@ConfigGroup(prefix = OMConfigKeys.OZONE_OM_HA_PREFIX + "."
+ + RaftServerConfigKeys.PREFIX)
+public class OzoneManagerRatisServerConfig {
+
+ @Config(key = "retrycache.expirytime",
+ defaultValue = "300s",
+ type = ConfigType.TIME,
+ tags = {OZONE, OM, RATIS},
+ description = "The timeout duration of the retry cache."
+ )
+ private long retryCacheTimeout = Duration.ofSeconds(300).toMillis();
+
+ public long getRetryCacheTimeout() {
+ return retryCacheTimeout;
+ }
+
+ public void setRetryCacheTimeout(Duration duration) {
+ this.retryCacheTimeout = duration.toMillis();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]