예제 #1
0
func NewClient(nameAddr string, leaseAddr string, connsPerDn int) (*Client, error) {
	ret := &Client{}
	var err error
	ret.Leases, err = leaseserver.NewLeaseClient(leaseAddr)
	if err != nil {
		return ret, err
	}
	ret.Names, err = NewNameClient(nameAddr)
	if err != nil {
		return ret, nil
	}
	ret.Datas, err = dataserver.NewDataClient(ret.Names, connsPerDn)
	return ret, err
}
예제 #2
0
// TODO refactor to use NewConfSet
func NewSingleNodeCluster(nncfg *conf.NSConfig, ds []*conf.DSConfig, format bool) (*SingleNodeCluster, error) {
	cl := &SingleNodeCluster{}

	nls, err := NewNameServer(nncfg, format)
	if err != nil {
		return nil, err
	}
	cl.LeaseServer = nls.leaseServer
	cl.NameServer = nls.nameserver
	fmt.Println("Starting name client")
	cl.Names, err = NewNameClient(nncfg.NameBindAddr)
	if err != nil {
		return cl, err
	}
	fmt.Println("starting lease client")
	cl.Leases, err = leaseserver.NewLeaseClient(nncfg.LeaseBindAddr)
	if err != nil {
		return cl, err
	}
	// start data client
	dc, err := dataserver.NewDataClient(cl.Names, 1)
	if err != nil {
		return cl, fmt.Errorf("error building dataclient : %s", err.Error())
	}
	cl.Datas = dc
	// start dataservers
	cl.DataNodes = make([]*dataserver.DataServer, len(ds))
	for idx, dscfg := range ds {
		fmt.Println("Starting DS with cfg %+v\n", dscfg)
		cl.DataNodes[idx], err = dataserver.NewDataServer(dscfg.VolumeRoots, dscfg.DataClientBindAddr, dscfg.NameDataBindAddr, dscfg.WebBindAddr, cl.Names, dc)
		if err != nil {
			return cl, err
		}
	}
	return cl, nil
}