Skip to content

Commit

Permalink
Merge pull request #223 from DataDog/jamie/flags
Browse files Browse the repository at this point in the history
jamie/flags
  • Loading branch information
jamiealquiza committed Nov 19, 2018
2 parents da31cab + c515814 commit 64d6d39
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
12 changes: 6 additions & 6 deletions cmd/topicmappr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Avoids reassigning partitions where movement isn't necessary, greatly reducing r

**Balancing Partition Placement With Constraints**

For each partition placement, topicmappr chooses the least-utilized candidate broker (based on partition counts or storage available, configurable via the `-placement` param) that satisfies the following constraints:
For each partition placement, topicmappr chooses the least utilized candidate broker (configurable as by storage or by partition counts) that satisfies the following constraints:

- the broker isn't already in the replica set
- the broker isn't in any of the existing replica set localities (using the Kafka `rack-id` parameter)
Expand Down Expand Up @@ -45,13 +45,13 @@ Usage:
Available Commands:
help Help about any command
rebalance [BETA] Rebalance partition allotments among a set of topics and brokers
rebalance Rebalance partition allotments among a set of topics and brokers
rebuild Rebuild a partition map for one or more topics
Flags:
-h, --help help for topicmappr
--zk-addr string ZooKeeper connect string (for broker metadata or rebuild-topic lookups) (default "localhost:2181")
--zk-prefix string ZooKeeper namespace prefix (for Kafka brokers)
--zk-addr string ZooKeeper connect string [TOPICMAPPR_ZK_ADDR] (default "localhost:2181")
--zk-prefix string ZooKeeper prefix (if Kafka is configured with a chroot path prefix) [TOPICMAPPR_ZK_PREFIX]
Use "topicmappr [command] --help" for more information about a command.
```
Expand Down Expand Up @@ -96,7 +96,7 @@ Global Flags:
## rebalance usage

```
[BETA] Rebalance partition allotments among a set of topics and brokers
Rebalance partition allotments among a set of topics and brokers
Usage:
topicmappr rebalance [flags]
Expand All @@ -123,4 +123,4 @@ Global Flags:

## Managing and Repairing Topics

See the wiki [Usage Guide](https://github.com/DataDog/kafka-kit/wiki/Usage-Guide) section for examples of common topic management tasks.
See the wiki [Usage Guide](https://github.com/DataDog/kafka-kit/wiki/Topicmappr-Usage-Guide) section for examples of common topic management tasks.
15 changes: 0 additions & 15 deletions cmd/topicmappr/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,6 @@ func initZooKeeper(cmd *cobra.Command) (kafkazk.Handler, error) {
return zk, nil
}

// ensureBrokerMetrics takes a map of reference brokers and
// a map of discovered broker metadata. Any non-missing brokers
// in the broker map must be present in the broker metadata map
// and have a non-true MetricsIncomplete value.
func ensureBrokerMetrics(cmd *cobra.Command, bm kafkazk.BrokerMap, bmm kafkazk.BrokerMetaMap) {
for id, b := range bm {
// Missing brokers won't even
// be found in the brokerMeta.
if !b.Missing && id != 0 && bmm[id].MetricsIncomplete {
fmt.Printf("Metrics not found for broker %d\n", id)
os.Exit(1)
}
}
}

// containsRegex takes a topic name
// reference and returns whether or not
// it should be interpreted as regex.
Expand Down
15 changes: 15 additions & 0 deletions cmd/topicmappr/commands/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ func getBrokerMeta(cmd *cobra.Command, zk kafkazk.Handler, m bool) kafkazk.Broke
return brokerMeta
}

// ensureBrokerMetrics takes a map of reference brokers and
// a map of discovered broker metadata. Any non-missing brokers
// in the broker map must be present in the broker metadata map
// and have a non-true MetricsIncomplete value.
func ensureBrokerMetrics(cmd *cobra.Command, bm kafkazk.BrokerMap, bmm kafkazk.BrokerMetaMap) {
for id, b := range bm {
// Missing brokers won't even
// be found in the brokerMeta.
if !b.Missing && id != 0 && bmm[id].MetricsIncomplete {
fmt.Printf("Metrics not found for broker %d\n", id)
os.Exit(1)
}
}
}

// getPartitionMeta returns a map of topic, partition metadata
// persisted in ZooKeeper (via an external mechanism*). This is
// primarily partition size metrics data used for the storage
Expand Down
4 changes: 2 additions & 2 deletions cmd/topicmappr/commands/rebalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

var rebalanceCmd = &cobra.Command{
Use: "rebalance",
Short: "[BETA] Rebalance partition allotments among a set of topics and brokers",
Long: `[BETA] Rebalance partition allotments among a set of topics and brokers`,
Short: "Rebalance partition allotments among a set of topics and brokers",
Long: `Rebalance partition allotments among a set of topics and brokers`,
Run: rebalance,
}

Expand Down
7 changes: 5 additions & 2 deletions cmd/topicmappr/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"

"github.com/jamiealquiza/envy"
"github.com/spf13/cobra"
)

Expand All @@ -12,13 +13,15 @@ var rootCmd = &cobra.Command{
}

func Execute() {
envy.ParseCobra(rootCmd, envy.CobraConfig{Prefix: "TOPICMAPPR", Persistent: true, Recursive: false})

if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func init() {
rootCmd.PersistentFlags().String("zk-addr", "localhost:2181", "ZooKeeper connect string (for broker metadata or rebuild-topic lookups)")
rootCmd.PersistentFlags().String("zk-prefix", "", "ZooKeeper namespace prefix (for Kafka brokers)")
rootCmd.PersistentFlags().String("zk-addr", "localhost:2181", "ZooKeeper connect string")
rootCmd.PersistentFlags().String("zk-prefix", "", "ZooKeeper prefix (if Kafka is configured with a chroot path prefix)")
}

0 comments on commit 64d6d39

Please sign in to comment.