This is an automated email from the ASF dual-hosted git repository.

szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 349c365  RATIS-1011 - Interfaces for client, server for netty 
streaming (#164)  Contributed by Ansh Khanna
349c365 is described below

commit 349c365e81d76b210df7a97704217178e3f7f826
Author: anshkhannasbu <[email protected]>
AuthorDate: Thu Aug 6 12:37:12 2020 -0400

    RATIS-1011 - Interfaces for client, server for netty streaming (#164)  
Contributed by Ansh Khanna
---
 .../org/apache/ratis/client/DataStreamClient.java  | 93 ++++++++++++++++++++++
 .../ratis/client/DataStreamClientFactory.java      | 40 ++++++++++
 .../apache/ratis/client/DataStreamClientRpc.java   | 38 +++++++++
 .../org/apache/ratis/client/api/DataStreamApi.java | 33 ++++++++
 .../apache/ratis/client/api/DataStreamOutput.java  | 38 +++++++++
 .../ratis/client/impl/DataStreamClientImpl.java    | 51 ++++++++++++
 .../main/java/org/apache/ratis/RaftConfigKeys.java | 17 ++++
 .../apache/ratis/datastream/DataStreamFactory.java | 23 ++++++
 .../ratis/datastream/SupportedDataStreamType.java  | 48 +++++++++++
 .../apache/ratis/protocol/DataStreamMessage.java   | 27 +++++++
 .../org/apache/ratis/protocol/DataStreamReply.java | 25 ++++++
 .../apache/ratis/protocol/DataStreamRequest.java   | 22 +++++
 .../apache/ratis/netty/NettyDataStreamFactory.java | 47 +++++++++++
 .../ratis/server/DataStreamServerFactory.java      | 27 +++++++
 .../apache/ratis/server/DataStreamServerRpc.java   | 25 ++++++
 15 files changed, 554 insertions(+)

diff --git 
a/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClient.java 
b/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClient.java
new file mode 100644
index 0000000..8e3f7ae
--- /dev/null
+++ b/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClient.java
@@ -0,0 +1,93 @@
+/*
+ * 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.client;
+
+import org.apache.ratis.RaftConfigKeys;
+import org.apache.ratis.client.api.DataStreamApi;
+import org.apache.ratis.client.impl.DataStreamClientImpl;
+import org.apache.ratis.conf.Parameters;
+import org.apache.ratis.conf.RaftProperties;
+import org.apache.ratis.datastream.SupportedDataStreamType;
+import org.apache.ratis.protocol.ClientId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A client interface that sends request to the streaming pipeline.
+ * Associated with it will be a Netty Client.
+ */
+public interface DataStreamClient {
+
+  Logger LOG = LoggerFactory.getLogger(DataStreamClient.class);
+
+  /** Return Client id. */
+  ClientId getId();
+
+  /** Return Streamer Api instance. */
+  DataStreamApi getDataStreamApi();
+
+  /**
+   * send to server via streaming.
+   * Return a completable future.
+   */
+
+  /** To build {@link DataStreamClient} objects */
+  class Builder {
+    private ClientId clientId;
+    private DataStreamClientRpc dataStreamClientRpc;
+    private RaftProperties properties;
+    private Parameters parameters;
+
+    private Builder() {}
+
+    public DataStreamClientImpl build(){
+      if (clientId == null) {
+        clientId = ClientId.randomId();
+      }
+      if (properties != null) {
+        if (dataStreamClientRpc == null) {
+          final SupportedDataStreamType type = 
RaftConfigKeys.DataStream.type(properties, LOG::info);
+          dataStreamClientRpc = 
DataStreamClientFactory.cast(type.newFactory(parameters))
+              .newDataStreamClientRpc(clientId, properties);
+        }
+      }
+      return new DataStreamClientImpl(clientId, properties, 
dataStreamClientRpc);
+    }
+
+    public Builder setClientId(ClientId clientId) {
+      this.clientId = clientId;
+      return this;
+    }
+
+    public Builder setParameters(Parameters parameters) {
+      this.parameters = parameters;
+      return this;
+    }
+
+    public Builder setDataStreamClientRpc(DataStreamClientRpc 
dataStreamClientRpc){
+      this.dataStreamClientRpc = dataStreamClientRpc;
+      return this;
+    }
+
+    public Builder setProperties(RaftProperties properties) {
+      this.properties = properties;
+      return this;
+    }
+  }
+
+}
diff --git 
a/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClientFactory.java
 
b/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClientFactory.java
new file mode 100644
index 0000000..f5b00e0
--- /dev/null
+++ 
b/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClientFactory.java
@@ -0,0 +1,40 @@
+/*
+ * 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.client;
+
+import org.apache.ratis.conf.RaftProperties;
+import org.apache.ratis.datastream.DataStreamFactory;
+import org.apache.ratis.protocol.ClientId;
+
+/**
+ * A factory to create streaming client.
+ */
+public interface DataStreamClientFactory extends DataStreamFactory {
+
+  static DataStreamClientFactory cast(DataStreamFactory dataStreamFactory) {
+    if (dataStreamFactory instanceof DataStreamClientFactory) {
+      return (DataStreamClientFactory) dataStreamFactory;
+    }
+    throw new ClassCastException("Cannot cast " + dataStreamFactory.getClass()
+        + " to " + ClientFactory.class
+        + "; stream type is " + dataStreamFactory.getDataStreamType());
+  }
+
+  DataStreamClientRpc newDataStreamClientRpc(ClientId clientId, RaftProperties 
properties);
+}
diff --git 
a/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClientRpc.java 
b/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClientRpc.java
new file mode 100644
index 0000000..7021de9
--- /dev/null
+++ 
b/ratis-client/src/main/java/org/apache/ratis/client/DataStreamClientRpc.java
@@ -0,0 +1,38 @@
+/*
+ * 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.client;
+
+import org.apache.ratis.protocol.DataStreamReply;
+import org.apache.ratis.protocol.DataStreamRequest;
+import org.apache.ratis.util.JavaUtils;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * An api interface for to stream from client to server.
+ */
+public interface DataStreamClientRpc {
+
+  /** Async call to send a request. */
+  default CompletableFuture<DataStreamReply> streamAsync(DataStreamRequest 
request) {
+    throw new UnsupportedOperationException(getClass() + " does not support "
+        + JavaUtils.getCurrentStackTraceElement().getMethodName());
+  }
+
+}
diff --git 
a/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamApi.java 
b/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamApi.java
new file mode 100644
index 0000000..03fd4b3
--- /dev/null
+++ b/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamApi.java
@@ -0,0 +1,33 @@
+/*
+ * 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.client.api;
+
+/**
+ * An interface for streaming data.
+ * Associated with it's implementation will be a client.
+ */
+
+public interface DataStreamApi {
+
+  /**
+   * Create a new stream for a new streamToRatis invocation
+   * allows multiple stream from a single client.
+   */
+  DataStreamOutput stream();
+
+}
diff --git 
a/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamOutput.java 
b/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamOutput.java
new file mode 100644
index 0000000..2c55be8
--- /dev/null
+++ 
b/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamOutput.java
@@ -0,0 +1,38 @@
+/*
+ * 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.client.api;
+
+import org.apache.ratis.protocol.DataStreamReply;
+import java.nio.ByteBuffer;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+
+public interface DataStreamOutput extends AutoCloseable {
+  CompletableFuture<DataStreamReply> streamAsync(ByteBuffer buf);
+
+  CompletableFuture<DataStreamReply> closeAsync();
+
+  default void close() throws Exception {
+    try {
+      closeAsync().get();
+    } catch (ExecutionException e) {
+      final Throwable cause = e.getCause();
+      throw cause instanceof Exception? (Exception)cause: e;
+    }
+  }
+}
diff --git 
a/ratis-client/src/main/java/org/apache/ratis/client/impl/DataStreamClientImpl.java
 
b/ratis-client/src/main/java/org/apache/ratis/client/impl/DataStreamClientImpl.java
new file mode 100644
index 0000000..fff816c
--- /dev/null
+++ 
b/ratis-client/src/main/java/org/apache/ratis/client/impl/DataStreamClientImpl.java
@@ -0,0 +1,51 @@
+/*
+ * 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.client.impl;
+
+import org.apache.ratis.client.DataStreamClientRpc;
+import org.apache.ratis.client.DataStreamClient;
+import org.apache.ratis.client.api.DataStreamApi;
+import org.apache.ratis.conf.RaftProperties;
+import org.apache.ratis.protocol.ClientId;
+
+public class DataStreamClientImpl implements DataStreamClient {
+
+  private final ClientId clientId;
+  private final RaftProperties properties;
+  private final DataStreamClientRpc dataStreamClientRpc;
+  private final DataStreamApi dataStreamApi = null; //TODO need an impl
+
+  public DataStreamClientImpl(ClientId clientId,
+                              RaftProperties properties,
+                              DataStreamClientRpc dataStreamClientRpc){
+    this.clientId = clientId;
+    this.properties = properties;
+    this.dataStreamClientRpc = dataStreamClientRpc;
+  }
+
+  @Override
+  public ClientId getId() {
+    return clientId;
+  }
+
+  @Override
+  public DataStreamApi getDataStreamApi(){
+    return dataStreamApi;
+  }
+
+}
diff --git a/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java 
b/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java
index a12de55..ede45cb 100644
--- a/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java
+++ b/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java
@@ -22,6 +22,7 @@ import static org.apache.ratis.conf.ConfUtils.printAll;
 import static org.apache.ratis.conf.ConfUtils.set;
 
 import org.apache.ratis.conf.RaftProperties;
+import org.apache.ratis.datastream.SupportedDataStreamType;
 import org.apache.ratis.rpc.RpcType;
 import org.apache.ratis.rpc.SupportedRpcType;
 
@@ -46,6 +47,22 @@ public interface RaftConfigKeys {
     }
   }
 
+  interface DataStream {
+    String PREFIX = RaftConfigKeys.PREFIX + ".datastream";
+
+    String TYPE_KEY = PREFIX + ".type";
+    String TYPE_DEFAULT = SupportedDataStreamType.NETTY.name();
+
+    static SupportedDataStreamType type(RaftProperties properties, 
Consumer<String> logger) {
+      final String t = get(properties::get, TYPE_KEY, TYPE_DEFAULT, logger);
+      return SupportedDataStreamType.valueOfIgnoreCase(t);
+    }
+
+    static void setType(RaftProperties properties, SupportedDataStreamType 
type) {
+      set(properties::set, TYPE_KEY, type.name());
+    }
+  }
+
   static void main(String[] args) {
     printAll(RaftConfigKeys.class);
   }
diff --git 
a/ratis-common/src/main/java/org/apache/ratis/datastream/DataStreamFactory.java 
b/ratis-common/src/main/java/org/apache/ratis/datastream/DataStreamFactory.java
new file mode 100644
index 0000000..6d88e7c
--- /dev/null
+++ 
b/ratis-common/src/main/java/org/apache/ratis/datastream/DataStreamFactory.java
@@ -0,0 +1,23 @@
+/*
+ * 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.datastream;
+
+public interface DataStreamFactory {
+  SupportedDataStreamType getDataStreamType();
+}
diff --git 
a/ratis-common/src/main/java/org/apache/ratis/datastream/SupportedDataStreamType.java
 
b/ratis-common/src/main/java/org/apache/ratis/datastream/SupportedDataStreamType.java
new file mode 100644
index 0000000..01d5f89
--- /dev/null
+++ 
b/ratis-common/src/main/java/org/apache/ratis/datastream/SupportedDataStreamType.java
@@ -0,0 +1,48 @@
+/*
+ * 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.datastream;
+
+import org.apache.ratis.conf.Parameters;
+import org.apache.ratis.util.ReflectionUtils;
+
+public enum SupportedDataStreamType implements DataStreamFactory {
+  NETTY("org.apache.ratis.netty.NettyDataStreamFactory");
+
+  private final String factoryClassName;
+
+  private static final Class<?>[] ARG_CLASSES = {Parameters.class};
+
+  public static SupportedDataStreamType valueOfIgnoreCase(String s) {
+    return valueOf(s.toUpperCase());
+  }
+
+  SupportedDataStreamType(String factoryClassName) {
+    this.factoryClassName = factoryClassName;
+  }
+
+  @Override
+  public SupportedDataStreamType getDataStreamType() {
+    return valueOf(this.factoryClassName.toUpperCase());
+  }
+
+  public DataStreamFactory newFactory(Parameters parameters) {
+    final Class<? extends DataStreamFactory> clazz = ReflectionUtils.getClass(
+        factoryClassName, DataStreamFactory.class);
+    return ReflectionUtils.newInstance(clazz, ARG_CLASSES, parameters);
+  }
+}
diff --git 
a/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamMessage.java 
b/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamMessage.java
new file mode 100644
index 0000000..eae8137
--- /dev/null
+++ 
b/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamMessage.java
@@ -0,0 +1,27 @@
+/*
+ * 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.protocol;
+
+public interface DataStreamMessage extends RaftRpcMessage {
+  long getStreamId();
+
+  long getDataOffset();
+
+  long getDataLength();
+}
\ No newline at end of file
diff --git 
a/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamReply.java 
b/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamReply.java
new file mode 100644
index 0000000..856eed1
--- /dev/null
+++ b/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamReply.java
@@ -0,0 +1,25 @@
+/*
+ * 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.protocol;
+
+import java.nio.ByteBuffer;
+
+public interface DataStreamReply extends DataStreamMessage {
+  ByteBuffer getResponse();
+}
\ No newline at end of file
diff --git 
a/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamRequest.java 
b/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamRequest.java
new file mode 100644
index 0000000..b2431d6
--- /dev/null
+++ 
b/ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamRequest.java
@@ -0,0 +1,22 @@
+/*
+ * 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.protocol;
+
+public interface DataStreamRequest extends DataStreamMessage {
+}
diff --git 
a/ratis-netty/src/main/java/org/apache/ratis/netty/NettyDataStreamFactory.java 
b/ratis-netty/src/main/java/org/apache/ratis/netty/NettyDataStreamFactory.java
new file mode 100644
index 0000000..66c360a
--- /dev/null
+++ 
b/ratis-netty/src/main/java/org/apache/ratis/netty/NettyDataStreamFactory.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.netty;
+
+import org.apache.ratis.client.DataStreamClientRpc;
+import org.apache.ratis.client.DataStreamClientFactory;
+import org.apache.ratis.conf.Parameters;
+import org.apache.ratis.conf.RaftProperties;
+import org.apache.ratis.datastream.SupportedDataStreamType;
+import org.apache.ratis.protocol.ClientId;
+import org.apache.ratis.server.RaftServer;
+import org.apache.ratis.server.DataStreamServerRpc;
+import org.apache.ratis.server.DataStreamServerFactory;
+
+public class NettyDataStreamFactory implements DataStreamServerFactory, 
DataStreamClientFactory {
+  public NettyDataStreamFactory(Parameters parameters){}
+
+  @Override
+  public SupportedDataStreamType getDataStreamType() {
+    return SupportedDataStreamType.NETTY;
+  }
+
+  @Override
+  public DataStreamClientRpc newDataStreamClientRpc(ClientId clientId, 
RaftProperties properties) {
+    return null;
+  }
+
+  @Override
+  public DataStreamServerRpc newDataStreamServerRpc(RaftServer server) {
+    return null;
+  }
+}
diff --git 
a/ratis-server/src/main/java/org/apache/ratis/server/DataStreamServerFactory.java
 
b/ratis-server/src/main/java/org/apache/ratis/server/DataStreamServerFactory.java
new file mode 100644
index 0000000..f0c3bd9
--- /dev/null
+++ 
b/ratis-server/src/main/java/org/apache/ratis/server/DataStreamServerFactory.java
@@ -0,0 +1,27 @@
+/*
+ * 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.datastream.DataStreamFactory;
+
+public interface DataStreamServerFactory extends DataStreamFactory {
+  /**
+   * Server implementation for streaming in Raft group
+   */
+  DataStreamServerRpc newDataStreamServerRpc(RaftServer server);
+}
diff --git 
a/ratis-server/src/main/java/org/apache/ratis/server/DataStreamServerRpc.java 
b/ratis-server/src/main/java/org/apache/ratis/server/DataStreamServerRpc.java
new file mode 100644
index 0000000..c5a074b
--- /dev/null
+++ 
b/ratis-server/src/main/java/org/apache/ratis/server/DataStreamServerRpc.java
@@ -0,0 +1,25 @@
+/*
+ * 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;
+
+/**
+ * A server interface handling incoming streams
+ * Relays those streams to other servers after persisting
+ */
+public interface DataStreamServerRpc {
+}

Reply via email to