Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion client/src/main/java/io/hstream/HStreamClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,20 @@ static HStreamClientBuilder builder() {
/** @return the {@link QueryerBuilder}. */
QueryerBuilder newQueryer();

/** @param stream the name of stream. */
/**
* create a new stream with 3 replicas.
*
* @param stream the name of stream.
*/
void createStream(String stream);

/**
* create a new stream.
*
* @param stream the name of stream.
*/
void createStream(String stream, short replicationFactor);

/**
* Delete specified stream with streamName.
*
Expand Down
8 changes: 7 additions & 1 deletion client/src/main/java/io/hstream/impl/HStreamClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class HStreamClientImpl implements HStreamClient {
private final HStreamApiGrpc.HStreamApiStub stub;
private final HStreamApiGrpc.HStreamApiBlockingStub blockingStub;

private static final short DEFAULT_STREAM_REPLICATOR = 3;

public HStreamClientImpl(String serviceUrl) {
ManagedChannel channel = ManagedChannelBuilder.forTarget(serviceUrl).usePlaintext().build();
this.managedChannel = channel;
Expand All @@ -47,8 +49,12 @@ public QueryerBuilder newQueryer() {

@Override
public void createStream(String streamName) {
Stream stream = new Stream(streamName, 3);
createStream(streamName, DEFAULT_STREAM_REPLICATOR);
}

@Override
public void createStream(String streamName, short replicationFactor) {
Stream stream = new Stream(streamName, replicationFactor);
blockingStub.createStream(GrpcUtils.streamToGrpc(stream));
}

Expand Down