Exemple #1
0
func handleScheduler() error {
	var api string
	var logLevel string

	flag.StringVar(&framework.Config.Master, "master", "", "Mesos Master addresses.")
	flag.StringVar(&api, "api", "", "API host:port for advertizing.")
	flag.StringVar(&framework.Config.User, "user", "", "Mesos user. Defaults to current system user")
	flag.StringVar(&framework.Config.Storage, "storage", "file:go_kafka_client_mesos.json", "Storage for cluster state. Examples: file:go_kafka_client_mesos.json; zk:master:2181/go-mesos")
	flag.StringVar(&logLevel, "log.level", framework.Config.LogLevel, "Log level. trace|debug|info|warn|error|critical. Defaults to info.")
	flag.StringVar(&framework.Config.FrameworkName, "framework.name", framework.Config.FrameworkName, "Framework name.")
	flag.StringVar(&framework.Config.FrameworkRole, "framework.role", framework.Config.FrameworkRole, "Framework role.")
	flag.DurationVar(&framework.Config.FrameworkTimeout, "framework.timeout", framework.Config.FrameworkTimeout, "Framework failover timeout.")

	ParseFlags("scheduler")

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

	if err := framework.InitLogging(logLevel); err != nil {
		return err
	}

	if framework.Config.Master == "" {
		return errors.New("--master flag is required.")
	}

	return framework.NewScheduler().Start()
}
func main() {
	flag.Parse()
	err := framework.InitLogging(*logLevel)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	var taskExecutor executor.Executor
	switch *executorType {
	case framework.TaskTypeMirrorMaker:
		taskExecutor = framework.NewMirrorMakerExecutor()
	default:
		{
			framework.Logger.Errorf("Unknown executor type %s", *executorType)
			os.Exit(1)
		}
	}

	driverConfig := executor.DriverConfig{
		Executor: taskExecutor,
	}

	driver, err := executor.NewMesosExecutorDriver(driverConfig)
	if err != nil {
		framework.Logger.Error(err)
		os.Exit(1)
	}

	_, err = driver.Start()
	if err != nil {
		framework.Logger.Error(err)
		os.Exit(1)
	}
	driver.Join()
}