예제 #1
0
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {
	ss.dataLock.Lock()
	defer ss.dataLock.Unlock()
	if ss.nextNode == ss.numNodes {
		reply.Status = storagerpc.OK
		reply.Servers = ss.servers
	} else {
		reply.Status = storagerpc.NotReady
	}
	return nil
}
예제 #2
0
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {
	if ss.serverReady == false {
		reply.Status = storagerpc.NotReady
		reply.Servers = nil
	} else {
		reply.Status = storagerpc.OK
		reply.Servers = ss.nodeList
	}

	return nil
}
예제 #3
0
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {

	// Reply with OK and servers only if all have connected
	if ss.count == len(ss.servers) {
		reply.Status = storagerpc.OK
		reply.Servers = ss.servers
		return nil
	} else {
		reply.Status = storagerpc.NotReady
		return nil
	}
}
예제 #4
0
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {
	if ss.storageServerReady {
		reply.Status = storagerpc.OK
		tmp := make([]storagerpc.Node, len(ss.nodesList), cap(ss.nodesList))
		copy(tmp, ss.nodesList)
		reply.Servers = tmp
	} else {
		reply.Status = storagerpc.NotReady
	}

	return nil
}
예제 #5
0
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {
	//Will fix race condition after checkpoint

	//ss.registerMapLock.Lock()
	//defer ss.registerMapLock.Unlock()
	if ss.nodeCount == ss.numNodes {
		reply.Status = storagerpc.OK
		reply.Servers = ss.ring
	} else {
		reply.Status = storagerpc.NotReady
		reply.Servers = nil
	}
	return nil
}
예제 #6
0
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {
	if !ss.isMaster {
		return errors.New("I am not a master!")
	}
	ss.registerLocker.Lock()
	defer ss.registerLocker.Unlock()
	if ss.registerCnt == ss.numNodes {
		reply.Status = storagerpc.OK
		reply.Servers = ss.nodes
	} else {
		reply.Status = storagerpc.NotReady
		reply.Servers = ss.nodes
	}
	return nil
}
예제 #7
0
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {
	ss.serverMutex.Lock()
	defer ss.serverMutex.Unlock()
	if !ss.isMaster {
		return errors.New("Error is not master server")
	}
	if ss.isReady {
		reply.Servers = list2SliceNode(ss.serverList)
		reply.Status = storagerpc.OK
	} else {
		reply.Servers = nil
		reply.Status = storagerpc.NotReady
	}
	return nil
}
예제 #8
0
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {
	if !ss.isMaster {
		return errors.New("server is not a master")
	}

	ss.infoRWL.RLock()
	defer ss.infoRWL.RUnlock()

	if !ss.isReady {
		reply.Status = storagerpc.NotReady
		return nil
	}
	reply.Status = storagerpc.OK
	for k := range ss.servers {
		reply.Servers = append(reply.Servers, *ss.servers[k])
	}

	return nil
}
// GetServers retrieves a list of all connected nodes in the ring. It
// replies with status NotReady if not all nodes in the ring have joined.
/// TODO this funcion might not need the mutex at all.
func (ss *storageServer) GetServers(args *storagerpc.GetServersArgs, reply *storagerpc.GetServersReply) error {

	//	fmt.Println("GetServer Called")

	ss.rMutex.Lock()
	defer ss.rMutex.Unlock()

	if !ss.isMaster {
		fmt.Println("!!!!!!!!! The get server is called in the slave node!!!")
	}

	if len(ss.ring) == ss.totalNode {
		// if the connection is finished
		reply.Servers = ss.ring
		reply.Status = storagerpc.OK

		//fmt.Println(reply.Servers);
	} else {
		reply.Status = storagerpc.NotReady
	}

	return nil
}