Skip to content

Commit 3a82119

Browse files
authored
add createStream method with replicationFactor parameter (#35)
1 parent aed83d5 commit 3a82119

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

client/src/main/java/io/hstream/HStreamClient.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,20 @@ static HStreamClientBuilder builder() {
2020
/** @return the {@link QueryerBuilder}. */
2121
QueryerBuilder newQueryer();
2222

23-
/** @param stream the name of stream. */
23+
/**
24+
* create a new stream with 3 replicas.
25+
*
26+
* @param stream the name of stream.
27+
*/
2428
void createStream(String stream);
2529

30+
/**
31+
* create a new stream.
32+
*
33+
* @param stream the name of stream.
34+
*/
35+
void createStream(String stream, short replicationFactor);
36+
2637
/**
2738
* Delete specified stream with streamName.
2839
*

client/src/main/java/io/hstream/impl/HStreamClientImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class HStreamClientImpl implements HStreamClient {
2323
private final HStreamApiGrpc.HStreamApiStub stub;
2424
private final HStreamApiGrpc.HStreamApiBlockingStub blockingStub;
2525

26+
private static final short DEFAULT_STREAM_REPLICATOR = 3;
27+
2628
public HStreamClientImpl(String serviceUrl) {
2729
ManagedChannel channel = ManagedChannelBuilder.forTarget(serviceUrl).usePlaintext().build();
2830
this.managedChannel = channel;
@@ -47,8 +49,12 @@ public QueryerBuilder newQueryer() {
4749

4850
@Override
4951
public void createStream(String streamName) {
50-
Stream stream = new Stream(streamName, 3);
52+
createStream(streamName, DEFAULT_STREAM_REPLICATOR);
53+
}
5154

55+
@Override
56+
public void createStream(String streamName, short replicationFactor) {
57+
Stream stream = new Stream(streamName, replicationFactor);
5258
blockingStub.createStream(GrpcUtils.streamToGrpc(stream));
5359
}
5460

0 commit comments

Comments
 (0)