diff --git a/src/inquirer/inquirer.go b/src/inquirer/inquirer.go index 0d2bc8e7a..1929145d3 100644 --- a/src/inquirer/inquirer.go +++ b/src/inquirer/inquirer.go @@ -28,7 +28,7 @@ func callRater(key string) (reply string) { log.Printf("Got en error from rater: %v", err) } } - log.Print(fmt.Sprintf("Result: %v", reply)) + //log.Print(fmt.Sprintf("Result: %v", reply)) return } diff --git a/src/inquirer/registration/registration.go b/src/inquirer/registration/registration.go index 48949bdde..3413c5112 100644 --- a/src/inquirer/registration/registration.go +++ b/src/inquirer/registration/registration.go @@ -32,7 +32,10 @@ func (rl *RaterList) RegisterRater(clientAddress string, replay *byte) error { } rl.Clients[clientAddress] = client log.Print(fmt.Sprintf("Rater %v registered succesfully.", clientAddress)) - rl.balancer_mutex.Unlock() + if len(rl.Clients) == 1 { + // unlock the balancer on first rater + rl.balancer_mutex.Unlock() + } return nil } @@ -54,8 +57,8 @@ func (rl *RaterList) startBalance() { go func(){ for { rl.balancer_mutex.Lock() - for addr, client := range rl.Clients { - log.Printf("using server %s:", addr) + for _, client := range rl.Clients { + //log.Printf("using server %s:", addr) rl.Balancer <- client } if len(rl.Clients) != 0 { diff --git a/src/rater/rater.go b/src/rater/rater.go index 8f1ccc50e..3ea860bf5 100644 --- a/src/rater/rater.go +++ b/src/rater/rater.go @@ -29,10 +29,10 @@ func (s *Storage) Get(args string, reply *string) (err error) { func main() { flag.Parse() - //getter, err := NewKyotoStorage("storage.kch") - //defer getter.Close() - getter, err := NewRedisStorage("tcp:127.0.0.1:6379") + getter, err := NewKyotoStorage("storage.kch") defer getter.Close() + //getter, err := NewRedisStorage("tcp:127.0.0.1:6379") + //defer getter.Close() if err != nil { log.Printf("Cannot open storage file: %v", err) os.Exit(1) diff --git a/src/test.go b/src/test.go deleted file mode 100644 index c699cedb9..000000000 --- a/src/test.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "net/rpc" - "fmt" -) - - -func main(){ - client, _ := rpc.DialHTTPPath("tcp", "localhost:2000", "/rpc") - var reply string - for i:= 0; i < 5 * 10e6; i++ { - client.Call("Responder.Get", "test", &reply) - } - fmt.Println(reply) -} - - diff --git a/src/test/test b/src/test/test index 4a2609a9f..eb939d3b3 100755 Binary files a/src/test/test and b/src/test/test differ diff --git a/src/test/test.go b/src/test/test.go index cbc8ee007..e8696a2ea 100644 --- a/src/test/test.go +++ b/src/test/test.go @@ -9,8 +9,11 @@ import ( func main(){ client, _ := rpc.DialHTTPPath("tcp", "localhost:2000", "/rpc") var reply string - client.Call("Responder.Get", "test", &reply) - fmt.Println(reply) + i:= 0 + for ; i < 5 * 10e4; i++ { + client.Call("Responder.Get", "test", &reply) + } + fmt.Println(i, reply) }