forked from yahoo/CMAK
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from yahoo/master
changes from upstream
- Loading branch information
Showing
34 changed files
with
410 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
language: scala | ||
sudo: false | ||
jdk: oraclejdk8 | ||
install: true | ||
script: "./sbt clean test" | ||
script: "./sbt clean coverage assembly" | ||
scala: | ||
- 2.11.5 | ||
- 2.11.5 | ||
#after_success: | ||
# - sbt coverageReport coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0 | ||
* See accompanying LICENSE file. | ||
*/ | ||
|
||
package controllers.api | ||
|
||
import controllers.KafkaManagerContext | ||
import play.api.libs.json._ | ||
import play.api.mvc._ | ||
|
||
object KafkaHealthCheck extends Controller { | ||
|
||
import play.api.libs.concurrent.Execution.Implicits.defaultContext | ||
|
||
private[this] val kafkaManager = KafkaManagerContext.getKafkaManager | ||
|
||
def availableBrokers(c: String) = Action.async { implicit request => | ||
kafkaManager.getBrokerList(c).map { errorOrBrokerList => | ||
errorOrBrokerList.fold( | ||
error => BadRequest(Json.obj("msg" -> error.msg)), | ||
brokerList => Ok(Json.obj("availableBrokers" -> brokerList.list.map(bi => bi.id))) | ||
) | ||
} | ||
} | ||
|
||
def underReplicatedPartitions(c: String, t: String) = Action.async { implicit request => | ||
kafkaManager.getTopicIdentity(c,t).map { errorOrTopicIdentity => | ||
errorOrTopicIdentity.fold( | ||
error => BadRequest(Json.obj("msg" -> error.msg)), | ||
topicIdentity => Ok(Json.obj("topic" -> t, "underReplicatedPartitions" -> topicIdentity.partitionsIdentity.filter(_._2.isUnderReplicated).map{case (num, pi) => pi.partNum})) | ||
) | ||
} | ||
} | ||
|
||
def unavailablePartitions(c: String, t: String) = Action.async { implicit request => | ||
kafkaManager.getTopicIdentity(c,t).map { errorOrTopicIdentity => | ||
errorOrTopicIdentity.fold( | ||
error => BadRequest(Json.obj("msg" -> error.msg)), | ||
topicIdentity => Ok(Json.obj("topic" -> t, "unavailablePartitions" -> topicIdentity.partitionsIdentity.filter(_._2.isr.isEmpty).map{case (num, pi) => pi.partNum})) | ||
) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.