You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by bh...@apache.org on 2020/01/22 17:19:38 UTC
[hadoop-ozone] branch master updated: HDDS-2903. Use regex to match
with ratis properties when creating ratis server. (#458)
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/hadoop-ozone.git
The following commit(s) were added to refs/heads/master by this push:
new c74429d HDDS-2903. Use regex to match with ratis properties when creating ratis server. (#458)
c74429d is described below
commit c74429dec7ba772ce1861771cd9fb3757920ef66
Author: Bharat Viswanadham <bh...@apache.org>
AuthorDate: Wed Jan 22 09:19:27 2020 -0800
HDDS-2903. Use regex to match with ratis properties when creating ratis server. (#458)
---
.../java/org/apache/hadoop/hdds/ratis/RatisHelper.java | 17 +++++++++++++++++
.../org/apache/hadoop/hdds/ratis/TestRatisHelper.java | 17 +++++++++++++++++
.../transport/server/ratis/XceiverServerRatis.java | 3 +++
3 files changed, 37 insertions(+)
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java
index f771df9..98c36b6 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java
@@ -74,6 +74,9 @@ public interface RatisHelper {
String RATIS_GRPC_CLIENT_HEADER_REGEX = "raft\\.grpc\\.(?!server|tls)" +
"([a-z\\.]+)";
+ // Ratis Server header regex filter.
+ String RATIS_SERVER_HEADER_REGEX = "raft\\.server\\.([a-z\\.]+)";
+
static String toRaftPeerIdString(DatanodeDetails id) {
return id.getUuidString();
}
@@ -267,6 +270,20 @@ public interface RatisHelper {
ratisClientConf.forEach((key, val) -> raftProperties.set(key, val));
}
+ /**
+ * Set all the properties matching with regex
+ * {@link RatisHelper#RATIS_SERVER_HEADER_REGEX} in ozone configuration
+ * object and configure it to RaftProperties.
+ * @param ozoneConf
+ * @param raftProperties
+ */
+ static void createRaftServerProperties(Configuration ozoneConf,
+ RaftProperties raftProperties) {
+ Map<String, String> ratisServerConf =
+ ozoneConf.getValByRegex(RATIS_SERVER_HEADER_REGEX);
+ ratisServerConf.forEach((key, val) -> raftProperties.set(key, val));
+ }
+
// For External gRPC client to server with gRPC TLS.
// No mTLS for external client as SCM CA does not issued certificates for them
static GrpcTlsConfig createTlsClientConfig(SecurityConfig conf,
diff --git a/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/ratis/TestRatisHelper.java b/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/ratis/TestRatisHelper.java
index 8fad533..3f7cf3d 100644
--- a/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/ratis/TestRatisHelper.java
+++ b/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/ratis/TestRatisHelper.java
@@ -70,4 +70,21 @@ public class TestRatisHelper {
Assert.assertNull(raftProperties.get("raft.grpc.server.port"));
}
+
+ @Test
+ public void testCreateRaftServerProperties() {
+
+ OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
+ ozoneConfiguration.set("raft.server.rpc.watch.request.timeout", "30s");
+ ozoneConfiguration.set("raft.server.rpc.request.timeout", "30s");
+
+ RaftProperties raftProperties = new RaftProperties();
+ RatisHelper.createRaftServerProperties(ozoneConfiguration, raftProperties);
+
+ Assert.assertEquals("30s",
+ raftProperties.get("raft.server.rpc.watch.request.timeout"));
+ Assert.assertEquals("30s",
+ raftProperties.get("raft.server.rpc.request.timeout"));
+
+ }
}
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
index 17a3892..c4b419e 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
@@ -264,6 +264,9 @@ public final class XceiverServerRatis implements XceiverServerSpi {
ratisServerConfiguration.getNumSnapshotsRetained();
RaftServerConfigKeys.Snapshot.setRetentionFileNum(properties,
numSnapshotsRetained);
+
+ // Set headers starting with prefix raft.server
+ RatisHelper.createRaftServerProperties(conf, properties);
return properties;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org