Пример #1
0
func runDataserver(args []string) {
	cfg := &conf.DSConfig{}
	err := cfg.ReadConfig(args[0])
	if err != nil {
		usage(err)
		return
	}
	services, err := integration.NewClient(cfg.NameAddr, cfg.LeaseAddr, 1)
	if err != nil {
		usage(err)
		return
	}
	ds, err := dataserver.NewDataServer(cfg.VolumeRoots, cfg.DataClientBindAddr, cfg.NameDataBindAddr, cfg.WebBindAddr, services.Names, services.Datas)
	if err != nil {
		usage(err)
		return
	}
	ds.Start()
	if len(args) > 1 {
		mountPoint := args[1]

		// start client
		client, err := newMountedClient(services.Leases, services.Names, services.Datas, mountPoint)
		if err != nil {
			usage(err)
			return
		}
		client.Loop()
		ds.Close()
	}
	ds.WaitClosed()
}
Пример #2
0
func singlenode(args []string) {
	numDNs, err := strconv.Atoi(args[0])
	if err != nil {
		usage(err)
		return
	}
	volsPerDn, err := strconv.Atoi(args[1])
	if err != nil {
		usage(err)
		return
	}
	replicationFactor, err := strconv.Atoi(args[2])
	if err != nil {
		usage(err)
		return
	}
	baseDir := args[3]
	mountPoint := args[4]
	nncfg, dscfg, err := conf.NewConfSet2(numDNs, volsPerDn, uint32(replicationFactor), baseDir)
	if err != nil {
		usage(err)
		return
	}
	cluster, err := integration.NewSingleNodeCluster(nncfg, dscfg, true)
	if err != nil {
		usage(err)
		return
	}
	cluster.Start()
	client, err := newMountedClient(cluster.Leases, cluster.Names, cluster.Datas, mountPoint)
	client.Loop()
	cluster.Close()
}