Skip to content

Commit

Permalink
retry consumer id with host address
Browse files Browse the repository at this point in the history
  • Loading branch information
adyliu committed Dec 9, 2013
1 parent 1d1b81d commit 6c80939
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,18 @@ private String generateConsumerId() {
System.currentTimeMillis(),//
Long.toHexString(uuid.getMostSignificantBits()).substring(0, 8));
} catch (UnknownHostException e) {
throw new IllegalArgumentException(
"can not generate consume id by auto, set the 'consumerid' parameter to fix this");
try {
return format("%s-%d-%s", InetAddress.getLocalHost().getHostAddress(), //
System.currentTimeMillis(),//
Long.toHexString(uuid.getMostSignificantBits()).substring(0, 8));
} catch (UnknownHostException ex) {
throw new IllegalArgumentException(
"can not generate consume id by auto, set the 'consumerid' parameter to fix this");
}
}
}


public void commitOffsets() {
if (zkClient == null) {
logger.error("zk client is null. Cannot commit offsets");
Expand Down Expand Up @@ -673,7 +680,6 @@ private long earliestOrLatestOffset(String topic, int brokerId, int partitionId,
simpleConsumer = new SimpleConsumer(broker.host, broker.port, config.getSocketTimeoutMs(),
config.getSocketBufferSize());
long[] offsets = simpleConsumer.getOffsetsBefore(topic, partitionId, earliestOrLatest, 1);
//FIXME: what's this!!!
if (offsets.length > 0) {
producedOffset = offsets[0];
}
Expand Down

0 comments on commit 6c80939

Please sign in to comment.