Merge pull request #6721 from sinsharat/etcd_runner_remove_unused_code

etcd-runner: remove unused code and change name for randClient
This commit is contained in:
Xiang Li 2016-10-25 10:01:20 -07:00 committed by GitHub
commit 18739e766a

View File

@ -72,7 +72,7 @@ func runElection(eps []string, rounds int) {
observedLeader := "" observedLeader := ""
validateWaiters := 0 validateWaiters := 0
rcs[i].c = randClient(eps) rcs[i].c = newClient(eps)
var ( var (
s *concurrency.Session s *concurrency.Session
err error err error
@ -143,7 +143,7 @@ func runElection(eps []string, rounds int) {
} }
func runLeaseRenewer(eps []string) { func runLeaseRenewer(eps []string) {
c := randClient(eps) c := newClient(eps)
ctx := context.Background() ctx := context.Background()
for { for {
@ -189,7 +189,7 @@ func runRacer(eps []string, round int) {
ctx := context.Background() ctx := context.Background()
cnt := 0 cnt := 0
for i := range rcs { for i := range rcs {
rcs[i].c = randClient(eps) rcs[i].c = newClient(eps)
var ( var (
s *concurrency.Session s *concurrency.Session
err error err error
@ -246,7 +246,7 @@ func performWatchOnPrefixes(ctx context.Context, eps []string, round int) {
) )
// create client for performing get and put operations // create client for performing get and put operations
client := randClient(eps) client := newClient(eps)
defer client.Close() defer client.Close()
// get revision using get request // get revision using get request
@ -304,7 +304,7 @@ func performWatchOnPrefixes(ctx context.Context, eps []string, round int) {
go func(prefix string) { go func(prefix string) {
defer wg.Done() defer wg.Done()
rc := randClient(eps) rc := newClient(eps)
rcs = append(rcs, rc) rcs = append(rcs, rc)
wc := rc.Watch(ctxc, prefix, clientv3.WithPrefix(), clientv3.WithRev(revision)) wc := rc.Watch(ctxc, prefix, clientv3.WithPrefix(), clientv3.WithRev(revision))
@ -402,15 +402,7 @@ func generateRandomKey(strlen uint) string {
return key return key
} }
func randClient(eps []string) *clientv3.Client { func newClient(eps []string) *clientv3.Client {
neps := make([]string, len(eps))
copy(neps, eps)
for i := range neps {
j := rand.Intn(i + 1)
neps[i], neps[j] = neps[j], neps[i]
}
c, err := clientv3.New(clientv3.Config{ c, err := clientv3.New(clientv3.Config{
Endpoints: eps, Endpoints: eps,
DialTimeout: 5 * time.Second, DialTimeout: 5 * time.Second,