Skip to content

KAFKA-5919: Adding checks on "version" field for tools using it#5126

Closed
ppatierno wants to merge 3 commits into
apache:trunkfrom
ppatierno:kafka-5919-update
Closed

KAFKA-5919: Adding checks on "version" field for tools using it#5126
ppatierno wants to merge 3 commits into
apache:trunkfrom
ppatierno:kafka-5919-update

Conversation

@ppatierno

Copy link
Copy Markdown
Contributor

Adding checks on "version" field for tools using it.
This is a new version of the closed PR #3887 (to see for more comments and related discussion).

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@ppatierno

ppatierno commented Jun 2, 2018

Copy link
Copy Markdown
Contributor Author

@lindong28 this is the simple version of the #3887 which I closed due to a mess with rebase (and then merge). Sorry for that but now it's simpler to review and it's aligned with current trunk.

@lindong28 lindong28 self-assigned this Jun 3, 2018

@lindong28 lindong28 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch. Looks good overall. Left some minor comments.

val offset = partitionJs("offset").to[Long]
new TopicPartition(topic, partition) -> offset
}.toBuffer
Json.parseFull(jsonData) match {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: can you remove the { here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I searched for other places where match is used at it seems that in those places, the { is always used. Or am I wrong?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I comment in the wrong line. I actually mean the line below.

More specifically,

      case Some(js) => {
        val version = js.asJsonObject.get("version") match {
          case Some(jsonValue) => jsonValue.to[Int]
          case None => EarliestVersion
        }
        parseJsonData(version, js)
      }

can be:

      case Some(js) =>
        val version = js.asJsonObject.get("version") match {
          case Some(jsonValue) => jsonValue.to[Int]
          case None => EarliestVersion
        }
        parseJsonData(version, js)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, we don't use { after all usage of case in LogManager.scala.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you are right. Done!

new TopicPartition(topic, partition) -> offset
}.toBuffer
Json.parseFull(jsonData) match {
case Some(js) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: can you remove the { here so that we following the existing code style? There are a few other places where we can reduce { and } similarly. Also, could we also follow the existing code style and remove some empty lines?

).asJava)
}

def parseTopicsJsonString(jsonData: String): Seq[String] = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch is trying to differentiate between parseTopicsJsonString and parseTopicsData by using different names. Since the parameter types are already different and explanatory, would it be simpler to keep the existing name, e.g. parseTopicsData?


def generateAssignment(zkClient: KafkaZkClient, brokerListToReassign: Seq[Int], topicsToMoveJsonString: String, disableRackAware: Boolean): (Map[TopicPartition, Seq[Int]], Map[TopicPartition, Seq[Int]]) = {
val topicsToReassign = ZkUtils.parseTopicsData(topicsToMoveJsonString)
val topicsToReassign = parseTopicsJsonString(topicsToMoveJsonString)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the method in ZkUtils since that is no longer used?

Renamed parsing methods
Removed unused parsing json method from ZkUtils
@ppatierno

Copy link
Copy Markdown
Contributor Author

I fixed your request changes, just a comment/doubts about removing {.

@lindong28

Copy link
Copy Markdown
Member

Thanks for the patch @ppatierno. LGTM. Merged to the trunk.

@lindong28 lindong28 closed this Jun 4, 2018
lindong28 pushed a commit that referenced this pull request Jun 4, 2018
Adding checks on "version" field for tools using it.
This is a new version of the closed PR #3887 (to see for more comments and related discussion).

Author: Paolo Patierno <ppatierno@live.com>

Reviewers: Dong Lin <lindong28@gmail.com>

Closes #5126 from ppatierno/kafka-5919-update
@ppatierno ppatierno deleted the kafka-5919-update branch June 6, 2018 06:45
ying-zheng pushed a commit to ying-zheng/kafka that referenced this pull request Jul 6, 2018
Adding checks on "version" field for tools using it.
This is a new version of the closed PR apache#3887 (to see for more comments and related discussion).

Author: Paolo Patierno <ppatierno@live.com>

Reviewers: Dong Lin <lindong28@gmail.com>

Closes apache#5126 from ppatierno/kafka-5919-update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants