szetszwo commented on code in PR #1516:
URL: https://github.com/apache/ratis/pull/1516#discussion_r3576240327


##########
ratis-server-api/src/main/java/org/apache/ratis/server/DataStreamReadResolver.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.ratis.server;
+
+import org.apache.ratis.conf.Parameters;
+import org.apache.ratis.protocol.RaftClientRequest;
+import org.apache.ratis.statemachine.StateMachine;
+
+import java.io.IOException;
+
+/** Resolves read-only data stream requests independently of a Raft division. 
*/
+@FunctionalInterface
+public interface DataStreamReadResolver {
+  String PARAMETER_KEY = DataStreamReadResolver.class.getName();
+
+  /** Set the resolver in the given server parameters. */
+  static void set(Parameters parameters, DataStreamReadResolver resolver) {
+    parameters.put(PARAMETER_KEY, resolver, DataStreamReadResolver.class);
+  }
+
+  /** Get the resolver from the given server parameters, if configured. */
+  static DataStreamReadResolver get(Parameters parameters) {
+    return parameters != null
+        ? parameters.get(PARAMETER_KEY, DataStreamReadResolver.class)
+        : null;
+  }

Review Comment:
   Let'e move the conf key and methods to RaftServerConfigKeys.DataStream:
   ```java
   +++ 
b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
   @@ -17,7 +17,9 @@
     */
    package org.apache.ratis.server;
    
   +import org.apache.ratis.conf.Parameters;
    import org.apache.ratis.conf.RaftProperties;
   +import org.apache.ratis.server.api.DataStreamServerApi;
    import org.apache.ratis.util.JavaUtils;
    import org.apache.ratis.util.SizeInBytes;
    import org.apache.ratis.util.TimeDuration;
   @@ -847,6 +849,15 @@ public interface RaftServerConfigKeys {
        static void setClientPoolSize(RaftProperties properties, int num) {
          setInt(properties::setInt, CLIENT_POOL_SIZE_KEY, num);
        }
   +
   +    String SERVER_API_RESOLVER_PARAMETER = PREFIX + "-server-api-resolver";
   +    Class<DataStreamServerApi.Resolver> SERVER_API_RESOLVER_CLASS = 
DataStreamServerApi.Resolver.class;
   +    static DataStreamServerApi.Resolver serverApiResolver(Parameters 
parameters) {
   +      return parameters != null ? 
parameters.get(SERVER_API_RESOLVER_PARAMETER, SERVER_API_RESOLVER_CLASS): null;
   +    }
   +    static void setServerApiResolver(Parameters parameters, 
DataStreamServerApi.Resolver resolver) {
   +      parameters.put(SERVER_API_RESOLVER_PARAMETER, resolver, 
SERVER_API_RESOLVER_CLASS);
   +    }
      }
   ```



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

Reply via email to