Commit Graph

4511 Commits

Author SHA1 Message Date
Koen De Groote 2bc780b959 MINOR: Use EnumMap/EnumSet if possible (#3919)
They are more efficient than HashMap/HashSet.

Reviewers: Ismael Juma <ismael@juma.me.uk>
2017-12-29 12:39:18 +00:00
Satish Duggana a3aea3cf4d MINOR: Fixed clusterId reference in Metadata.update (#4360)
Also fixed log message with respective error in KerberosLogin.login.

Reviewers: Jason Gustafson <jason@confluent.io>
2017-12-28 10:21:43 -08:00
Manikumar Reddy O 89b245baa7 MINOR: Update test classes to use KafkaZkClient/AdminZkClient methods (#4353) 2017-12-27 16:30:02 +00:00
Vahid Hashemian 5fc3fd48b0 MINOR: Use TopicPartition in ConsumerGroupCommand instead of TopicAndPartition where possible (#4333)
Reviewers: Jason Gustafson <jason@confluent.io>
2017-12-22 18:37:36 -08:00
Guozhang Wang 5995453f4c MINOR: Web docs for KIP-220
1. added functions for KafkaStreams and KafkaClientSupplier.
2. added prefix for admin client in StreamsConfig.

Author: Guozhang Wang <wangguoz@gmail.com>

Reviewers: Jason Gustafson <jason@confluent.io>, Matthias J. Sax <matthias@confluent.io>

Closes #4338 from guozhangwang/K6150-doc-changes
2017-12-22 11:53:04 -08:00
Matthias Wessendorf 0538f15ac3 KAFKA-5772 Improve Util classes (#3370)
Utils with static methods should not be instantiated, hence marking the classes `final` and adding a `private` constructor.

Reviewers: Randall Hauch <rhauch@gmail.com>, Jason Gustafson <jason@confluent.io>
2017-12-22 11:41:21 -08:00
Ismael Juma 2652565d42
KAFKA-6390: Update ZooKeeper to 3.4.11, Gradle and other minor updates (#4345)
Updates:
- Gradle, gradle plugins and maven artifact updated
- Bug fix updates for ZooKeeper, Jackson, EasyMock and Snappy

Not updated:
- RocksDB as it often causes issues, so better done separately
- args4j as our test coverage is weak and the update was a
feature release

Also fixed scala-reflect version to match scala-library.

Release notes for ZooKeeper 3.4.11:
https://zookeeper.apache.org/doc/r3.4.11/releasenotes.html

A notable fix is improved handling of UnknownHostException:
https://issues.apache.org/jira/browse/ZOOKEEPER-2614

Manually tested that IntelliJ import and build still works.
Relying on existing test suite otherwise.

Reviewers: Jun Rao <junrao@gmail.com>
2017-12-22 18:41:22 +00:00
Jun Rao 27c2c81663 KAFKA-6320: Move ZK metrics in KafkaHealthCheck to ZookeeperClient (#4351)
* Moved metrics in KafkaHealthCheck to ZookeeperClient.
* Converted remaining ZkUtils usage in KafkaServer to ZookeeperClient and removed ZkUtils from KafkaServer.
* Made the re-creation of ZooKeeper during ZK session expiration with infinite retries.
* Added unit tests for all new methods in KafkaZkClient.

Reviewers: Manikumar Reddy <manikumar.reddy@gmail.com>, Ismael Juma <ismael@juma.me.uk>
2017-12-22 10:28:57 +00:00
Matthias Wessendorf 43aaa7c363 KAFKA-5895: Gradle 3.0+ is needed on the build (#3861)
Reviewers: Ismael Juma <ismael@juma.me.uk>
2017-12-22 01:52:12 +00:00
Ismael Juma 9fcb0017d7
MINOR: Use GitHub git repo for push by default (#4352) 2017-12-22 01:19:13 +00:00
Joel Hamill 3e2fe17c08 MINOR: Improve Streams Dev Guide content on web docs
This PR migrates content from CP Streams Dev Guide.

Here is the top-level page:
![image](https://user-images.githubusercontent.com/11722533/33904945-df9cf804-df31-11e7-93aa-52385961522c.png)

Here is a child page:
![image](https://user-images.githubusercontent.com/11722533/33904976-f2eafabe-df31-11e7-918c-fbf95db0f76b.png)

See related: https://github.com/apache/kafka-site/pull/112

Author: Joel Hamill <joel-hamill@users.noreply.github.com>

Reviewers: Guozhang Wang <wangguoz@gmail.com>

Closes #4252 from joel-hamill/20171122-migrate-cp-dev-guide
2017-12-21 11:15:54 -08:00
Guozhang Wang 7d6f6f7320 MINOR: Fix race condition in Streams EOS system test
We should start the process only within the `with` block, otherwise the bytes parameter would cause a race condition that result in false alarms of system test failures.

Author: Guozhang Wang <wangguoz@gmail.com>

Reviewers: Ewen Cheslack-Postava <me@ewencp.org>

Closes #4348 from guozhangwang/KMinor-fix-eos-test
2017-12-20 18:44:36 -08:00
Matthias J. Sax dca1474b4b KAFKA-6126: Remove unnecessary topics created check
Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Bill Bejeck <bill@confluent.io>, Guozhang Wang <wangguoz@gmail.com>

Closes #4322 from mjsax/kafka-6126-remove-topic-check-on-rebalance-2
2017-12-20 18:02:33 -08:00
Matthias J. Sax 9cacb92d13 KAFKA-4263: Fix flaky test QueryableStateIntegrationTest.concurrentAccess
Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Damian Guy <damian.guy@gmail.com>, Guozhang Wang <wangguoz@gmail.com>

Closes #4342 from mjsax/kafka-4263-concurrentAccess
2017-12-20 15:22:06 -08:00
Colin P. Mccabe 760d86a970 KAFKA-5849; Add process stop, round trip workload, partitioned test
* Implement process stop faults via SIGSTOP / SIGCONT

* Implement RoundTripWorkload, which both sends messages, and confirms that they are received at least once.

* Allow Trogdor tasks to block until other Trogdor tasks are complete.

* Add CreateTopicsWorker, which can be a building block for a lot of tests.

* Simplify how TaskSpec subclasses in ducktape serialize themselves to JSON.

* Implement some fault injection tests in round_trip_workload_test.py

Author: Colin P. Mccabe <cmccabe@confluent.io>

Reviewers: Ismael Juma <ismael@juma.me.uk>, Rajini Sivaram <rajinisivaram@googlemail.com>

Closes #4323 from cmccabe/KAFKA-5849
2017-12-20 21:35:33 +00:00
Manikumar Reddy 488ea4b9fd KAFKA-5647; Use KafkaZkClient in ReassignPartitionsCommand and PreferredReplicaLeaderElectionCommand
*  Use KafkaZkClient in ReassignPartitionsCommand
*  Use KafkaZkClient in PreferredReplicaLeaderElectionCommand
*  Updated test classes to use new methods
*  All existing tests should pass

Author: Manikumar Reddy <manikumar.reddy@gmail.com>

Reviewers: Jun Rao <junrao@gmail.com>

Closes #4260 from omkreddy/KAFKA-5647-ADMINCOMMANDS
2017-12-20 12:19:36 -08:00
Rajini Sivaram 35c1be7469 KAFKA-5746; Document new broker metrics added for health checks
Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #4026 from rajinisivaram/MINOR-KIP-188-metrics-docs
2017-12-20 13:37:42 +00:00
Dong Lin cdb3955452 KAFKA-6331; Fix transient failure in AdminClientIntegrationTest.testAlterReplicaLogDirs
Author: Dong Lin <lindong28@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #4306 from lindong28/KAFKA-6331
2017-12-20 12:01:36 +00:00
Guozhang Wang 82c6d429e7 KAFKA-6150: KIP-204 part III; Change repartition topic segment size and ms
1. Create default internal topic configs in StreamsConfig, especially for repartition topics change the segment size and time to smaller value.
2. Consolidate the default internal topic settings to InternalTopicManager and simplify InternalTopicConfig correspondingly.
3. Add an integration test for purging data.
4. MINOR: change TopologyBuilderException to IllegalStateException in StreamPartitionAssignor (part of https://issues.apache.org/jira/browse/KAFKA-5660).

Here are a few public facing APIs that get added:

1. AbstractConfig#originalsWithPrefix(String prefix, boolean strip): this for simplify the logic of passing admin and topic prefixed configs to consumer properties.
2. KafkaStreams constructor with Time object for convienent mocking in tests.

Will update KIP-204 accordingly if people re-votes these changes.

Author: Guozhang Wang <wangguoz@gmail.com>
Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Matthias J. Sax <matthias@confluent.io>, Bill Bejeck <bill@confluent.io>, Damian Guy <damian.guy@gmail.com>

Closes #4315 from guozhangwang/K6150-segment-size
2017-12-19 16:05:42 -08:00
Bill Bejeck f3b9afe622 MINOR: Broker down for significant amt of time system test
System test where a broker is offline more than the configured timeouts.  In this case:
- Max poll interval set to 45 secs
- Retries set to 2
- Request timeout set to 15 seconds
- Max block ms set to 30 seconds

The broker was taken off-line for 70 seconds or more than double request timeout * num retries

[passing system test results](http://confluent-kafka-branch-builder-system-test-results.s3-us-west-2.amazonaws.com/2017-12-11--001.1513034559--bbejeck--KSTREAMS_1179_broker_down_for_significant_amt_of_time--6ab4802/report.html)

Author: Bill Bejeck <bill@confluent.io>

Reviewers: Matthias J. Sax <matthias@confluent.io>, Guozhang Wang <wangguoz@gmail.com>

Closes #4313 from bbejeck/KSTREAMS_1179_broker_down_for_significant_amt_of_time
2017-12-19 15:37:21 -08:00
Ismael Juma 88c2b6849a KAFKA-6317; Maven artifact for kafka should not depend on log4j
It should only depend on slf4j-api (like kafka-clients). The
release tarball still includes log4j and slf4j-log4j12.

Manually verified that there are no duplicate dependencies
in the release tarball and `./gradlew core:dependencies`
looks good.

Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Closes #4297 from ijuma/kafka-6317-kafka-slf4j-api-only
2017-12-19 15:15:27 +00:00
Matthias J. Sax 9aad649fd0 MINOR: Fix race condition in KafkaStreamsTest.shouldReturnThreadMetadata
Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Guozhang Wang <wangguoz@gmail.com>

Closes #4337 from mjsax/minor-fix-kafakstreamstest
2017-12-18 17:39:25 -08:00
Matthias J. Sax 22f742cdd2 MINOR: Stabilize flaky smoke system tests before KIP-91
This is a workaround until KIP-91 is merged. We tried increasing the timeout multiple times already but tests are still flaky.

Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Bill Bejeck <bill@confluent.io>, Apurva Mehta <apurva@confluent.io>, Guozhang Wang <wangguoz@gmail.com>

Closes #4329 from mjsax/hotfix-system-tests
2017-12-18 17:34:50 -08:00
Dong Lin 066bfc314c KAFKA-6258; SSLTransportLayer should keep reading from socket until either the buffer is full or the socket has no more data
When consumer uses plaintext and there is remaining data in consumer's buffer, consumer.poll() will read all data available from the socket buffer to consumer buffer. However, if consumer uses ssl and there is remaining data, consumer.poll() may only read 16 KB (the size of SslTransportLayer.appReadBuffer) from socket buffer. This will reduce efficient of consumer.poll() by asking user to call more poll() to get the same amount of data.

Furthermore, we observe that for users who naively sleep a constant time after each consumer.poll(), some partition will lag behind after they switch from plaintext to ssl. Here is the explanation why this can happen.

Say there are 1 partition of 1MB/sec and 9 partition of 32KB/sec. Leaders of these partitions are all different and consumer is consuming these 10 partitions. Let's also assume that socket read buffer size is large enough and consume sleeps 1 sec between consumer.poll(). 1 sec is long enough for consumer to receive the FetchResponse back from broker.

When consumer uses plaintext, each consumer.poll() will read all data from the socket buffer and it means 1 MB data is read from each partition.

When consumer uses ssl, each consumer.poll() is likely to find that there is some data available in the memory. In this case consumer only reads 16 KB data from other sockets, particularly the socket for the broker with the large partition. Then the throughput of the large partition will be limited to 16KB/sec.

Arguably user should not sleep 1 sec if its consumer is lagging behind. But on Kafka dev side it is nice to keep the previous behavior and optimize consumer.poll() to read as much data from socket as possible.

Author: Dong Lin <lindong28@gmail.com>

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>, Jason Gustafson <jason@confluent.io>

Closes #4248 from lindong28/KAFKA-6258
2017-12-18 11:15:09 -08:00
Matthias J. Sax e86f70ed20 MINOR: improve JavaDocs for KafkaStreams, KafkaProducer, KafkaConsumer
Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Apurva Mehta <apurva@confluent.io>, Guozhang Wang <wangguoz@gmail.com>

Closes #4335 from mjsax/minor-improve-KafkaStreams-javadocs
2017-12-18 11:10:03 -08:00
Prasanna Gautam e5daa40e31 KAFKA-5473; handle ZK session expiration properly when a new session can't be established
(WIP: this commit isn't ready to be reviewed yet. I was checking the travis-ci build with the configuration changes in my account and opened the PR prematurely against trunk. I will make it consistent with Contribution guidelines once it's well tested.)

https://issues.apache.org/jira/browse/KAFKA-5473

Design:
`zookeeper.connection.retry.timeout.ms` => this determines how long to wait before triggering the shutdown. The default is 60000ms.

Currently the implementation only handles the `handleSessionEstablishmentError` by waiting for the sessionTimeout.

Author: Prasanna Gautam <prasannagautam@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>, Jun Rao <junrao@gmail.com>

Closes #3990 from prasincs/KAFKA-5473
2017-12-15 14:48:30 -08:00
Vahid Hashemian 529786638b KAFKA-5526; Additional `--describe` views for ConsumerGroupCommand (KIP-175)
The `--describe` option of ConsumerGroupCommand is expanded, as proposed in [KIP-175](https://cwiki.apache.org/confluence/display/KAFKA/KIP-175%3A+Additional+%27--describe%27+views+for+ConsumerGroupCommand), to support:
* `--describe` or `--describe --offsets`: listing of current group offsets
* `--describe --members` or `--describe --members --verbose`: listing of group members
* `--describe --state`: group status

Example: With a single partition topic `test1` and a double partition topic `test2`, consumers `consumer1` and `consumer11` subscribed to `test`, consumers `consumer2` and `consumer22` and `consumer222` subscribed to `test2`, and all consumers belonging to group `test-group`, this is an output example of the new options above for `test-group`:

```
--describe, or --describe --offsets:

TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                     HOST            CLIENT-ID
test2           0          0               0               0               consumer2-bad9496d-0889-47ab-98ff-af17d9460382  /127.0.0.1      consumer2
test2           1          0               0               0               consumer22-c45e6ee2-0c7d-44a3-94a8-9627f63fb411 /127.0.0.1      consumer22
test1           0          0               0               0               consumer1-d51b0345-3194-4305-80db-81a68fa6c5bf  /127.0.0.1      consumer1
```

```
--describe --members

CONSUMER-ID                                      HOST            CLIENT-ID       #PARTITIONS
consumer2-bad9496d-0889-47ab-98ff-af17d9460382   /127.0.0.1      consumer2       1
consumer222-ed2108cd-d368-41f1-8514-5b72aa835bcc /127.0.0.1      consumer222     0
consumer11-dc8295d7-8f3f-4438-9b11-7270bab46760  /127.0.0.1      consumer11      0
consumer22-c45e6ee2-0c7d-44a3-94a8-9627f63fb411  /127.0.0.1      consumer22      1
consumer1-d51b0345-3194-4305-80db-81a68fa6c5bf   /127.0.0.1      consumer1       1
```

```
--describe --members --verbose

CONSUMER-ID                                      HOST            CLIENT-ID       #PARTITIONS     ASSIGNMENT
consumer2-bad9496d-0889-47ab-98ff-af17d9460382   /127.0.0.1      consumer2       1               test2(0)
consumer222-ed2108cd-d368-41f1-8514-5b72aa835bcc /127.0.0.1      consumer222     0               -
consumer11-dc8295d7-8f3f-4438-9b11-7270bab46760  /127.0.0.1      consumer11      0               -
consumer22-c45e6ee2-0c7d-44a3-94a8-9627f63fb411  /127.0.0.1      consumer22      1               test2(1)
consumer1-d51b0345-3194-4305-80db-81a68fa6c5bf   /127.0.0.1      consumer1       1               test1(0)
```

```
--describe --state

COORDINATOR (ID)         ASSIGNMENT-STRATEGY       STATE                #MEMBERS
localhost:9092 (0)       range                     Stable               5
```

Note that this PR also addresses the issue reported in [KAFKA-6158](https://issues.apache.org/jira/browse/KAFKA-6158) by dynamically setting the width of columns `TOPIC`, `CONSUMER-ID`, `HOST`, `CLIENT-ID` and `COORDINATOR (ID)`. This avoid truncation of column values when they go over the current fixed width of these columns.

The code has been restructured to better support testing of individual values and also the console output. Unit tests have been updated and extended to take advantage of this restructuring.

Author: Vahid Hashemian <vahidhashemian@us.ibm.com>

Reviewers: Jason Gustafson <jason@confluent.io>

Closes #4271 from vahidhashemian/KAFKA-5526
2017-12-15 10:26:00 -08:00
Matt Farmer 69777260e0 KAFKA-6086: Provide for custom error handling when Kafka Streams fails to produce
This PR creates and implements the `ProductionExceptionHandler` as described in [KIP-210](https://cwiki.apache.org/confluence/display/KAFKA/KIP-210+-+Provide+for+custom+error+handling++when+Kafka+Streams+fails+to+produce).

I've additionally provided a default implementation preserving the existing behavior. I fixed various compile errors in the tests that resulted from my changing of method signatures, and added tests to cover the new behavior.

Author: Matt Farmer <mfarmer@rsglab.com>
Author: Matt Farmer <matt@frmr.me>

Reviewers: Matthias J. Sax <matthias@confluent.io>, Bill Bejeck <bill@confluent.io>, Damian Guy <damian.guy@gmail.com>

Closes #4165 from farmdawgnation/msf/kafka-6086
2017-12-15 12:53:17 +00:00
Tobias Gies 68712dcdec KAFKA-6308; Connect Struct should use deepEquals/deepHashCode
This changes the Struct's equals and hashCode method to use Arrays#deepEquals and Arrays#deepHashCode, respectively. This resolves a problem where two structs with values of type byte[] would not be considered equal even though the byte arrays' contents are equal. By using deepEquals, the byte arrays' contents are compared instead of ther identity.

Since this changes the behavior of the equals method for byte array values, the behavior of hashCode must change alongside it to ensure the methods still fulfill the general contract of "equal objects must have equal hashCodes".

Test rationale:
All existing unit tests for equals were untouched and continue to work. A new test method was added to verify the behavior of equals and hashCode for Struct instances that contain a byte array value. I verify the reflixivity and transitivity of equals as well as the fact that equal Structs have equal hashCodes
and not-equal structs do not have equal hashCodes.

Author: Tobias Gies <tobias.gies@trivago.com>
Author: Tobias Gies <tobias@tobiasgies.de>

Reviewers: Randall Hauch <rhauch@gmail.com>, Jason Gustafson <jason@confluent.io>

Closes #4293 from tobiasgies/feature/kafka-6308-deepequals
2017-12-14 15:26:20 -08:00
Colin P. Mccabe 616321bcb6 KAFKA-6102; Consolidate MockTime implementations between connect and clients
Author: Colin P. Mccabe <cmccabe@confluent.io>

Reviewers: Randall Hauch <rhauch@gmail.com>, Jason Gustafson <jason@confluent.io>

Closes #4105 from cmccabe/KAFKA-6102
2017-12-14 14:50:34 -08:00
Damian Guy 1cf7ec87d3 KAFKA-6360: Clear RocksDB Segments when store is closed
Now that we support re-initializing state stores, we need to clear the segments when the store is closed so that they can be re-opened.

Author: Damian Guy <damian.guy@gmail.com>

Reviewers: Bill Bejeck <bbejeck@gmail.com>, Guozhang Wang <wangguoz@gmail.com>, Ted Yu <yuzhihong@gmail.com>

Closes #4324 from dguy/kafka-6360
2017-12-14 09:51:56 -08:00
Damian Guy d1a9252ca1 KAFKA-6349: Fix concurrent modification exception in AbstractStateManager during restore
Fixes a `ConcurrentModificationException` in`AbstractStateManager` that is triggered when a `StateStore` is re-initialized and there are multiple stores in the context.

Author: Damian Guy <damian.guy@gmail.com>

Reviewers: Matthias J. Sax <matthias@confluent.io>, Bill Bejeck <bill@confluent.io>, GuozhangWang <wangguoz@gmail.com>

Closes #4317 from dguy/kafka-6349
2017-12-12 19:25:01 -08:00
Damian Guy fe3699ce33 MINOR: Fix warn logging in RecordCollectorImpl
Fix warn log message in RecordCollectorImpl so it prints the exception message rather than `{}`

Author: Damian Guy <damian.guy@gmail.com>

Reviewers: Matthias J. Sax <matthias@confluent.io>, Bill Bejeck <bill@confluent.io>, GuozhangWang <wangguoz@gmail.com>

Closes #4318 from dguy/minor-logging-record-collector
2017-12-12 19:13:39 -08:00
Manikumar Reddy b088822134 KAFKA-5764; Add toLowerCase support to sasl.kerberos.principal.to.local rule (KIP-203)
Author: Manikumar Reddy <manikumar.reddy@gmail.com>

Reviewers: Jason Gustafson <jason@confluent.io>

Closes #3800 from omkreddy/KAFKA-5764-REGEX
2017-12-12 15:47:57 -08:00
umesh chaudhary 0a508a436c KAFKA-5631; Use Jackson for serialising to JSON
- Rename `encode` to `legacyEncodeAsString`, we
can remove this when we remove `ZkUtils`.
- Introduce `encodeAsString` that uses Jackson.
- Change `encodeAsBytes` to use Jackson.
- Avoid intermediate string when converting
Broker to json bytes.

The methods that use Jackson only support
Java collections unlike `legacyEncodeAsString`.

Tests were added `encodeAsString` and
`encodeAsBytes`.

Author: umesh chaudhary <umesh9794@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #4259 from umesh9794/KAFKA-5631
2017-12-12 18:34:03 +02:00
Rajini Sivaram 651c6e480a KAFKA-6319: Quote strings stored in JSON configs
This is required for ACLs where SSL principals contain
special characters (e.g. comma) that are escaped using
backslash. The strings need to be quoted for JSON to
ensure that the JSON stored in ZK is valid.

Also converted `SslEndToEndAuthorizationTest` to use a
principal with special characters to ensure that this
path is tested.

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #4303 from rajinisivaram/KAFKA-6319
2017-12-12 12:05:11 +02:00
Ismael Juma a5cd34d796 KAFKA-6324; Change LogSegment.delete to deleteIfExists and harden log recovery
- Rename `delete()` to `deleteIfExists()` in `LogSegment`, `AbstractIndex`
and `TxnIndex`. Throw exception in case of IO errors for more informative
errors and to make it less likely that errors are ignored, `boolean` is used
for the case where the file does not exist (like `Files.deleteIfExists()`).
- Fix an instance of delete while open (should fix KAFKA-6322 and
KAFKA-6075).
- `LogSegment.deleteIfExists` no longer throws an exception if any of
the files it tries to delete does not exist (fixes KAFKA-6194).
- Remove unnecessary `FileChannel.force(true)` when deleting file.
- Introduce `LogSegment.open()` and use it to improve encapsulation
and reduce duplication.
- Expand functionality of `LogSegment.onBecomeInactiveSegment()`
to reduce duplication and improve encapsulation.
- Use `AbstractIndex.deleteIfExists()` instead of deleting files manually.
- Improve logging when deleting swap files.
- Use CorruptIndexException instead of IllegalArgumentException.
- Simplify `LogCleaner.cleanSegments()` to reduce duplication and
improve encapsulation.
- A few other clean-ups in Log, LogSegment, etc.

Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Jun Rao <junrao@gmail.com>, Ted Yu <yuzhihong@gmail.com>

Closes #4040 from ijuma/kafka-5829-follow-up
2017-12-12 10:00:05 +02:00
Guozhang Wang 72eec0a04c KAFKA-6334: minor typo fix in web docs 2017-12-11 18:55:13 -08:00
Rajini Sivaram e5741b90cd MINOR: Increase number of messages in replica verification tool test
Increase the number of messages produced to make the test more reliable. The test failed in a recent build and also fails intermittently when run locally. Since the producer uses acks=0 and the test stops as soon as a lag is observed, the change shouldn't have a big impact on the time taken to run when lag is observed sooner.

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Jason Gustafson <jason@confluent.io>

Closes #4312 from rajinisivaram/MINOR-replicaverification-test
2017-12-11 11:13:57 -08:00
Matthias J. Sax 043951753b KAFKA-6121: Restore and global consumer should not use auto.offset.reset
- set auto.offset.reste to "none" for restore and global consumer
- handle InvalidOffsetException for restore and global consumer
- add corresponding tests
- some minor cleanup

Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Damian Guy <damian.guy@gmail.com, Bill Bejeck <bill@confluent.io>, GuozhangWang <wangguoz@gmail.com>

Closes #4215 from mjsax/kafka-6121-restore-global-consumer-handle-reset
2017-12-11 14:20:10 +00:00
Jason Gustafson 2bf2348b5f KAFKA-6289; NetworkClient should not expose failed internal ApiVersions requests
The NetworkClient internally ApiVersion requests to each broker following connection establishment. If this request happens to fail (perhaps due to an incompatible broker), the NetworkClient includes the response in the result of poll(). Applications will generally not be expecting this response which may lead to failed assertions (or in the case of AdminClient, an obscure log message).

I've added test cases which await the ApiVersion request sent by NetworkClient to be in-flight, and then disconnect the connection and verify that the response is not included from poll().

Author: Jason Gustafson <jason@confluent.io>

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Closes #4280 from hachikuji/KAFKA-6289
2017-12-08 10:54:31 +00:00
Matthias J. Sax 234ec8a8af KAFKA-4857: Replace StreamsKafkaClient with AdminClient in Kafka Streams
Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Ismael Juma <ismael@juma.me.uk>, Bill Bejeck <bbejeck@gmail.com>, Guozhang Wang <wangguoz@gmail.com>

Closes #4242 from mjsax/kafka-4857-admit-client
2017-12-07 16:16:54 -08:00
Randall Hauch 86e2bc937a KAFKA-6313; Add SLF4J as direct dependency to Kafka core
Recent changes are now directly using the SLF4J API, so we should have a direct dependency.

Author: Randall Hauch <rhauch@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #4296 from rhauch/kafka-6313
2017-12-07 10:36:47 +02:00
Ismael Juma b73c765d7e MINOR: Avoid intermediate strings when parsing/decoding ZK JSON
Also:
- Fix bug in result type of `createSequentialPersistentPath`
- Remove duplicated code from `ReplicationUtils`
- Move `propagateIsrChanges` from `ReplicationUtils` to `KafkaZkClient`
- Add tests
- Minor clean-ups

Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Jun Rao <junrao@gmail.com>, Ted Yu <yuzhihong@gmail.com>, Manikumar Reddy <manikumar.reddy@gmail.com>

Closes #4261 from ijuma/zk-data-improvements
2017-12-07 02:38:34 +02:00
Ismael Juma b00a9fc7c3 KAFKA-6065; Latency metric for KafkaZkClient
Measures the latency of each request.

Updated existing `ZkUtils` test to use `KafkaZkClient`
instead.

Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Jun Rao <junrao@gmail.com>

Closes #4265 from ijuma/kafka-6065-async-zk-metrics
2017-12-07 01:13:40 +02:00
Ismael Juma d543e19a09 KAFKA-6193; Only delete reassign_partitions znode after reassignment is complete
- Ensure that `partitionsBeingReassigned` is fully populated before
`removePartitionFromReassignedPartitions` is invoked. This is
necessary to avoid premature deletion of the `reassign_partitions`
znode.
- Modify and add tests to verify the fixes.
- Add documentation.
- Use `info` log message if assignedReplicas == newReplicas and
remove control flow based on exceptions.
- General logging improvements.
- Simplify `initializePartitionAssignment` by relying on logic already
present in `maybeTriggerPartitionReassignment`.

Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Jun Rao <junrao@gmail.com>, Guozhang Wang <wangguoz@gmail.com>

Closes #4283 from ijuma/kafka-6193-flaky-shouldPerformMultipleReassignmentOperationsOverVariousTopics
2017-12-06 22:18:41 +02:00
tedyu b690933987 KAFKA-6300; SelectorTest may fail with ConcurrentModificationException
Synchronization is added w.r.t. sockets ArrayList to avoid ConcurrentModificationException

Author: tedyu <yuzhihong@gmail.com>

Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Rajini Sivaram <rajinisivaram@googlemail.com>

Closes #4299 from tedyu/trunk
2017-12-06 19:43:29 +00:00
Jorge Quilcate Otoya 30f08d158a KAFKA-5520: KIP-171; Extend Consumer Group Reset Offset for Stream Application
KIP: https://cwiki.apache.org/confluence/display/KAFKA/KIP-171+-+Extend+Consumer+Group+Reset+Offset+for+Stream+Application

Merge changes from KIP-198

Ref: https://github.com/apache/kafka/pull/3831

Author: Jorge Quilcate Otoya <quilcate.jorge@gmail.com>
Author: Ismael Juma <ismael@juma.me.uk>
Author: Matthias J. Sax <matthias@confluent.io>
Author: Manikumar Reddy <manikumar.reddy@gmail.com>
Author: Guozhang Wang <wangguoz@gmail.com>
Author: Apurva Mehta <apurva@confluent.io>
Author: Rajini Sivaram <rajinisivaram@googlemail.com>
Author: Jason Gustafson <jason@confluent.io>
Author: Vahid Hashemian <vahidhashemian@us.ibm.com>
Author: Bill Bejeck <bill@confluent.io>
Author: Dong Lin <lindong28@gmail.com>
Author: Soenke Liebau <soenke.liebau@opencore.com>
Author: Colin P. Mccabe <cmccabe@confluent.io>
Author: Damian Guy <damian.guy@gmail.com>
Author: Xavier Léauté <xl+github@xvrl.net>
Author: Maytee Chinavanichkit <maytee.chinavanichkit@linecorp.com>
Author: Joel Hamill <git config --global user.email>
Author: Paolo Patierno <ppatierno@live.com>
Author: siva santhalingam <siva.santhalingam@gmail.com>
Author: Tommy Becker <tobecker@tivo.com>
Author: Mickael Maison <mickael.maison@gmail.com>
Author: Onur Karaman <okaraman@linkedin.com>
Author: tedyu <yuzhihong@gmail.com>
Author: Xin Li <Xin.Li@trivago.com>
Author: Magnus Edenhill <magnus@edenhill.se>
Author: Manjula K <manjula@kafka-summit.org>
Author: Hugo Louro <hmclouro@gmail.com>
Author: Jeff Widman <jeff@jeffwidman.com>
Author: bartdevylder <bartdevylder@gmail.com>
Author: Ewen Cheslack-Postava <me@ewencp.org>
Author: Jacek Laskowski <jacek@japila.pl>
Author: Tom Bentley <tbentley@redhat.com>
Author: Konstantine Karantasis <konstantine@confluent.io>

Reviewers: Matthias J. Sax <matthias@confluent.io>, Guozhang Wang <wangguoz@gmail.com>

Closes #4159 from jeqo/feature/kip-171
2017-12-06 11:38:38 -08:00
Manikumar Reddy fd8f182cc4 MINOR: Add maybeThrow method to ZooKeeperClient AsyncResponse
* Add maybeThrow method to AsyncResponse
* Update KafkaZkClient to use newly introduced maybeThrow
* Change AsyncResponse from trait to abstract class for
more readable stacktraces (there's no benefit in using a
trait here)

Author: Manikumar Reddy <manikumar.reddy@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #4266 from omkreddy/KAFKAZKCLEINT_EXCEPTION_CLEANUP
2017-12-06 16:27:21 +02:00
Dong Lin 078fd21365 KAFKA-6174; Add methods in AdminClient Options classes to restore binary compatibility with 0.11
From 0.11 to 1.0, we moved `DescribeClusterOptions timeoutMs(Integer timeoutMs)` from
DescribeClusterOptions to AbstractOptions (similarly for other Options classes). This can
cause code compiled against 0.11.0.x to fail when it is executed with 1.0 kafka-clients jar.
This patch adds back these methods to restore binary compatibility with 0.11.

Author: Dong Lin <lindong28@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #4257 from lindong28/KAFKA-6174
2017-12-06 15:56:56 +02:00