Skip to content

Commit

Permalink
Address PR comments, update README, image
Browse files Browse the repository at this point in the history
  • Loading branch information
patelh committed Mar 26, 2015
1 parent 3ac2f29 commit e61eb09
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist
/.settings
activator*
RUNNING_PID
.DS_Store
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ It supports the following :
- Run preferred replica election
- Generate partition assignments (based on current state of cluster)
- Run reassignment of partition (based on generated assignments)
- Create a topic with optional topic configs (0.8.1.1 has different configs than 0.8.2+)
- Delete topic (only supported on 0.8.2+ and remember set delete.topic.enable=true in broker config)
- Topic list now indicates topics marked for deletion (only supported on 0.8.2+)

Cluster Management

Expand Down
8 changes: 3 additions & 5 deletions app/controllers/Topic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import play.api.mvc._

import scala.concurrent.Future
import scala.util.{Success, Failure, Try}
import scalaz.-\/
import scalaz.{\/-, -\/}

/**
* @author hiral
Expand Down Expand Up @@ -87,15 +87,13 @@ object Topic extends Controller{

def createTopic(clusterName: String) = Action.async { implicit request =>
createTopicForm(clusterName).map { errorOrForm =>
errorOrForm.fold(
error => Ok(views.html.errors.onApiError(error)),
form => Ok(views.html.topic.createTopic(clusterName, form)))
Ok(views.html.topic.createTopic(clusterName, errorOrForm))
}
}

def handleCreateTopic(clusterName: String) = Action.async { implicit request =>
defaultCreateForm.bindFromRequest.fold(
formWithErrors => Future.successful(BadRequest(views.html.topic.createTopic(clusterName,formWithErrors))),
formWithErrors => Future.successful(BadRequest(views.html.topic.createTopic(clusterName,\/-(formWithErrors)))),
ct => {
val props = new Properties()
ct.configs.filter(_.value.isDefined).foreach(c => props.setProperty(c.name,c.value.get))
Expand Down
2 changes: 1 addition & 1 deletion app/kafka/manager/KafkaStateActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import scala.util.{Success, Failure, Try}
import ActorModel._
import kafka.manager.utils._
import scala.collection.JavaConverters._
class KafkaStateActor(curator: CuratorFramework, deleteSupported: Boolean = false) extends BaseQueryCommandActor {
class KafkaStateActor(curator: CuratorFramework, deleteSupported: Boolean) extends BaseQueryCommandActor {

// e.g. /brokers/topics/analytics_content/partitions/0/state
private[this] val topicsTreeCache = new TreeCache(curator,ZkUtils.BrokerTopicsPath)
Expand Down
37 changes: 21 additions & 16 deletions app/views/topic/createTopic.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*@
@(cluster: String, createTopicForm: Form[models.form.CreateTopic])(implicit request: RequestHeader)
@import scalaz.{\/}
@(cluster: String, errorOrForm: kafka.manager.ApiError \/ Form[models.form.CreateTopic])(implicit request: RequestHeader)

@import helper._
@import b3.vertical.fieldConstructor
Expand All @@ -11,6 +12,24 @@
@theMenu = {
@views.html.navigation.clusterMenu(cluster,"Topic","Create",models.navigation.Menus.clusterMenus(cluster))
}

@renderForm(createTopicForm: Form[models.form.CreateTopic]) = {
<div class="panel-body">
@b3.form(routes.Topic.handleCreateTopic(cluster)) {
<fieldset>
@b3.text(createTopicForm("topic"), '_label -> "Topic", 'placeholder -> "", 'autofocus -> true )
@b3.text(createTopicForm("partitions"), '_label -> "Partitions", 'placeholder -> "8")
@b3.text(createTopicForm("replication"), '_label -> "Replication Factor", 'placeholder -> "3")
@helper.repeat(createTopicForm("configs"), min = 1) { configsForm =>
@b3.hidden(configsForm("name").name, configsForm("name").value.getOrElse(""))
@b3.text(configsForm("value"), '_label -> configsForm("name").value.getOrElse(""))
}
@b3.submit('class -> "submit-button btn btn-primary"){ Create }
<a href="@routes.Topic.topics(cluster)" class="cancel-button btn btn-default" role="button">Cancel</a>
</fieldset>
}
</div>
}

@main(
"Create Topic",
Expand All @@ -19,21 +38,7 @@
<div class="col-md-6 un-pad-me">
<div class="panel panel-default">
<div class="panel-heading"><h3><button type="button" class="btn btn-link" onclick="goBack()"><span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span></button>Create Topic</h3></div>
<div class="panel-body">
@b3.form(routes.Topic.handleCreateTopic(cluster)) {
<fieldset>
@b3.text(createTopicForm("topic"), '_label -> "Topic", 'placeholder -> "", 'autofocus -> true )
@b3.text(createTopicForm("partitions"), '_label -> "Partitions", 'placeholder -> "8")
@b3.text(createTopicForm("replication"), '_label -> "Replication Factor", 'placeholder -> "3")
@helper.repeat(createTopicForm("configs"), min = 1) { configsForm =>
@b3.hidden(configsForm("name").name, configsForm("name").value.getOrElse(""))
@b3.text(configsForm("value"), '_label -> configsForm("name").value.getOrElse(""))
}
@b3.submit('class -> "submit-button btn btn-primary"){ Create }
<a href="@routes.Topic.topics(cluster)" class="cancel-button btn btn-default" role="button">Cancel</a>
</fieldset>
}
</div>
@errorOrForm.fold( views.html.errors.onApiError(_), renderForm(_))
</div>
</div>
}
Expand Down
37 changes: 3 additions & 34 deletions app/views/topic/topicViewContent.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,39 +109,6 @@
@topicIdentity.underReplicatedPercentage
</td>
</tr>
<!--
<tr>
<td>
@b3.form(routes.ReassignPartitions.handleOperation(cluster,topic)) {
<fieldset>
<input type="hidden" name="operation" value="confirm">
<input type="hidden" name="brokers" value="@Seq()">
@b3.submit('class -> "btn btn-primary btn-block"){ Generate Partition Assignments}
</fieldset>
}
</td>
</tr>
<tr>
<td>
@b3.form(routes.ReassignPartitions.handleOperation(cluster,topic)) {
<fieldset>
<input type="hidden" name="operation" value="run">
<input type="hidden" name="brokers" value="@Seq()">
@b3.submit('class -> "btn btn-primary btn-block"){ Reassign Partitions }
</fieldset>
}
</td>
</tr>
<tr>
<td>
@b3.form(routes.Topic.handleDeleteTopic(cluster, topic)) {
<fieldset>
@b3.hidden("topic",topic)
@b3.submit('class -> "btn btn-primary btn-block"){ Delete Topic }
</fieldset>
}
</td>
</tr>-->
</tbody>
</table>
@if(!topicIdentity.config.isEmpty) {
Expand Down Expand Up @@ -170,7 +137,8 @@
<td>
@b3.form(routes.ReassignPartitions.handleOperation(cluster,topic)) {
<fieldset>
<input type="hidden" name="operation" value="generate">
<input type="hidden" name="operation" value="confirm">
<input type="hidden" name="brokers" value="@Seq()">
@b3.submit('class -> "btn btn-primary btn-block"){ Generate Partition Assignments}
</fieldset>
}
Expand All @@ -179,6 +147,7 @@
@b3.form(routes.ReassignPartitions.handleOperation(cluster,topic)) {
<fieldset>
<input type="hidden" name="operation" value="run">
<input type="hidden" name="brokers" value="@Seq()">
@b3.submit('class -> "btn btn-primary btn-block"){ Reassign Partitions }
</fieldset>
}
Expand Down
Binary file modified img/topic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e61eb09

Please sign in to comment.