Ejemplo n.º 1
0
//Join will create a Chord node with a file system application and join to an existing DHT
//specified by the address addr. It returns the resulting FileSystem struct.
//The input home indicates the directory that will store distributed documents.
//The input myaddr specifies which address the application will listen on.
func Join(home string, myaddr string, addr string) *FileSystem {
	var err error
	me := new(FileSystem)
	me.node, err = chord.Join(myaddr, addr)
	if err != nil {
		checkError(err)
		return nil
	}
	fmt.Printf("here\n")

	me.home = home
	me.mirror = fmt.Sprintf("%s/mirrored", home)
	me.addr = myaddr

	err = os.MkdirAll(me.home, 0755)
	err = os.MkdirAll(me.mirror, 0755)
	fmt.Printf("made directory %s.\n", me.home)
	if err != nil {
		checkError(err)
		return nil
	}
	me.node.Register(code, me)
	//experimental
	me.malicious = false
	me.cache = make(map[string]bool)
	return me
}
Ejemplo n.º 2
0
func Join(home string, myaddr string, addr string) *LaviniaServer {
	me := new(LaviniaServer)
	me.node = chord.Join(myaddr, addr)
	if me.node == nil {
		return nil
	}

	me.fs = fs.Extend(home, addr, me.node)
	if me.fs == nil {
		return nil
	}

	me.storage = fmt.Sprintf("%s/pmts", home)
	err := os.MkdirAll(me.storage, 0755)
	if err != nil {
		checkError(err)
		return nil
	}

	me.node.Register(code, me)
	return me
}