func EntryPoint(p []int, trust chan int) (chan int, chan int, chan int) {
	process = p
	ownProcess, _ = connector.GetOwnProcess()
	handlTrustChan = trust
	//Take the process and make one map, suspect
	for pr := range process {
		proc := process[pr]
		pSuspect[proc] = false
	}
	leader = ownProcess
	go auxiliar()

	return handlSuspectChan, handlRecoveryChan, handlTrustLeaderChan

}
func EntryPoint(d int, p []int) (chan int, chan int) {
	delay = d
	actualTimeout = d
	ownProcess, _ = connector.GetOwnProcess()
	process = p

	//Take the process and make 2 maps, alive and suspect
	for aux := range p {
		proc := process[aux]
		pAlive[proc] = true
		pSuspect[proc] = false

	}

	go startTimer(actualTimeout)
	return handlHBReplyChan, handlHBRequChan
}
Beispiel #3
0
func main() {
	//Entry point of the application
	process = connector.GetProcesses()
	ownProcess, _ = connector.GetOwnProcess()
	//Create the connection
	go createServer()

	//Take the ids of all the processess
	keys := make([]int, len(process))
	i := 0
	for k, _ := range process {
		keys[i] = k
		i++
	}
	//Call paxos and assign the channels
	handlTrustChan, inPrepChan, handlPromiseLeaderChan, inAcceptChan, learnChan, valueChan = paxosMain.EntryPoint(debug)
	//Launch Leader Election
	handlSuspectChan, handlRecoveryChan, handlTrustLeaderChan = leaderElection.EntryPoint(keys, handlTrustChan)
	//Launch Failure Detector
	handlHBReplyChan, handlHBRequChan = failureDetector.EntryPoint(delay, keys)

	<-endChan

}
Beispiel #4
0
func isLeader() bool {
	me, _ := connector.GetOwnProcess()
	leader := leaderElection.GetLeader()
	return me == leader
}