|
@@ -156,58 +156,19 @@ public final class XceiverServerRatis implements XceiverServerSpi {
|
|
|
final RaftProperties properties = new RaftProperties();
|
|
|
|
|
|
// Set rpc type
|
|
|
- final String rpcType = conf.get(
|
|
|
- OzoneConfigKeys.DFS_CONTAINER_RATIS_RPC_TYPE_KEY,
|
|
|
- OzoneConfigKeys.DFS_CONTAINER_RATIS_RPC_TYPE_DEFAULT);
|
|
|
- final RpcType rpc = SupportedRpcType.valueOfIgnoreCase(rpcType);
|
|
|
- RaftConfigKeys.Rpc.setType(properties, rpc);
|
|
|
+ final RpcType rpc = setRpcType(conf, properties);
|
|
|
|
|
|
// set raft segment size
|
|
|
- final int raftSegmentSize = (int)conf.getStorageSize(
|
|
|
- OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_SIZE_KEY,
|
|
|
- OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_SIZE_DEFAULT,
|
|
|
- StorageUnit.BYTES);
|
|
|
- RaftServerConfigKeys.Log.setSegmentSizeMax(properties,
|
|
|
- SizeInBytes.valueOf(raftSegmentSize));
|
|
|
+ setRaftSegmentSize(conf, properties);
|
|
|
|
|
|
// set raft segment pre-allocated size
|
|
|
- final int raftSegmentPreallocatedSize = (int) conf.getStorageSize(
|
|
|
- OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_PREALLOCATED_SIZE_KEY,
|
|
|
- OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_PREALLOCATED_SIZE_DEFAULT,
|
|
|
- StorageUnit.BYTES);
|
|
|
- int logAppenderQueueNumElements = conf.getInt(
|
|
|
- OzoneConfigKeys.DFS_CONTAINER_RATIS_LOG_APPENDER_QUEUE_NUM_ELEMENTS,
|
|
|
- OzoneConfigKeys
|
|
|
- .DFS_CONTAINER_RATIS_LOG_APPENDER_QUEUE_NUM_ELEMENTS_DEFAULT);
|
|
|
- final int logAppenderQueueByteLimit = (int) conf.getStorageSize(
|
|
|
- OzoneConfigKeys.DFS_CONTAINER_RATIS_LOG_APPENDER_QUEUE_BYTE_LIMIT,
|
|
|
- OzoneConfigKeys
|
|
|
- .DFS_CONTAINER_RATIS_LOG_APPENDER_QUEUE_BYTE_LIMIT_DEFAULT,
|
|
|
- StorageUnit.BYTES);
|
|
|
- RaftServerConfigKeys.Log.Appender
|
|
|
- .setBufferElementLimit(properties, logAppenderQueueNumElements);
|
|
|
- RaftServerConfigKeys.Log.Appender.setBufferByteLimit(properties,
|
|
|
- SizeInBytes.valueOf(logAppenderQueueByteLimit));
|
|
|
- RaftServerConfigKeys.Log.setPreallocatedSize(properties,
|
|
|
- SizeInBytes.valueOf(raftSegmentPreallocatedSize));
|
|
|
+ final int raftSegmentPreallocatedSize =
|
|
|
+ setRaftSegmentPreallocatedSize(conf, properties);
|
|
|
|
|
|
// Set max write buffer size, which is the scm chunk size
|
|
|
- final int maxChunkSize = OzoneConsts.OZONE_SCM_CHUNK_MAX_SIZE;
|
|
|
- RaftServerConfigKeys.Log.setWriteBufferSize(properties,
|
|
|
- SizeInBytes.valueOf(maxChunkSize));
|
|
|
-
|
|
|
- // Set the client requestTimeout
|
|
|
- TimeUnit timeUnit =
|
|
|
- OzoneConfigKeys.DFS_RATIS_CLIENT_REQUEST_TIMEOUT_DURATION_DEFAULT
|
|
|
- .getUnit();
|
|
|
- long duration = conf.getTimeDuration(
|
|
|
- OzoneConfigKeys.DFS_RATIS_CLIENT_REQUEST_TIMEOUT_DURATION_KEY,
|
|
|
- OzoneConfigKeys.DFS_RATIS_CLIENT_REQUEST_TIMEOUT_DURATION_DEFAULT
|
|
|
- .getDuration(), timeUnit);
|
|
|
- final TimeDuration clientRequestTimeout =
|
|
|
- TimeDuration.valueOf(duration, timeUnit);
|
|
|
- RaftClientConfigKeys.Rpc
|
|
|
- .setRequestTimeout(properties, clientRequestTimeout);
|
|
|
+ final int maxChunkSize = setMaxWriteBuffer(conf, properties);
|
|
|
+ TimeUnit timeUnit;
|
|
|
+ long duration;
|
|
|
|
|
|
// set the configs enable and set the stateMachineData sync timeout
|
|
|
RaftServerConfigKeys.Log.StateMachineData.setSync(properties, true);
|
|
@@ -224,66 +185,19 @@ public final class XceiverServerRatis implements XceiverServerSpi {
|
|
|
.setSyncTimeout(properties, dataSyncTimeout);
|
|
|
|
|
|
// Set the server Request timeout
|
|
|
- timeUnit = OzoneConfigKeys.DFS_RATIS_SERVER_REQUEST_TIMEOUT_DURATION_DEFAULT
|
|
|
- .getUnit();
|
|
|
- duration = conf.getTimeDuration(
|
|
|
- OzoneConfigKeys.DFS_RATIS_SERVER_REQUEST_TIMEOUT_DURATION_KEY,
|
|
|
- OzoneConfigKeys.DFS_RATIS_SERVER_REQUEST_TIMEOUT_DURATION_DEFAULT
|
|
|
- .getDuration(), timeUnit);
|
|
|
- final TimeDuration serverRequestTimeout =
|
|
|
- TimeDuration.valueOf(duration, timeUnit);
|
|
|
- RaftServerConfigKeys.Rpc
|
|
|
- .setRequestTimeout(properties, serverRequestTimeout);
|
|
|
+ setServerRequestTimeout(conf, properties);
|
|
|
|
|
|
// set timeout for a retry cache entry
|
|
|
- timeUnit =
|
|
|
- OzoneConfigKeys.DFS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_DEFAULT
|
|
|
- .getUnit();
|
|
|
- duration = conf.getTimeDuration(
|
|
|
- OzoneConfigKeys.DFS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_KEY,
|
|
|
- OzoneConfigKeys.DFS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_DEFAULT
|
|
|
- .getDuration(), timeUnit);
|
|
|
- final TimeDuration retryCacheTimeout =
|
|
|
- TimeDuration.valueOf(duration, timeUnit);
|
|
|
- RaftServerConfigKeys.RetryCache
|
|
|
- .setExpiryTime(properties, retryCacheTimeout);
|
|
|
+ setTimeoutForRetryCache(conf, properties);
|
|
|
|
|
|
// Set the ratis leader election timeout
|
|
|
- TimeUnit leaderElectionMinTimeoutUnit =
|
|
|
- OzoneConfigKeys.
|
|
|
- DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_DEFAULT
|
|
|
- .getUnit();
|
|
|
- duration = conf.getTimeDuration(
|
|
|
- OzoneConfigKeys.DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY,
|
|
|
- OzoneConfigKeys.
|
|
|
- DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_DEFAULT
|
|
|
- .getDuration(), leaderElectionMinTimeoutUnit);
|
|
|
- final TimeDuration leaderElectionMinTimeout =
|
|
|
- TimeDuration.valueOf(duration, leaderElectionMinTimeoutUnit);
|
|
|
- RaftServerConfigKeys.Rpc
|
|
|
- .setTimeoutMin(properties, leaderElectionMinTimeout);
|
|
|
- long leaderElectionMaxTimeout =
|
|
|
- leaderElectionMinTimeout.toLong(TimeUnit.MILLISECONDS) + 200;
|
|
|
- RaftServerConfigKeys.Rpc.setTimeoutMax(properties,
|
|
|
- TimeDuration.valueOf(leaderElectionMaxTimeout, TimeUnit.MILLISECONDS));
|
|
|
+ setRatisLeaderElectionTimeout(conf, properties);
|
|
|
|
|
|
// Set the maximum cache segments
|
|
|
RaftServerConfigKeys.Log.setMaxCachedSegmentNum(properties, 2);
|
|
|
|
|
|
// set the node failure timeout
|
|
|
- timeUnit = OzoneConfigKeys.DFS_RATIS_SERVER_FAILURE_DURATION_DEFAULT
|
|
|
- .getUnit();
|
|
|
- duration = conf.getTimeDuration(
|
|
|
- OzoneConfigKeys.DFS_RATIS_SERVER_FAILURE_DURATION_KEY,
|
|
|
- OzoneConfigKeys.DFS_RATIS_SERVER_FAILURE_DURATION_DEFAULT
|
|
|
- .getDuration(), timeUnit);
|
|
|
- final TimeDuration nodeFailureTimeout =
|
|
|
- TimeDuration.valueOf(duration, timeUnit);
|
|
|
- RaftServerConfigKeys.setLeaderElectionTimeout(properties,
|
|
|
- nodeFailureTimeout);
|
|
|
- RaftServerConfigKeys.Rpc.setSlownessTimeout(properties,
|
|
|
- nodeFailureTimeout);
|
|
|
- nodeFailureTimeoutMs = nodeFailureTimeout.toLong(TimeUnit.MILLISECONDS);
|
|
|
+ setNodeFailureTimeout(conf, properties);
|
|
|
|
|
|
// Set the ratis storage directory
|
|
|
String storageDir = HddsServerUtil.getOzoneDatanodeRatisDirectory(conf);
|
|
@@ -331,6 +245,143 @@ public final class XceiverServerRatis implements XceiverServerSpi {
|
|
|
return properties;
|
|
|
}
|
|
|
|
|
|
+ private void setNodeFailureTimeout(Configuration conf,
|
|
|
+ RaftProperties properties) {
|
|
|
+ TimeUnit timeUnit;
|
|
|
+ long duration;
|
|
|
+ timeUnit = OzoneConfigKeys.DFS_RATIS_SERVER_FAILURE_DURATION_DEFAULT
|
|
|
+ .getUnit();
|
|
|
+ duration = conf.getTimeDuration(
|
|
|
+ OzoneConfigKeys.DFS_RATIS_SERVER_FAILURE_DURATION_KEY,
|
|
|
+ OzoneConfigKeys.DFS_RATIS_SERVER_FAILURE_DURATION_DEFAULT
|
|
|
+ .getDuration(), timeUnit);
|
|
|
+ final TimeDuration nodeFailureTimeout =
|
|
|
+ TimeDuration.valueOf(duration, timeUnit);
|
|
|
+ RaftServerConfigKeys.setLeaderElectionTimeout(properties,
|
|
|
+ nodeFailureTimeout);
|
|
|
+ RaftServerConfigKeys.Rpc.setSlownessTimeout(properties,
|
|
|
+ nodeFailureTimeout);
|
|
|
+ nodeFailureTimeoutMs = nodeFailureTimeout.toLong(TimeUnit.MILLISECONDS);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setRatisLeaderElectionTimeout(Configuration conf,
|
|
|
+ RaftProperties properties) {
|
|
|
+ long duration;
|
|
|
+ TimeUnit leaderElectionMinTimeoutUnit =
|
|
|
+ OzoneConfigKeys.
|
|
|
+ DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_DEFAULT
|
|
|
+ .getUnit();
|
|
|
+ duration = conf.getTimeDuration(
|
|
|
+ OzoneConfigKeys.DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY,
|
|
|
+ OzoneConfigKeys.
|
|
|
+ DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_DEFAULT
|
|
|
+ .getDuration(), leaderElectionMinTimeoutUnit);
|
|
|
+ final TimeDuration leaderElectionMinTimeout =
|
|
|
+ TimeDuration.valueOf(duration, leaderElectionMinTimeoutUnit);
|
|
|
+ RaftServerConfigKeys.Rpc
|
|
|
+ .setTimeoutMin(properties, leaderElectionMinTimeout);
|
|
|
+ long leaderElectionMaxTimeout =
|
|
|
+ leaderElectionMinTimeout.toLong(TimeUnit.MILLISECONDS) + 200;
|
|
|
+ RaftServerConfigKeys.Rpc.setTimeoutMax(properties,
|
|
|
+ TimeDuration.valueOf(leaderElectionMaxTimeout, TimeUnit.MILLISECONDS));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setTimeoutForRetryCache(Configuration conf,
|
|
|
+ RaftProperties properties) {
|
|
|
+ TimeUnit timeUnit;
|
|
|
+ long duration;
|
|
|
+ timeUnit =
|
|
|
+ OzoneConfigKeys.DFS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_DEFAULT
|
|
|
+ .getUnit();
|
|
|
+ duration = conf.getTimeDuration(
|
|
|
+ OzoneConfigKeys.DFS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_KEY,
|
|
|
+ OzoneConfigKeys.DFS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_DEFAULT
|
|
|
+ .getDuration(), timeUnit);
|
|
|
+ final TimeDuration retryCacheTimeout =
|
|
|
+ TimeDuration.valueOf(duration, timeUnit);
|
|
|
+ RaftServerConfigKeys.RetryCache
|
|
|
+ .setExpiryTime(properties, retryCacheTimeout);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setServerRequestTimeout(Configuration conf,
|
|
|
+ RaftProperties properties) {
|
|
|
+ TimeUnit timeUnit;
|
|
|
+ long duration;
|
|
|
+ timeUnit = OzoneConfigKeys.DFS_RATIS_SERVER_REQUEST_TIMEOUT_DURATION_DEFAULT
|
|
|
+ .getUnit();
|
|
|
+ duration = conf.getTimeDuration(
|
|
|
+ OzoneConfigKeys.DFS_RATIS_SERVER_REQUEST_TIMEOUT_DURATION_KEY,
|
|
|
+ OzoneConfigKeys.DFS_RATIS_SERVER_REQUEST_TIMEOUT_DURATION_DEFAULT
|
|
|
+ .getDuration(), timeUnit);
|
|
|
+ final TimeDuration serverRequestTimeout =
|
|
|
+ TimeDuration.valueOf(duration, timeUnit);
|
|
|
+ RaftServerConfigKeys.Rpc
|
|
|
+ .setRequestTimeout(properties, serverRequestTimeout);
|
|
|
+ }
|
|
|
+
|
|
|
+ private int setMaxWriteBuffer(Configuration conf, RaftProperties properties) {
|
|
|
+ final int maxChunkSize = OzoneConsts.OZONE_SCM_CHUNK_MAX_SIZE;
|
|
|
+ RaftServerConfigKeys.Log.setWriteBufferSize(properties,
|
|
|
+ SizeInBytes.valueOf(maxChunkSize));
|
|
|
+
|
|
|
+ // Set the client requestTimeout
|
|
|
+ TimeUnit timeUnit =
|
|
|
+ OzoneConfigKeys.DFS_RATIS_CLIENT_REQUEST_TIMEOUT_DURATION_DEFAULT
|
|
|
+ .getUnit();
|
|
|
+ long duration = conf.getTimeDuration(
|
|
|
+ OzoneConfigKeys.DFS_RATIS_CLIENT_REQUEST_TIMEOUT_DURATION_KEY,
|
|
|
+ OzoneConfigKeys.DFS_RATIS_CLIENT_REQUEST_TIMEOUT_DURATION_DEFAULT
|
|
|
+ .getDuration(), timeUnit);
|
|
|
+ final TimeDuration clientRequestTimeout =
|
|
|
+ TimeDuration.valueOf(duration, timeUnit);
|
|
|
+ RaftClientConfigKeys.Rpc
|
|
|
+ .setRequestTimeout(properties, clientRequestTimeout);
|
|
|
+ return maxChunkSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int setRaftSegmentPreallocatedSize(Configuration conf,
|
|
|
+ RaftProperties properties) {
|
|
|
+ final int raftSegmentPreallocatedSize = (int) conf.getStorageSize(
|
|
|
+ OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_PREALLOCATED_SIZE_KEY,
|
|
|
+ OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_PREALLOCATED_SIZE_DEFAULT,
|
|
|
+ StorageUnit.BYTES);
|
|
|
+ int logAppenderQueueNumElements = conf.getInt(
|
|
|
+ OzoneConfigKeys.DFS_CONTAINER_RATIS_LOG_APPENDER_QUEUE_NUM_ELEMENTS,
|
|
|
+ OzoneConfigKeys
|
|
|
+ .DFS_CONTAINER_RATIS_LOG_APPENDER_QUEUE_NUM_ELEMENTS_DEFAULT);
|
|
|
+ final int logAppenderQueueByteLimit = (int) conf.getStorageSize(
|
|
|
+ OzoneConfigKeys.DFS_CONTAINER_RATIS_LOG_APPENDER_QUEUE_BYTE_LIMIT,
|
|
|
+ OzoneConfigKeys
|
|
|
+ .DFS_CONTAINER_RATIS_LOG_APPENDER_QUEUE_BYTE_LIMIT_DEFAULT,
|
|
|
+ StorageUnit.BYTES);
|
|
|
+ RaftServerConfigKeys.Log.Appender
|
|
|
+ .setBufferElementLimit(properties, logAppenderQueueNumElements);
|
|
|
+ RaftServerConfigKeys.Log.Appender.setBufferByteLimit(properties,
|
|
|
+ SizeInBytes.valueOf(logAppenderQueueByteLimit));
|
|
|
+ RaftServerConfigKeys.Log.setPreallocatedSize(properties,
|
|
|
+ SizeInBytes.valueOf(raftSegmentPreallocatedSize));
|
|
|
+ return raftSegmentPreallocatedSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setRaftSegmentSize(Configuration conf,
|
|
|
+ RaftProperties properties) {
|
|
|
+ final int raftSegmentSize = (int)conf.getStorageSize(
|
|
|
+ OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_SIZE_KEY,
|
|
|
+ OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_SIZE_DEFAULT,
|
|
|
+ StorageUnit.BYTES);
|
|
|
+ RaftServerConfigKeys.Log.setSegmentSizeMax(properties,
|
|
|
+ SizeInBytes.valueOf(raftSegmentSize));
|
|
|
+ }
|
|
|
+
|
|
|
+ private RpcType setRpcType(Configuration conf, RaftProperties properties) {
|
|
|
+ final String rpcType = conf.get(
|
|
|
+ OzoneConfigKeys.DFS_CONTAINER_RATIS_RPC_TYPE_KEY,
|
|
|
+ OzoneConfigKeys.DFS_CONTAINER_RATIS_RPC_TYPE_DEFAULT);
|
|
|
+ final RpcType rpc = SupportedRpcType.valueOfIgnoreCase(rpcType);
|
|
|
+ RaftConfigKeys.Rpc.setType(properties, rpc);
|
|
|
+ return rpc;
|
|
|
+ }
|
|
|
+
|
|
|
public static XceiverServerRatis newXceiverServerRatis(
|
|
|
DatanodeDetails datanodeDetails, Configuration ozoneConf,
|
|
|
ContainerDispatcher dispatcher, StateContext context) throws IOException {
|