Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable Kestrel batch_size #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 11 additions & 2 deletions src/jvm/backtype/storm/spout/KestrelThriftSpout.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class KestrelThriftSpout extends BaseRichSpout {
private String _queueName = null;
private SpoutOutputCollector _collector;
private Scheme _scheme;
private int _batchSize;

private List<KestrelClientInfo> _kestrels;
private int _emitIndex;
Expand Down Expand Up @@ -93,14 +94,22 @@ public void closeClient() {
}
}

public KestrelThriftSpout(List<String> hosts, int port, String queueName, Scheme scheme) {
public KestrelThriftSpout(List<String> hosts, int port, String queueName, Scheme scheme, int batchSize) {
if(hosts.isEmpty()) {
throw new IllegalArgumentException("Must configure at least one host");
}
if(batchSize < 1) {
throw new IllegalArgumentException("Batch size must be >= 1");
}
_port = port;
_hosts = hosts;
_queueName = queueName;
_scheme = scheme;
_batchSize = batchSize;
}

public KestrelThriftSpout(List<String> hosts, int port, String queueName, Scheme scheme) {
this(hosts, port, queueName, scheme, BATCH_SIZE);
}

public KestrelThriftSpout(String hostname, int port, String queueName, Scheme scheme) {
Expand Down Expand Up @@ -160,7 +169,7 @@ public boolean bufferKestrelGet(int index) {
if(now > info.blacklistTillTimeMs) {
List<Item> items = null;
try {
items = info.getValidClient().get(_queueName, BATCH_SIZE, 0, _messageTimeoutMillis);
items = info.getValidClient().get(_queueName, _batchSize, 0, _messageTimeoutMillis);
} catch(TException e) {
blacklist(info, e);
return false;
Expand Down