rename cli to client

This commit is contained in:
jaffee 2017-01-09 13:42:17 -06:00
parent e46ba6d485
commit 821b8d974f
6 changed files with 17 additions and 17 deletions

View file

@ -7,22 +7,22 @@ import (
)
func firstHostClient(hosts []string) (*pilosa.Client, error) {
cli, err := pilosa.NewClient(hosts[0])
client, err := pilosa.NewClient(hosts[0])
if err != nil {
return nil, err
}
return cli, nil
return client, nil
}
func roundRobinClient(hosts []string, agentNum int) (*pilosa.Client, error) {
cliNum := agentNum % len(hosts)
return firstHostClient(hosts[cliNum:])
clientNum := agentNum % len(hosts)
return firstHostClient(hosts[clientNum:])
}
// HasClient provides a reusable component for Benchmark implementations which
// provides the Init method, a ClientType argument and a cli internal variable.
type HasClient struct {
cli *pilosa.Client
client *pilosa.Client
ClientType string `json:"client-type"`
}
@ -33,10 +33,10 @@ func (h *HasClient) Init(hosts []string, agentNum int) error {
var err error
switch h.ClientType {
case "single":
h.cli, err = firstHostClient(hosts)
h.client, err = firstHostClient(hosts)
return err
case "round_robin":
h.cli, err = roundRobinClient(hosts, agentNum)
h.client, err = roundRobinClient(hosts, agentNum)
return err
default:
return fmt.Errorf("Unsupported ClientType: %v", h.ClientType)

View file

@ -69,7 +69,7 @@ func (b *DiagonalSetBits) ConsumeFlags(args []string) ([]string, error) {
// Run runs the DiagonalSetBits benchmark
func (b *DiagonalSetBits) Run(ctx context.Context, agentNum int) map[string]interface{} {
results := make(map[string]interface{})
if b.cli == nil {
if b.client == nil {
results["error"] = fmt.Errorf("No client set for DiagonalSetBits agent: %v", agentNum)
return results
}
@ -79,7 +79,7 @@ func (b *DiagonalSetBits) Run(ctx context.Context, agentNum int) map[string]inte
iterID := agentizeNum(n, b.Iterations, agentNum)
query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+iterID, b.BaseProfileID+iterID)
start = time.Now()
_, err := b.cli.ExecuteQuery(ctx, b.DB, query, true)
_, err := b.client.ExecuteQuery(ctx, b.DB, query, true)
if err != nil {
results["error"] = err
return results

View file

@ -63,7 +63,7 @@ func (b *MultiDBSetBits) ConsumeFlags(args []string) ([]string, error) {
// Run runs the MultiDBSetBits benchmark
func (b *MultiDBSetBits) Run(ctx context.Context, agentNum int) map[string]interface{} {
results := make(map[string]interface{})
if b.cli == nil {
if b.client == nil {
results["error"] = fmt.Errorf("No client set for MultiDBSetBits agent: %v", agentNum)
return results
}
@ -72,7 +72,7 @@ func (b *MultiDBSetBits) Run(ctx context.Context, agentNum int) map[string]inter
for n := 0; n < b.Iterations; n++ {
query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+n, b.BaseProfileID+n)
start = time.Now()
_, err := b.cli.ExecuteQuery(ctx, "multidb"+strconv.Itoa(agentNum), query, true)
_, err := b.client.ExecuteQuery(ctx, "multidb"+strconv.Itoa(agentNum), query, true)
if err != nil {
results["error"] = err
return results

View file

@ -86,7 +86,7 @@ func (b *RandomSetBits) Run(ctx context.Context, agentNum int) map[string]interf
src := rand.NewSource(b.Seed + int64(agentNum))
rng := rand.New(src)
results := make(map[string]interface{})
if b.cli == nil {
if b.client == nil {
results["error"] = fmt.Errorf("No client set for RandomSetBits agent: %v", agentNum)
return results
}
@ -97,7 +97,7 @@ func (b *RandomSetBits) Run(ctx context.Context, agentNum int) map[string]interf
profID := rng.Int63n(b.ProfileIDRange)
query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+bitmapID, b.BaseProfileID+profID)
start = time.Now()
b.cli.ExecuteQuery(ctx, b.DB, query, true)
b.client.ExecuteQuery(ctx, b.DB, query, true)
s.Add(time.Now().Sub(start))
}
AddToResults(s, results)

View file

@ -90,7 +90,7 @@ func (b *RandomQuery) ConsumeFlags(args []string) ([]string, error) {
func (b *RandomQuery) Run(ctx context.Context, agentNum int) map[string]interface{} {
seed := b.Seed + int64(agentNum)
results := make(map[string]interface{})
if b.cli == nil {
if b.client == nil {
results["error"] = fmt.Errorf("No client set for RandomQuery agent: %v", agentNum)
return results
}
@ -100,7 +100,7 @@ func (b *RandomQuery) Run(ctx context.Context, agentNum int) map[string]interfac
for n := 0; n < b.Iterations; n++ {
call := qm.Random(b.MaxN, b.MaxDepth, b.MaxArgs, uint64(b.BaseBitmapID), uint64(b.BitmapIDRange))
start = time.Now()
b.cli.ExecuteQuery(ctx, b.DBs[n%len(b.DBs)], call.String(), true)
b.client.ExecuteQuery(ctx, b.DBs[n%len(b.DBs)], call.String(), true)
s.Add(time.Now().Sub(start))
}
AddToResults(s, results)

View file

@ -137,7 +137,7 @@ func (b *ZipfSetBits) Init(hosts []string, agentNum int) error {
// Run runs the ZipfSetBits benchmark
func (b *ZipfSetBits) Run(ctx context.Context, agentNum int) map[string]interface{} {
results := make(map[string]interface{})
if b.cli == nil {
if b.client == nil {
results["error"] = fmt.Errorf("No client set for ZipfSetBits agent: %v", agentNum)
return results
}
@ -153,7 +153,7 @@ func (b *ZipfSetBits) Run(ctx context.Context, agentNum int) map[string]interfac
query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+int64(bitmapID), b.BaseProfileID+int64(profID))
start = time.Now()
_, err := b.cli.ExecuteQuery(ctx, b.DB, query, true)
_, err := b.client.ExecuteQuery(ctx, b.DB, query, true)
if err != nil {
results["error"] = fmt.Sprintf("Error executing query in zipf: %v", err)
return results