Esempio n. 1
0
func cmdBenchmarkGet() error {

	if len(globalZkList) == 0 {
		return errors.NotValidf("zookeeper list")
	}

	if len(globalTopic) == 0 {
		return errors.NotValidf("Topic")
	}

	message := make(chan *go_kafka_client.Message)
	consumConfig := go_kafka_client.DefaultConsumerConfig()
	consumConfig.Groupid = "BenchmarkGroup-Test"
	consumConfig.AutoOffsetReset = go_kafka_client.SmallestOffset
	zkConfig := go_kafka_client.NewZookeeperConfig()
	zkConfig.ZookeeperConnect = strings.Split(globalZkList, ",")
	consumConfig.Coordinator = go_kafka_client.NewZookeeperCoordinator(zkConfig)

	consumConfig.Strategy =
		func(_ *go_kafka_client.Worker, msg *go_kafka_client.Message,
			id go_kafka_client.TaskId) go_kafka_client.WorkerResult {

			message <- msg
			return go_kafka_client.NewSuccessfulResult(id)
		}

	consumConfig.WorkerFailureCallback =
		func(_ *go_kafka_client.WorkerManager) go_kafka_client.FailedDecision {
			return go_kafka_client.CommitOffsetAndContinue
		}

	consumConfig.WorkerFailedAttemptCallback =
		func(_ *go_kafka_client.Task, _ go_kafka_client.WorkerResult) go_kafka_client.FailedDecision {
			return go_kafka_client.CommitOffsetAndContinue
		}

	consumer := go_kafka_client.NewConsumer(consumConfig)
	topicCountMap := make(map[string]int)
	topicCountMap[globalTopic] = 1
	go consumer.StartStatic(topicCountMap)

	time.Sleep(2e9)
	bt := utils.NewBenchmarkTester(globalConcurrentLevel, globalDuration, func(bt *utils.BenchmarkTester, index int) error {

		<-message
		return nil
	}, nil)

	return errors.Trace(bt.Run())
}
Esempio n. 2
0
func main() {
	flag.Parse()
	if *zkConnect == "" || *blueTopic == "" || *blueGroup == "" || *bluePattern == "" || *greenTopic == "" || *greenGroup == "" || *greenPattern == "" {
		flag.Usage()
		os.Exit(1)
	}
	blue := kafka.BlueGreenDeployment{*blueTopic, *bluePattern, *blueGroup}
	green := kafka.BlueGreenDeployment{*greenTopic, *greenPattern, *greenGroup}

	zkConfig := kafka.NewZookeeperConfig()
	zkConfig.ZookeeperConnect = []string{*zkConnect}

	zk := kafka.NewZookeeperCoordinator(zkConfig)
	zk.Connect()

	zk.RequestBlueGreenDeployment(blue, green)
}