Skip to content

Commit e6b37c0

Browse files
committed
Merge pull request #295 from dpkp/kafka_0_8_2
Kafka 0.8.2.0 updates
2 parents 28a8385 + 21a5ca8 commit e6b37c0

File tree

7 files changed

+175
-7
lines changed

7 files changed

+175
-7
lines changed

kafka/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ConnectionError, FailedPayloadsError,
1212
KafkaTimeoutError, KafkaUnavailableError,
1313
LeaderNotAvailableError, UnknownTopicOrPartitionError,
14-
NotLeaderForPartitionError)
14+
NotLeaderForPartitionError, ReplicaNotAvailableError)
1515

1616
from kafka.conn import collect_hosts, KafkaConnection, DEFAULT_SOCKET_TIMEOUT_SECONDS
1717
from kafka.protocol import KafkaProtocol
@@ -350,6 +350,11 @@ def load_metadata_for_topics(self, *topics):
350350
log.error('No leader for topic %s partition %d', topic, partition)
351351
self.topics_to_brokers[topic_part] = None
352352
continue
353+
# If one of the replicas is unavailable -- ignore
354+
# this error code is provided for admin purposes only
355+
# we never talk to replicas, only the leader
356+
except ReplicaNotAvailableError:
357+
log.warning('Some (non-leader) replicas not available for topic %s partition %d', topic, partition)
353358

354359
# If Known Broker, topic_partition -> BrokerMetadata
355360
if leader in self.brokers:
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# see kafka.server.KafkaConfig for additional details and defaults
16+
17+
############################# Server Basics #############################
18+
19+
# The id of the broker. This must be set to a unique integer for each broker.
20+
broker.id={broker_id}
21+
22+
############################# Socket Server Settings #############################
23+
24+
# The port the socket server listens on
25+
port={port}
26+
27+
# Hostname the broker will bind to. If not set, the server will bind to all interfaces
28+
host.name={host}
29+
30+
# Hostname the broker will advertise to producers and consumers. If not set, it uses the
31+
# value for "host.name" if configured. Otherwise, it will use the value returned from
32+
# java.net.InetAddress.getCanonicalHostName().
33+
#advertised.host.name=<hostname routable by clients>
34+
35+
# The port to publish to ZooKeeper for clients to use. If this is not set,
36+
# it will publish the same port that the broker binds to.
37+
#advertised.port=<port accessible by clients>
38+
39+
# The number of threads handling network requests
40+
num.network.threads=2
41+
42+
# The number of threads doing disk I/O
43+
num.io.threads=8
44+
45+
# The send buffer (SO_SNDBUF) used by the socket server
46+
socket.send.buffer.bytes=1048576
47+
48+
# The receive buffer (SO_RCVBUF) used by the socket server
49+
socket.receive.buffer.bytes=1048576
50+
51+
# The maximum size of a request that the socket server will accept (protection against OOM)
52+
socket.request.max.bytes=104857600
53+
54+
55+
############################# Log Basics #############################
56+
57+
# A comma seperated list of directories under which to store log files
58+
log.dirs={tmp_dir}/data
59+
60+
# The default number of log partitions per topic. More partitions allow greater
61+
# parallelism for consumption, but this will also result in more files across
62+
# the brokers.
63+
num.partitions={partitions}
64+
default.replication.factor={replicas}
65+
66+
############################# Log Flush Policy #############################
67+
68+
# Messages are immediately written to the filesystem but by default we only fsync() to sync
69+
# the OS cache lazily. The following configurations control the flush of data to disk.
70+
# There are a few important trade-offs here:
71+
# 1. Durability: Unflushed data may be lost if you are not using replication.
72+
# 2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
73+
# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to exceessive seeks.
74+
# The settings below allow one to configure the flush policy to flush data after a period of time or
75+
# every N messages (or both). This can be done globally and overridden on a per-topic basis.
76+
77+
# The number of messages to accept before forcing a flush of data to disk
78+
#log.flush.interval.messages=10000
79+
80+
# The maximum amount of time a message can sit in a log before we force a flush
81+
#log.flush.interval.ms=1000
82+
83+
############################# Log Retention Policy #############################
84+
85+
# The following configurations control the disposal of log segments. The policy can
86+
# be set to delete segments after a period of time, or after a given size has accumulated.
87+
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
88+
# from the end of the log.
89+
90+
# The minimum age of a log file to be eligible for deletion
91+
log.retention.hours=168
92+
93+
# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining
94+
# segments don't drop below log.retention.bytes.
95+
#log.retention.bytes=1073741824
96+
97+
# The maximum size of a log segment file. When this size is reached a new log segment will be created.
98+
log.segment.bytes=536870912
99+
100+
# The interval at which log segments are checked to see if they can be deleted according
101+
# to the retention policies
102+
log.retention.check.interval.ms=60000
103+
104+
# By default the log cleaner is disabled and the log retention policy will default to just delete segments after their retention expires.
105+
# If log.cleaner.enable=true is set the cleaner will be enabled and individual logs can then be marked for log compaction.
106+
log.cleaner.enable=false
107+
108+
############################# Zookeeper #############################
109+
110+
# Zookeeper connection string (see zookeeper docs for details).
111+
# This is a comma separated host:port pairs, each corresponding to a zk
112+
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
113+
# You can also append an optional chroot string to the urls to specify the
114+
# root directory for all kafka znodes.
115+
zookeeper.connect={zk_host}:{zk_port}/{zk_chroot}
116+
117+
# Timeout in ms for connecting to zookeeper
118+
zookeeper.connection.timeout.ms=1000000
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
log4j.rootLogger=INFO, stdout
17+
18+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
19+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
20+
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n
21+
22+
log4j.logger.kafka=DEBUG, stdout
23+
log4j.logger.org.I0Itec.zkclient.ZkClient=INFO, stdout
24+
log4j.logger.org.apache.zookeeper=INFO, stdout
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# the directory where the snapshot is stored.
16+
dataDir={tmp_dir}
17+
# the port at which the clients will connect
18+
clientPort={port}
19+
clientPortAddress={host}
20+
# disable the per-ip limit on the number of connections since this is a non-production config
21+
maxClientCnxns=0

test/fixtures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def open(self):
123123
# Party!
124124
self.out("Starting...")
125125
self.child.start()
126-
self.child.wait_for(r"Snapshotting")
126+
self.child.wait_for(r"binding to port")
127127
self.out("Done!")
128128

129129
def close(self):
@@ -212,8 +212,8 @@ def open(self):
212212

213213
if proc.wait() != 0:
214214
self.out("Failed to create Zookeeper chroot node")
215-
self.out(proc.stdout)
216-
self.out(proc.stderr)
215+
self.out(proc.stdout.read())
216+
self.out(proc.stderr.read())
217217
raise RuntimeError("Failed to create Zookeeper chroot node")
218218
self.out("Done!")
219219

test/test_client_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_ensure_topic_exists(self):
5454
# Offset Tests #
5555
####################
5656

57-
@kafka_versions("0.8.1", "0.8.1.1")
57+
@kafka_versions("0.8.1", "0.8.1.1", "0.8.2.0")
5858
def test_commit_fetch_offsets(self):
5959
req = OffsetCommitRequest(self.topic, 0, 42, b"metadata")
6060
(resp,) = self.client.send_offset_commit_request(b"group", [req])

test/test_consumer_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def test_huge_messages(self):
257257

258258
big_consumer.stop()
259259

260-
@kafka_versions("0.8.1", "0.8.1.1")
260+
@kafka_versions("0.8.1", "0.8.1.1", "0.8.2.0")
261261
def test_offset_behavior__resuming_behavior(self):
262262
self.send_messages(0, range(0, 100))
263263
self.send_messages(1, range(100, 200))
@@ -357,7 +357,7 @@ def test_kafka_consumer__blocking(self):
357357
self.assertEqual(len(messages), 5)
358358
self.assertGreaterEqual(t.interval, TIMEOUT_MS / 1000.0 )
359359

360-
@kafka_versions("0.8.1", "0.8.1.1")
360+
@kafka_versions("0.8.1", "0.8.1.1", "0.8.2.0")
361361
def test_kafka_consumer__offset_commit_resume(self):
362362
GROUP_ID = random_string(10)
363363

0 commit comments

Comments
 (0)