-
Notifications
You must be signed in to change notification settings - Fork 15.1k
MINOR: Fix bugs identified by compiler warnings #6258
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
Changes from all commits
852b11b
bb555d7
3ef916b
875a0e9
f0a0cab
9494582
d34e6a4
dd5a468
f2b655d
b0d70da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1751,7 +1751,7 @@ class KafkaZkClient private[zk] (zooKeeperClient: ZooKeeperClient, isSecure: Boo | |
|
|
||
| private def reCreate(): Stat = { | ||
| val codeAfterDelete = delete() | ||
| var codeAfterReCreate = codeAfterDelete | ||
| val codeAfterReCreate = codeAfterDelete | ||
| debug(s"Result of znode ephemeral deletion at $path is: $codeAfterDelete") | ||
| if (codeAfterDelete == Code.OK || codeAfterDelete == Code.NONODE) { | ||
| create() | ||
|
|
@@ -1880,6 +1880,7 @@ object KafkaZkClient { | |
| case _ => null | ||
| } | ||
| SetDataResponse(resultCode, setDataOp.path, ctx, stat, responseMetadata) | ||
| case zkOp => throw new IllegalStateException(s"Unexpected zkOp: $zkOp") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @junrao Please check that this is OK.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ijuma : Yes, this part looks good to me. |
||
| } | ||
| case null => throw KeeperException.create(resultCode) | ||
| case _ => throw new IllegalStateException(s"Cannot unwrap $response because the first zookeeper op is not check op in original MultiRequest") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1274,17 +1274,11 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging { | |
| waitForLeaderToBecome(partition1, 1) | ||
|
|
||
| // topic 2 unchanged | ||
| try { | ||
| electResult.partitionResult(partition2).get() | ||
| fail("topic 2 wasn't requested") | ||
| } catch { | ||
| case e: ExecutionException => | ||
| val cause = e.getCause | ||
| assertTrue(cause.getClass.getName, cause.isInstanceOf[UnknownTopicOrPartitionException]) | ||
| assertEquals("Preferred leader election for partition \"elect-preferred-leaders-topic-2-0\" was not attempted", | ||
| cause.getMessage) | ||
| assertEquals(0, currentLeader(partition2)) | ||
| } | ||
| var e = intercept[ExecutionException](electResult.partitionResult(partition2).get()).getCause | ||
| assertEquals(classOf[UnknownTopicOrPartitionException], e.getClass) | ||
| assertEquals("Preferred leader election for partition \"elect-preferred-leaders-topic-2-0\" was not attempted", | ||
| e.getMessage) | ||
| assertEquals(0, currentLeader(partition2)) | ||
|
|
||
| // meaningful election with null partitions | ||
| electResult = client.electPreferredLeaders(null) | ||
|
|
@@ -1298,17 +1292,11 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging { | |
| val unknownPartition = new TopicPartition("topic-does-not-exist", 0) | ||
| electResult = client.electPreferredLeaders(asList(unknownPartition)) | ||
| assertEquals(Set(unknownPartition).asJava, electResult.partitions.get) | ||
| try { | ||
| electResult.partitionResult(unknownPartition).get() | ||
| } catch { | ||
| case e: Exception => | ||
| val cause = e.getCause | ||
| assertTrue(cause.isInstanceOf[UnknownTopicOrPartitionException]) | ||
| assertEquals("The partition does not exist.", | ||
| cause.getMessage) | ||
| assertEquals(1, currentLeader(partition1)) | ||
| assertEquals(1, currentLeader(partition2)) | ||
| } | ||
| e = intercept[ExecutionException](electResult.partitionResult(unknownPartition).get()).getCause | ||
| assertEquals(classOf[UnknownTopicOrPartitionException], e.getClass) | ||
| assertEquals("The partition does not exist.", e.getMessage) | ||
| assertEquals(1, currentLeader(partition1)) | ||
| assertEquals(1, currentLeader(partition2)) | ||
|
|
||
| // Now change the preferred leader to 2 | ||
| changePreferredLeader(prefer2) | ||
|
|
@@ -1318,15 +1306,9 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging { | |
| assertEquals(Set(unknownPartition, partition1).asJava, electResult.partitions.get) | ||
| waitForLeaderToBecome(partition1, 2) | ||
| assertEquals(1, currentLeader(partition2)) | ||
| try { | ||
| electResult.partitionResult(unknownPartition).get() | ||
| } catch { | ||
| case e: Exception => | ||
| val cause = e.getCause | ||
| assertTrue(cause.isInstanceOf[UnknownTopicOrPartitionException]) | ||
| assertEquals("The partition does not exist.", | ||
| cause.getMessage) | ||
| } | ||
| e = intercept[ExecutionException](electResult.partitionResult(unknownPartition).get()).getCause | ||
| assertEquals(classOf[UnknownTopicOrPartitionException], e.getClass) | ||
| assertEquals("The partition does not exist.", e.getMessage) | ||
|
|
||
| // dupe partitions | ||
| electResult = client.electPreferredLeaders(asList(partition2, partition2)) | ||
|
|
@@ -1338,63 +1320,36 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging { | |
| changePreferredLeader(prefer1) | ||
| // but shut it down... | ||
| servers(1).shutdown() | ||
| waitUntilTrue ( | ||
| () => { | ||
| val description = client.describeTopics(Set (partition1.topic(), partition2.topic()).asJava).all().get() | ||
| return !description.asScala.flatMap{ | ||
| case (topic, description) => description.partitions().asScala.map( | ||
| partition => partition.isr().asScala).flatten | ||
| }.exists(node => node.id == 1) | ||
| }, | ||
| "Expect broker 1 to no longer be in any ISR" | ||
| ) | ||
| waitUntilTrue (() => { | ||
| val description = client.describeTopics(Set(partition1.topic, partition2.topic).asJava).all().get() | ||
| val isr = description.asScala.values.flatMap(_.partitions.asScala.flatMap(_.isr.asScala)) | ||
| !isr.exists(_.id == 1) | ||
| }, "Expect broker 1 to no longer be in any ISR") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tombentley after I fixed this, the test started failing.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ijuma : Good find. These are indeed existing bugs. There are 4 references of LeaderNotAvailableException in line 1358, 1372, 1380 and 1390. They all need to be changed to PreferredLeaderNotAvailableException. Once I fixed those locally, the test passes.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Jun! Will fix. |
||
|
|
||
| // ... now what happens if we try to elect the preferred leader and it's down? | ||
| val shortTimeout = new ElectPreferredLeadersOptions().timeoutMs(10000) | ||
| electResult = client.electPreferredLeaders(asList(partition1), shortTimeout) | ||
| assertEquals(Set(partition1).asJava, electResult.partitions.get) | ||
| try { | ||
| electResult.partitionResult(partition1).get() | ||
| fail() | ||
| } catch { | ||
| case e: Exception => | ||
| val cause = e.getCause | ||
| assertTrue(cause.getClass.getName, cause.isInstanceOf[LeaderNotAvailableException]) | ||
| assertTrue(s"Wrong message ${cause.getMessage}", cause.getMessage.contains( | ||
| "Failed to elect leader for partition elect-preferred-leaders-topic-1-0 under strategy PreferredReplicaPartitionLeaderElectionStrategy")) | ||
| } | ||
| e = intercept[ExecutionException](electResult.partitionResult(partition1).get()).getCause | ||
| assertEquals(classOf[PreferredLeaderNotAvailableException], e.getClass) | ||
| assertTrue(s"Wrong message ${e.getMessage}", e.getMessage.contains( | ||
| "Failed to elect leader for partition elect-preferred-leaders-topic-1-0 under strategy PreferredReplicaPartitionLeaderElectionStrategy")) | ||
| assertEquals(2, currentLeader(partition1)) | ||
|
|
||
| // preferred leader unavailable with null argument | ||
| electResult = client.electPreferredLeaders(null, shortTimeout) | ||
| try { | ||
| electResult.partitions.get() | ||
| fail() | ||
| } catch { | ||
| case e: Exception => | ||
| val cause = e.getCause | ||
| assertTrue(cause.getClass.getName, cause.isInstanceOf[LeaderNotAvailableException]) | ||
| } | ||
| try { | ||
| electResult.partitionResult(partition1).get() | ||
| fail() | ||
| } catch { | ||
| case e: Exception => | ||
| val cause = e.getCause | ||
| assertTrue(cause.getClass.getName, cause.isInstanceOf[LeaderNotAvailableException]) | ||
| assertTrue(s"Wrong message ${cause.getMessage}", cause.getMessage.contains( | ||
| "Failed to elect leader for partition elect-preferred-leaders-topic-1-0 under strategy PreferredReplicaPartitionLeaderElectionStrategy")) | ||
| } | ||
| try { | ||
| electResult.partitionResult(partition2).get() | ||
| fail() | ||
| } catch { | ||
| case e: Exception => | ||
| val cause = e.getCause | ||
| assertTrue(cause.getClass.getName, cause.isInstanceOf[LeaderNotAvailableException]) | ||
| assertTrue(s"Wrong message ${cause.getMessage}", cause.getMessage.contains( | ||
| "Failed to elect leader for partition elect-preferred-leaders-topic-2-0 under strategy PreferredReplicaPartitionLeaderElectionStrategy")) | ||
| } | ||
| e = intercept[ExecutionException](electResult.partitions.get()).getCause | ||
| assertEquals(classOf[PreferredLeaderNotAvailableException], e.getClass) | ||
|
|
||
| e = intercept[ExecutionException](electResult.partitionResult(partition1).get()).getCause | ||
| assertEquals(classOf[PreferredLeaderNotAvailableException], e.getClass) | ||
| assertTrue(s"Wrong message ${e.getMessage}", e.getMessage.contains( | ||
| "Failed to elect leader for partition elect-preferred-leaders-topic-1-0 under strategy PreferredReplicaPartitionLeaderElectionStrategy")) | ||
|
|
||
| e = intercept[ExecutionException](electResult.partitionResult(partition2).get()).getCause | ||
| assertEquals(classOf[PreferredLeaderNotAvailableException], e.getClass) | ||
| assertTrue(s"Wrong message ${e.getMessage}", e.getMessage.contains( | ||
| "Failed to elect leader for partition elect-preferred-leaders-topic-2-0 under strategy PreferredReplicaPartitionLeaderElectionStrategy")) | ||
|
|
||
| assertEquals(2, currentLeader(partition1)) | ||
| assertEquals(2, currentLeader(partition2)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tombentley Please check that we didn't intend to use this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this can be removed since the logic is folded into onComplete() already.