#!/bin/bash

set -ex

sleep 10

<% zks = link('zookeeper') %>
<% zk_port = zks.p('client_port') %>
<% list =  zks.instances.map { |instance| "#{instance.address}:#{zk_port}" }.join(",") %>

curl -v -u "<%= p('username') %>:<%= p('password') %>" localhost:<%= p("listen_port") %>/clusters  -X POST \
  --data 'name=<%= p("name") %>&zkHosts=<%= list %>&kafkaVersion=0.10.1.0&jmxUser=&jmxPass=&tuning.brokerViewUpdatePeriodSeconds=30&tuning.clusterManagerThreadPoolSize=2&tuning.clusterManagerThreadPoolQueueSize=100&tuning.kafkaCommandThreadPoolSize=2&tuning.kafkaCommandThreadPoolQueueSize=100&tuning.logkafkaCommandThreadPoolSize=2&tuning.logkafkaCommandThreadPoolQueueSize=100&tuning.logkafkaUpdatePeriodSeconds=30&tuning.partitionOffsetCacheTimeoutSecs=5&tuning.brokerViewThreadPoolSize=2&tuning.brokerViewThreadPoolQueueSize=1000&tuning.offsetCacheThreadPoolSize=2&tuning.offsetCacheThreadPoolQueueSize=1000&tuning.kafkaAdminClientThreadPoolSize=2&tuning.kafkaAdminClientThreadPoolQueueSize=1000'
