Beispiel #1
0
func main() {
	// Instruct Go to use all CPU cores.
	// TODO(spencer): this may be excessive and result in worse
	// performance. We should keep an eye on this as we move to
	// production workloads.
	numCPU := runtime.NumCPU()
	runtime.GOMAXPROCS(numCPU)
	rand.Seed(util.NewPseudoSeed())
	if log.V(1) {
		log.Infof("running using %d processor cores", numCPU)
	}

	if len(os.Args) == 1 {
		os.Args = append(os.Args, "help")
	}
	if err := cli.Run(os.Args[1:]); err != nil {
		fmt.Fprintf(os.Stderr, "Failed running command %q: %v\n", os.Args[1:], err)
		os.Exit(1)
	}
}
func TestGossipPeerings(t *testing.T) {
	l := localcluster.Create(*numNodes, stopper)
	l.Events = make(chan localcluster.Event, 10)
	l.Start()
	defer l.Stop()

	checkGossip(t, l, 20*time.Second, hasPeers(len(l.Nodes)))

	// Restart the first node.
	log.Infof("restarting node 0")
	if err := l.Nodes[0].Restart(5); err != nil {
		t.Fatal(err)
	}
	checkGossip(t, l, 20*time.Second, hasPeers(len(l.Nodes)))

	// Restart another node.
	rand.Seed(util.NewPseudoSeed())
	pickedNode := rand.Intn(len(l.Nodes)-1) + 1
	log.Infof("restarting node %d", pickedNode)
	if err := l.Nodes[pickedNode].Restart(5); err != nil {
		t.Fatal(err)
	}
	checkGossip(t, l, 20*time.Second, hasPeers(len(l.Nodes)))
}
Beispiel #3
0
func main() {
	// Instruct Go to use all CPU cores.
	// TODO(spencer): this may be excessive and result in worse
	// performance. We should keep an eye on this as we move to
	// production workloads.
	numCPU := runtime.NumCPU()
	runtime.GOMAXPROCS(numCPU)
	rand.Seed(util.NewPseudoSeed())
	log.V(1).Infof("running using %d processor cores", numCPU)

	c := commander.Commander{
		Name: "cockroach",
		Commands: []*commander.Command{
			cli.CmdInit,
			cli.CmdGetZone,
			cli.CmdLsZones,
			cli.CmdRmZone,
			cli.CmdSetZone,
			cli.CmdStart,
			{
				UsageLine: "listparams",
				Short:     "list all available parameters and their default values",
				Long: `
List all available parameters and their default values.
Note that parameter parsing stops after the first non-
option after the command name. Hence, the options need
to precede any additional arguments,

  cockroach <command> [options] [arguments].`,
				Run: func(cmd *commander.Command, args []string) {
					flag.CommandLine.PrintDefaults()
				},
			},
			{
				UsageLine: "version",
				Short:     "output version information",
				Long: `
Output build version information.
`,
				Run: func(cmd *commander.Command, args []string) {
					info := util.GetBuildInfo()
					w := &tabwriter.Writer{}
					w.Init(os.Stdout, 2, 1, 2, ' ', 0)
					fmt.Fprintf(w, "Build Vers:  %s\n", info.Vers)
					fmt.Fprintf(w, "Build Tag:   %s\n", info.Tag)
					fmt.Fprintf(w, "Build Time:  %s\n", info.Time)
					fmt.Fprintf(w, "Build Deps:\n\t%s\n",
						strings.Replace(strings.Replace(info.Deps, " ", "\n\t", -1), ":", "\t", -1))
					w.Flush()
				},
			},
		},
	}

	cli.InitFlags(cli.Context)

	if len(os.Args) == 1 {
		os.Args = append(os.Args, "help")
	}
	if err := c.Run(os.Args[1:]); err != nil {
		log.Fatalf("Failed running command %q: %v\n", os.Args[1:], err)
	}
}