Skip to content

Commit

Permalink
*: add debug
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Sep 21, 2017
1 parent 260eae2 commit c15b9f1
Show file tree
Hide file tree
Showing 24 changed files with 15 additions and 3,783 deletions.
7 changes: 7 additions & 0 deletions clientv3/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package clientv3

import (
"context"
"fmt"
"net/url"
"strings"
"sync"
Expand Down Expand Up @@ -291,27 +292,33 @@ func (b *simpleBalancer) up(addr grpc.Address) (func(error), bool) {
b.mu.Lock()
defer b.mu.Unlock()

fmt.Println("simpleBalancer up:", addr)
// gRPC might call Up after it called Close. We add this check
// to "fix" it up at application layer. Otherwise, will panic
// if b.upc is already closed.
if b.closed {
fmt.Println("simpleBalancer up closed:", addr, b.closed)
return func(err error) {}, false
}
// gRPC might call Up on a stale address.
// Prevent updating pinAddr with a stale address.
if !hasAddr(b.addrs, addr.Addr) {
fmt.Println("simpleBalancer up !hasAddr:", addr, "/", b.addrs)
return func(err error) {}, false
}
if b.pinAddr != "" {
fmt.Println("simpleBalancer up b.pinAddr != '':", addr, "/", b.pinAddr)
return func(err error) {}, false
}
// notify waiting Get()s and pin first connected address
close(b.upc)
b.downc = make(chan struct{})
b.pinAddr = addr.Addr
fmt.Println("simpleBalancer up pinned:", addr)
// notify client that a connection is up
b.readyOnce.Do(func() { close(b.readyc) })
return func(err error) {
fmt.Println("simpleBalancer up error:", addr, err)
b.mu.Lock()
b.upc = make(chan struct{})
close(b.downc)
Expand Down
2 changes: 2 additions & 0 deletions clientv3/health_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package clientv3

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -174,6 +175,7 @@ func (hb *healthBalancer) mayPin(addr grpc.Address) bool {
skip := len(hb.addrs) == 1 || len(hb.unhealthy) == 0
_, bad := hb.unhealthy[addr.Addr]
hb.mu.RUnlock()
fmt.Println("mayPin:", addr, skip, bad)
if skip || !bad {
return true
}
Expand Down
163 changes: 0 additions & 163 deletions e2e/ctl_v3_alarm_test.go

This file was deleted.

Loading

0 comments on commit c15b9f1

Please sign in to comment.