func main() { config := parseAndValidateArgs() mirrorMaker := kafka.NewMirrorMaker(config) go mirrorMaker.Start() ctrlc := make(chan os.Signal, 1) signal.Notify(ctrlc, os.Interrupt) <-ctrlc mirrorMaker.Stop() }
func (e *MirrorMakerExecutor) startMirrorMaker() { consumerConfigs := make([]string, 0) rawConsumerConfigs := strings.Split(e.config["consumer.config"], ",") for _, config := range rawConsumerConfigs { resourceTokens := strings.Split(config, "/") consumerConfigs = append(consumerConfigs, resourceTokens[len(resourceTokens)-1]) } rawProducerConfig := strings.Split(e.config["producer.config"], "/") producerConfig := rawProducerConfig[len(rawProducerConfig)-1] mmConfig := kafka.NewMirrorMakerConfig() e.config.SetIntConfig("num.producers", &mmConfig.NumProducers) e.config.SetIntConfig("num.streams", &mmConfig.NumStreams) e.config.SetStringConfig("prefix", &mmConfig.TopicPrefix) e.config.SetIntConfig("queue.size", &mmConfig.ChannelSize) e.config.SetStringConfig("whitelist", &mmConfig.Whitelist) e.config.SetStringConfig("blacklist", &mmConfig.Blacklist) mmConfig.ProducerConfig = producerConfig mmConfig.ConsumerConfigs = consumerConfigs e.mirrorMaker = kafka.NewMirrorMaker(mmConfig) e.mirrorMaker.Start() }