Пример #1
0
func handleStart() error {
	id := stripArgument()
	if id == "" {
		return errors.New("No task id supplied to start")
	}

	var api string
	var timeout int64

	flag.StringVar(&api, "api", "", "API host:port for advertizing.")
	flag.Int64Var(&timeout, "timeout", 30, "Timeout in seconds to wait until the task receives Running status.")

	ParseFlags("start")

	if err := resolveApi(api); err != nil {
		return err
	}

	request := framework.NewApiRequest(framework.Config.Api + "/api/start")
	request.PutString("id", id)
	request.PutInt("timeout", timeout)

	response := request.Get()
	fmt.Println(response.Message)

	return nil
}
Пример #2
0
func handleAddConsumer() error {
	id := stripArgument()
	if id == "" {
		return errors.New("No task id supplied to add")
	}
	var (
		api = flag.String("api", "", "API host:port")
		cpu = flag.Float64("cpu", 0.1, "CPUs per task")
		mem = flag.Float64("mem", 128, "Mem per task")
	)
	ParseFlags("add")
	if err := resolveApi(*api); err != nil {
		return err
	}

	if *executor == "" {
		return errors.New("Executor name required")
	}

	request := framework.NewApiRequest(framework.Config.Api + "/api/add")
	request.PutString("type", framework.TaskTypeConsumer)
	request.PutString("id", id)
	request.PutFloat("cpu", *cpu)
	request.PutFloat("mem", *mem)
	request.PutString("executor", *executor)

	response := request.Get()

	fmt.Println(response.Message)

	return nil
}
Пример #3
0
func handleStatus() error {
	var api string
	flag.StringVar(&api, "api", "", "Binding host:port for http/artifact server. Optional if SM_API env is set.")

	ParseFlags("status")
	if err := resolveApi(api); err != nil {
		return err
	}
	response := framework.NewApiRequest(framework.Config.Api + "/api/status").Get()
	fmt.Println(response.Message)
	return nil
}
Пример #4
0
func handleRemove() error {
	id := stripArgument()
	if id == "" {
		return errors.New("No task id supplied to remove")
	}

	var api string
	flag.StringVar(&api, "api", "", "API host:port for advertizing.")
	ParseFlags("remove")

	if err := resolveApi(api); err != nil {
		return err
	}

	request := framework.NewApiRequest(framework.Config.Api + "/api/remove")
	request.PutString("id", id)
	response := request.Get()

	fmt.Println(response.Message)

	return nil
}
Пример #5
0
func handleAddMirrorMaker() error {
	id := stripArgument()
	if id == "" {
		return errors.New("No task id supplied to add")
	}

	var api string
	var cpu float64
	var mem float64
	var constraints string

	flag.StringVar(&api, "api", "", "API host:port for advertizing.")
	flag.Float64Var(&cpu, "cpu", 0.5, "CPUs per task.")
	flag.Float64Var(&mem, "mem", 512, "Mem per task.")
	flag.StringVar(&constraints, "constraints", "", "Constraints (hostname=like:^master$,rack=like:^1.*$).")
	ParseFlags("add")

	if err := resolveApi(api); err != nil {
		return err
	}

	if *executor == "" {
		return errors.New("Executor name required")
	}

	request := framework.NewApiRequest(framework.Config.Api + "/api/add")
	request.PutString("type", framework.TaskTypeMirrorMaker)
	request.PutString("id", id)
	request.PutFloat("cpu", cpu)
	request.PutFloat("mem", mem)
	request.PutString("constraints", constraints)
	request.PutString("executor", *executor)

	response := request.Get()

	fmt.Println(response.Message)

	return nil
}
Пример #6
0
func handleUpdate() error {
	id := stripArgument()
	if id == "" {
		return errors.New("No task id supplied to start")
	}

	var api string
	var cpu float64
	var mem float64
	var whitelist string
	var blacklist string
	var consumerConfig consumerConfigs
	var producerConfig string
	var numProducers int64
	var numStreams int64
	preservePartitions := new(boolFlag)
	preserveOrder := new(boolFlag)
	var prefix string
	var channelSize int64
	var constraints string
	var metricsTopic string
	var options string

	flag.StringVar(&api, "api", "", "API host:port for advertizing.")
	flag.Float64Var(&cpu, "cpu", math.SmallestNonzeroFloat64, "CPUs per task.")
	flag.Float64Var(&mem, "mem", math.SmallestNonzeroFloat64, "Mem per task.")
	flag.StringVar(&whitelist, "whitelist", "", "Regex pattern for whitelist. Providing both whitelist and blacklist is an error.")
	flag.StringVar(&blacklist, "blacklist", "", "Regex pattern for blacklist. Providing both whitelist and blacklist is an error.")
	flag.StringVar(&producerConfig, "producer.config", "", "Producer config url or file name.")
	flag.Var(&consumerConfig, "consumer.config", "Consumer config url or file name.")
	flag.Int64Var(&numProducers, "num.producers", math.MinInt64, "Number of producers.")
	flag.Int64Var(&numStreams, "num.streams", math.MinInt64, "Number of consumption streams.")
	flag.Var(preservePartitions, "preserve.partitions", "Preserve partition number. E.g. if message was read from partition 5 it'll be written to partition 5.")
	flag.Var(preserveOrder, "preserve.order", "E.g. message sequence 1, 2, 3, 4, 5 will remain 1, 2, 3, 4, 5 in destination topic.")
	flag.StringVar(&prefix, "prefix", "", "Destination topic prefix.")
	flag.Int64Var(&channelSize, "queue.size", math.MinInt64, "Maximum number of messages that are buffered between the consumer and producer.")
	flag.StringVar(&constraints, "constraints", "", "Constraints (hostname=like:^master$,rack=like:^1.*$).")
	flag.StringVar(&metricsTopic, "metrics.topic", "", "Kafka topic to produce mirror maker consumer metrics to. Optional and turned off by default.")
	flag.StringVar(&options, "options", "", "Additional options")
	ParseFlags("update")

	if err := resolveApi(api); err != nil {
		return err
	}

	request := framework.NewApiRequest(framework.Config.Api + "/api/update")
	request.PutString("id", id)
	request.PutFloat("cpu", cpu)
	request.PutFloat("mem", mem)
	request.PutString("constraints", constraints)
	request.PutString("whitelist", whitelist)
	request.PutString("blacklist", blacklist)
	request.PutString("producer.config", producerConfig)
	request.PutStringSlice("consumer.config", consumerConfig)
	request.PutInt("num.producers", numProducers)
	request.PutInt("num.streams", numStreams)
	if preservePartitions.isSet {
		request.PutBool("preserve.partitions", preservePartitions.value)
	}
	if preserveOrder.isSet {
		request.PutBool("preserve.order", preserveOrder.value)
	}
	request.PutString("prefix", prefix)
	request.PutInt("queue.size", channelSize)
	request.PutString("metrics.topic", metricsTopic)
	request.PutString("options", options)

	response := request.Get()

	fmt.Println(response.Message)

	return nil
}