Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,12 @@ public String brokerPath() {
* @param partition
* @return
*/
private int getLeaderFor(String topic, long partition) {
public int getLeaderFor(String topic, long partition) {
try {
String topicBrokersPath = partitionPath(topic);
byte[] hostPortData = _curator.getData().forPath(topicBrokersPath + "/" + partition + "/state");
Map<Object, Object> value = (Map<Object, Object>) JSONValue.parse(new String(hostPortData, "UTF-8"));
Integer leader = ((Number) value.get("leader")).intValue();
if (leader == -1) {
throw new RuntimeException("No leader found for partition " + partition);
}
return leader;
} catch (RuntimeException e) {
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public void refresh() {
for (Partition id : newPartitions) {
PartitionManager man = new PartitionManager(_connections, _topologyInstanceId, _state, _stormConf, _spoutConfig, id);
_managers.put(id, man);
if(_reader.getLeaderFor(id.topic, id.partition) != -1) {
_managers.put(id, man);
}else {
LOG.warn("No leader found for partition " + id.topic + " : " + id.partition);
}
}

} catch (Exception e) {
Expand Down