Ejemplo n.º 1
0
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

}
Ejemplo n.º 2
0
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
}
Ejemplo n.º 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

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