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

Upgrade to Kafka 0.11.0.3 #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 9 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<spring.boot.version>1.3.6.RELEASE</spring.boot.version>
<additionalparam>-Xdoclint:none</additionalparam>
<curator.version>2.10.0</curator.version>
<kafka.version>0.11.0.3</kafka.version>
<kafka.scala.version>2.11</kafka.scala.version>

<!-- name of parameter changed in latest mvn javadoc plugin version-->
<additionalOptions>-Xdoclint:none</additionalOptions>
Expand Down Expand Up @@ -60,18 +62,21 @@
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.9.2</artifactId>
<version>0.8.2.2</version>
<artifactId>kafka_${kafka.scala.version}</artifactId>
<version>${kafka.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
<version>1.1.3.RELEASE</version>
</dependency>

<!-- Spring Boot -->
Expand Down Expand Up @@ -123,7 +128,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -137,13 +141,11 @@
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.0-groovy-2.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -152,13 +154,6 @@
<version>0.7.1</version>
<scope>test</scope>
</dependency>
<!-- Right now only needed by integration tests -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.8.2.2</version>
<scope>test</scope>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
import com.homeadvisor.kafdrop.model.*;
import com.homeadvisor.kafdrop.util.BrokerChannel;
import com.homeadvisor.kafdrop.util.Version;
import kafka.api.ConsumerMetadataRequest;
import kafka.api.GroupCoordinatorRequest;
import kafka.api.PartitionOffsetRequestInfo;
import kafka.cluster.Broker;
import kafka.cluster.BrokerEndPoint;
import kafka.common.ErrorMapping;
import kafka.common.TopicAndPartition;
import kafka.javaapi.*;
import kafka.network.BlockingChannel;
import kafka.server.ConfigType;
import kafka.utils.ZKGroupDirs;
import kafka.utils.ZKGroupTopicDirs;
import kafka.utils.ZkUtils;
Expand Down Expand Up @@ -128,7 +129,7 @@ public void start() throws Exception
});
brokerPathCache.start(StartMode.POST_INITIALIZED_EVENT);

topicConfigPathCache = new PathChildrenCache(curatorFramework, ZkUtils.TopicConfigPath(), true);
topicConfigPathCache = new PathChildrenCache(curatorFramework, ZkUtils.getEntityConfigPath(ConfigType.Topic()), true);
topicConfigPathCache.getListenable().addListener((f, e) -> {
if (e.getType() == PathChildrenCacheEvent.Type.INITIALIZED)
{
Expand Down Expand Up @@ -392,7 +393,7 @@ public TopicVO parseZkTopic(ChildData input)
objectMapper.reader(TopicRegistrationVO.class).readValue(input.getData());

topic.setConfig(
Optional.ofNullable(topicConfigPathCache.getCurrentData(ZkUtils.TopicConfigPath() + "/" + topic.getName()))
Optional.ofNullable(topicConfigPathCache.getCurrentData(ZkUtils.getEntityConfigPath(ConfigType.Topic()) + "/" + topic.getName()))
.map(this::readTopicConfig)
.orElse(Collections.emptyMap()));

Expand Down Expand Up @@ -437,7 +438,7 @@ private Map<String, TopicVO> getTopicMetadata(BlockingChannel channel, String...

channel.send(request);
final kafka.api.TopicMetadataResponse underlyingResponse =
kafka.api.TopicMetadataResponse.readFrom(channel.receive().buffer());
kafka.api.TopicMetadataResponse.readFrom(channel.receive().payload());

LOG.debug("Received topic metadata response: {}", underlyingResponse);

Expand All @@ -453,7 +454,7 @@ private TopicVO processTopicMetadata(TopicMetadata tmd)
TopicVO topic = new TopicVO(tmd.topic());

topic.setConfig(
Optional.ofNullable(topicConfigPathCache.getCurrentData(ZkUtils.TopicConfigPath() + "/" + topic.getName()))
Optional.ofNullable(topicConfigPathCache.getCurrentData(ZkUtils.getEntityConfigPath(ConfigType.Topic()) + "/" + topic.getName()))
.map(this::readTopicConfig)
.orElse(Collections.emptyMap()));

Expand Down Expand Up @@ -482,7 +483,7 @@ private TopicPartitionVO parsePartitionMetadata(String topic, PartitionMetadata

private List<Integer> getIsr(String topic, PartitionMetadata pmd)
{
return pmd.isr().stream().map(Broker::id).collect(Collectors.toList());
return pmd.isr().stream().map(BrokerEndPoint::id).collect(Collectors.toList());
}

private Map<String, Object> readTopicConfig(ChildData d)
Expand Down Expand Up @@ -741,14 +742,14 @@ private Map<Integer, Long> getConsumerOffsets(BlockingChannel channel,
channel.send(request.underlying());

final kafka.api.OffsetFetchResponse underlyingResponse =
kafka.api.OffsetFetchResponse.readFrom(channel.receive().buffer());
kafka.api.OffsetFetchResponse.readFrom(channel.receive().payload());

LOG.debug("Received consumer offset response: {}", underlyingResponse);

OffsetFetchResponse response = new OffsetFetchResponse(underlyingResponse);

return response.offsets().entrySet().stream()
.filter(entry -> entry.getValue().error() == ErrorMapping.NoError())
.filter(entry -> entry.getValue().error().code() == ErrorMapping.NoError())
.collect(Collectors.toMap(entry -> entry.getKey().partition(), entry -> entry.getValue().offset()));
}

Expand All @@ -766,14 +767,14 @@ private Integer offsetManagerBroker(String groupId)

private Integer offsetManagerBroker(BlockingChannel channel, String groupId)
{
final ConsumerMetadataRequest request =
new ConsumerMetadataRequest(groupId, (short) 0, 0, clientId());
final GroupCoordinatorRequest request =
new GroupCoordinatorRequest(groupId, (short) 0, 0, clientId());

LOG.debug("Sending consumer metadata request: {}", request);

channel.send(request);
ConsumerMetadataResponse response =
ConsumerMetadataResponse.readFrom(channel.receive().buffer());
GroupCoordinatorResponse response =
GroupCoordinatorResponse.readFrom(channel.receive().payload());

LOG.debug("Received consumer metadata response: {}", response);

Expand Down Expand Up @@ -866,7 +867,7 @@ private OffsetResponse sendOffsetRequest(Integer brokerId, TopicVO topic,
{
channel.send(offsetRequest.underlying());
final kafka.api.OffsetResponse underlyingResponse =
kafka.api.OffsetResponse.readFrom(channel.receive().buffer());
kafka.api.OffsetResponse.readFrom(channel.receive().payload());

LOG.debug("Received offset response: {}", underlyingResponse);

Expand Down