add more debug info.

pull/17/head
John Shahid 2013-10-31 14:21:26 -04:00
parent 8064b74309
commit 7196dac32a
1 changed files with 6 additions and 3 deletions

View File

@ -45,6 +45,7 @@ var registeredCommands bool
// Creates a new server.
func NewRaftServer(path string, host string, port int, clusterConfig *ClusterConfiguration) *RaftServer {
if !registeredCommands {
raft.SetLogLevel(raft.Trace)
registeredCommands = true
raft.RegisterCommand(&AddPotentialServerCommand{})
raft.RegisterCommand(&UpdateServerStateCommand{})
@ -93,7 +94,11 @@ func (s *RaftServer) leaderConnectString() (string, bool) {
func (s *RaftServer) doOrProxyCommand(command raft.Command, commandType string) (interface{}, error) {
if s.raftServer.State() == raft.Leader {
return s.raftServer.Do(command)
value, err := s.raftServer.Do(command)
if err != nil {
fmt.Printf("Error: Cannot run command %#v. %s", command, err)
}
return value, err
} else {
if leader, ok := s.leaderConnectString(); !ok {
return nil, errors.New("Couldn't connect to the cluster leader...")
@ -178,8 +183,6 @@ func (s *RaftServer) startRaft(potentialLeaders []string, retryUntilJoin bool) {
log.Fatal(err)
}
s.raftServer.SetElectionTimeout(300 * time.Millisecond)
transporter.Install(s.raftServer, s)
s.raftServer.Start()