Skip to content

Commit

Permalink
display configs on broker page
Browse files Browse the repository at this point in the history
iamgd67 committed Jul 29, 2021
1 parent 4f7d908 commit 5a050fb
Showing 3 changed files with 26 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/controllers/Cluster.scala
Original file line number Diff line number Diff line change
@@ -210,8 +210,14 @@ class Cluster (val cc: ControllerComponents, val kafkaManagerContext: KafkaManag
}

def broker(c: String, b: Int) = Action.async { implicit request: RequestHeader =>
kafkaManager.getBrokerView(c,b).map { errorOrBrokerView =>
Ok(views.html.broker.brokerView(c,b,errorOrBrokerView)).withHeaders("X-Frame-Options" -> "SAMEORIGIN")
val futureErrorOrBrokerIdentity = kafkaManager.getBrokerIdentity(c,b)
kafkaManager.getBrokerView(c,b).zip(futureErrorOrBrokerIdentity).map {
case (errorOrBrokerView,errorOrBrokerIdentity) =>
var newRst = errorOrBrokerView
errorOrBrokerIdentity.map(bi=>{
newRst = errorOrBrokerView.map(x=>x.copy(broker=Option(bi)))
})
Ok(views.html.broker.brokerView(c,b,newRst)).withHeaders("X-Frame-Options" -> "SAMEORIGIN")
}
}

4 changes: 3 additions & 1 deletion app/kafka/manager/model/ActorModel.scala
Original file line number Diff line number Diff line change
@@ -52,7 +52,9 @@ object ActorModel {
case class BVView(topicPartitions: Map[TopicIdentity, BrokerTopicInfo], clusterContext: ClusterContext,
metrics: Option[BrokerMetrics] = None,
messagesPerSecCountHistory: Option[Queue[BrokerMessagesPerSecCount]] = None,
stats: Option[BrokerClusterStats] = None) extends QueryResponse {
stats: Option[BrokerClusterStats] = None,
broker: Option[BrokerIdentity] = None
) extends QueryResponse {
def numTopics : Int = topicPartitions.size
def numPartitions : Int = topicPartitions.values.foldLeft(0)((acc,i) => acc + i.partitions.size)
def numPartitionsAsLeader : Int = topicPartitions.values.foldLeft(0)((acc,i) => acc + i.partitionsAsLeader.size)
15 changes: 15 additions & 0 deletions app/views/broker/brokerViewContent.scala.html
Original file line number Diff line number Diff line change
@@ -31,6 +31,21 @@
}
</tbody>
</table>
@if(!brokerView.broker.isEmpty && !brokerView.broker.get.config.isEmpty) {
<table class="table">
<thead>
<th>Config</th><th>Value</th>
</thead>
<tbody>
@for( (k,v) <- brokerView.broker.get.config) {
<tr>
<td>@k</td>
<td>@v</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
</div>

0 comments on commit 5a050fb

Please sign in to comment.