func main() {
	flag.Parse()
	if *storageMasterNodePort == "" {
		if *portnum == 0 {
			*portnum = 9009
		}
		// Single node execution
		*storageMasterNodePort = fmt.Sprintf("localhost:%d", *portnum)
		if *numNodes == 0 {
			*numNodes = 1
			log.Println("Self-mastering, setting nodes to 1")
		}
	}

	l, e := net.Listen("tcp", fmt.Sprintf(":%d", *portnum))
	if e != nil {
		log.Fatal("listen error:", e)
	}
	_, listenport, _ := net.SplitHostPort(l.Addr().String())
	log.Println("Server starting on ", listenport)
	*portnum, _ = strconv.Atoi(listenport)
	ss := storageimpl.NewStorageserver(*storageMasterNodePort, *numNodes, *portnum, uint32(*nodeID))
	srpc := storagerpc.NewStorageRPC(ss)
	rpc.Register(srpc)
	rpc.HandleHTTP()
	http.Serve(l, nil)
}
Beispiel #2
0
// Initialize proxy and tribserver
func initTribserver(storage string, server string, myhostport string) net.Listener {
	// Start proxy
	l, err := net.Listen("tcp", server)
	if err != nil {
		log.Fatal("listen error:", err)
	}
	pc = proxycounter.NewProxyCounter(storage, server)
	if pc == nil {
		fmt.Println("Could not start proxy")
		return nil
	}
	srpc := storagerpc.NewStorageRPC(pc)
	rpc.Register(srpc)
	rpc.HandleHTTP()
	go http.Serve(l, nil)

	// Start tribserver
	ts = tribimpl.NewTribserver(server, myhostport)
	if ts == nil {
		fmt.Println("Could not start tribserver")
		return nil
	}
	rpc.Register(ts)
	return l
}
Beispiel #3
0
// Initialize proxy and libstore
func initLibstore(storage string, server string, myhostport string, flags int) net.Listener {
	// Start proxy
	l, err := net.Listen("tcp", server)
	if err != nil {
		log.Fatal("listen error:", err)
	}
	pc = proxycounter.NewProxyCounter(storage, server)
	if pc == nil {
		fmt.Println("Could not start proxy")
		return nil
	}
	srpc := storagerpc.NewStorageRPC(pc)
	rpc.Register(srpc)
	rpc.HandleHTTP()
	go http.Serve(l, nil)

	// Start libstore
	ls, err = libstore.NewLibstore(server, myhostport, flags)
	if ls == nil || err != nil {
		fmt.Println("Could not start libstore")
		return nil
	}
	return l
}