Merge commit 'a64f1a634ff57f3902770cfc75bd10249d898245'

This commit is contained in:
Alain Jobart 2014-01-27 15:36:42 -08:00
Родитель 893a2afa0e a64f1a634f
Коммит dcd66642de
9 изменённых файлов: 32 добавлений и 38 удалений

Просмотреть файл

@ -8,11 +8,11 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"log"
"os" "os"
"strings" "strings"
"time" "time"
log "github.com/golang/glog"
"github.com/youtube/vitess/go/db" "github.com/youtube/vitess/go/db"
_ "github.com/youtube/vitess/go/vt/client2" _ "github.com/youtube/vitess/go/vt/client2"
_ "github.com/youtube/vitess/go/vt/client2/tablet" _ "github.com/youtube/vitess/go/vt/client2/tablet"
@ -105,7 +105,7 @@ func main() {
log.Fatalf("client error: %v", err) log.Fatalf("client error: %v", err)
} }
log.Println("Sending the query...") log.Infof("Sending the query...")
now := time.Now() now := time.Now()
// handle dml // handle dml
@ -126,7 +126,7 @@ func main() {
} }
n, err := r.RowsAffected() n, err := r.RowsAffected()
log.Println("Total time:", time.Now().Sub(now), "Rows affected:", n) log.Infof("Total time:", time.Now().Sub(now), "Rows affected:", n)
} else { } else {
// launch the query // launch the query
@ -147,7 +147,7 @@ func main() {
for _, field := range cols { for _, field := range cols {
line += "\t" + field line += "\t" + field
} }
log.Println(line) log.Infof(line)
} }
// get the rows // get the rows
@ -168,13 +168,13 @@ func main() {
line += "\t" line += "\t"
} }
} }
log.Println(line) log.Infof(line)
} }
rowIndex++ rowIndex++
} }
if err := r.Err(); err != nil { if err := r.Err(); err != nil {
log.Fatalf("Error %v\n", err) log.Fatalf("Error %v\n", err)
} }
log.Println("Total time:", time.Now().Sub(now), "Row count:", rowIndex) log.Infof("Total time:", time.Now().Sub(now), "Row count:", rowIndex)
} }
} }

Просмотреть файл

@ -4,7 +4,6 @@ import (
"archive/zip" "archive/zip"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log"
"os" "os"
"os/exec" "os/exec"
"os/signal" "os/signal"
@ -16,6 +15,7 @@ import (
"time" "time"
opts "code.google.com/p/opts-go" opts "code.google.com/p/opts-go"
log "github.com/golang/glog"
"github.com/youtube/vitess/go/terminal" "github.com/youtube/vitess/go/terminal"
"github.com/youtube/vitess/go/zk" "github.com/youtube/vitess/go/zk"
@ -131,7 +131,6 @@ func init() {
"watch": cmdWatch, "watch": cmdWatch,
"zip": cmdZip, "zip": cmdZip,
} }
log.SetFlags(0)
zconn = zk.NewMetaConn(false) zconn = zk.NewMetaConn(false)
} }
@ -259,7 +258,7 @@ func cmdElock(args []string) {
zconn.Delete(zkPath, -1) zconn.Delete(zkPath, -1)
return return
case event := <-watch: case event := <-watch:
log.Printf("elock: event %v: %v", zkPath, event) log.Infof("elock: event %v: %v", zkPath, event)
if !event.Ok() { if !event.Ok() {
//log.Fatalf("elock: error %v: %v", zkPath, event) //log.Fatalf("elock: error %v: %v", zkPath, event)
break watchLoop break watchLoop
@ -293,13 +292,13 @@ func cmdWatch(args []string) {
case <-sigRecv: case <-sigRecv:
return return
case event := <-eventChan: case event := <-eventChan:
log.Printf("watch: event %v: %v", event.Path, event) log.Infof("watch: event %v: %v", event.Path, event)
if event.Type == zookeeper.EVENT_CHANGED { if event.Type == zookeeper.EVENT_CHANGED {
data, stat, watch, err := zconn.GetW(event.Path) data, stat, watch, err := zconn.GetW(event.Path)
if err != nil { if err != nil {
log.Fatalf("ERROR: failed to watch %v", err) log.Fatalf("ERROR: failed to watch %v", err)
} }
log.Printf("watch: %v %v\n", event.Path, stat) log.Infof("watch: %v %v\n", event.Path, stat)
println(data) println(data)
go func() { go func() {
eventChan <- <-watch eventChan <- <-watch
@ -307,7 +306,7 @@ func cmdWatch(args []string) {
} else if event.State == zookeeper.STATE_CLOSED { } else if event.State == zookeeper.STATE_CLOSED {
return return
} else if event.Type == zookeeper.EVENT_DELETED { } else if event.Type == zookeeper.EVENT_DELETED {
log.Printf("watch: %v deleted\n", event.Path) log.Infof("watch: %v deleted\n", event.Path)
} else { } else {
// Most likely a session event - try t // Most likely a session event - try t
_, _, watch, err := zconn.GetW(event.Path) _, _, watch, err := zconn.GetW(event.Path)
@ -358,7 +357,7 @@ func cmdLs(args []string) {
if err != nil { if err != nil {
hasError = true hasError = true
if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) { if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) {
log.Printf("ls: cannot access %v: %v", zkPath, err) log.Warningf("ls: cannot access %v: %v", zkPath, err)
} }
} }
@ -384,7 +383,7 @@ func cmdLs(args []string) {
stat, err := zconn.Exists(localPath) stat, err := zconn.Exists(localPath)
if err != nil { if err != nil {
if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) { if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) {
log.Printf("ls: cannot access: %v: %v", localPath, err) log.Warningf("ls: cannot access: %v: %v", localPath, err)
} }
} else { } else {
stats[i] = stat stats[i] = stat
@ -521,7 +520,7 @@ func cmdRm(args []string) {
if err != nil { if err != nil {
if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) { if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) {
hasError = true hasError = true
log.Printf("rm: cannot delete %v: %v", zkPath, err) log.Warningf("rm: cannot delete %v: %v", zkPath, err)
} }
} }
} }
@ -552,7 +551,7 @@ func cmdCat(args []string) {
if err != nil { if err != nil {
hasError = true hasError = true
if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) { if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) {
log.Printf("cat: cannot access %v: %v", zkPath, err) log.Warningf("cat: cannot access %v: %v", zkPath, err)
} }
} else { } else {
if *longListing { if *longListing {
@ -578,7 +577,7 @@ func cmdEdit(args []string) {
data, stat, err := zconn.Get(zkPath) data, stat, err := zconn.Get(zkPath)
if err != nil { if err != nil {
if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) { if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) {
log.Printf("edit: cannot access %v: %v", zkPath, err) log.Warningf("edit: cannot access %v: %v", zkPath, err)
} }
os.Exit(1) os.Exit(1)
} }
@ -591,7 +590,7 @@ func cmdEdit(args []string) {
f.Close() f.Close()
} }
if err != nil { if err != nil {
log.Printf("edit: cannot write file %v", err) log.Warningf("edit: cannot write file %v", err)
os.Exit(1) os.Exit(1)
} }
@ -602,15 +601,13 @@ func cmdEdit(args []string) {
err = cmd.Run() err = cmd.Run()
if err != nil { if err != nil {
os.Remove(tmpPath) os.Remove(tmpPath)
log.Printf("edit: cannot start $EDITOR: %v", err) log.Fatalf("edit: cannot start $EDITOR: %v", err)
os.Exit(1)
} }
fileData, err := ioutil.ReadFile(tmpPath) fileData, err := ioutil.ReadFile(tmpPath)
if err != nil { if err != nil {
os.Remove(tmpPath) os.Remove(tmpPath)
log.Printf("edit: cannot read file %v", err) log.Fatalf("edit: cannot read file %v", err)
os.Exit(1)
} }
if string(fileData) != data { if string(fileData) != data {
@ -618,8 +615,7 @@ func cmdEdit(args []string) {
_, err = zconn.Set(zkPath, string(fileData), stat.Version()) _, err = zconn.Set(zkPath, string(fileData), stat.Version())
if err != nil { if err != nil {
os.Remove(tmpPath) os.Remove(tmpPath)
log.Printf("edit: cannot write zk file %v", err) log.Fatalf("edit: cannot write zk file %v", err)
os.Exit(1)
} }
} }
os.Remove(tmpPath) os.Remove(tmpPath)
@ -648,7 +644,7 @@ func cmdStat(args []string) {
if err != nil { if err != nil {
hasError = true hasError = true
if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) { if !*force || !zookeeper.IsError(err, zookeeper.ZNONODE) {
log.Printf("stat: cannot access %v: %v", zkPath, err) log.Warningf("stat: cannot access %v: %v", zkPath, err)
} }
continue continue
} }
@ -735,7 +731,7 @@ func cmdChmod(args []string) {
aclv, _, err := zconn.ACL(zkPath) aclv, _, err := zconn.ACL(zkPath)
if err != nil { if err != nil {
hasError = true hasError = true
log.Printf("chmod: cannot set access %v: %v", zkPath, err) log.Warningf("chmod: cannot set access %v: %v", zkPath, err)
continue continue
} }
if addPerms { if addPerms {
@ -746,7 +742,7 @@ func cmdChmod(args []string) {
err = zconn.SetACL(zkPath, aclv, -1) err = zconn.SetACL(zkPath, aclv, -1)
if err != nil { if err != nil {
hasError = true hasError = true
log.Printf("chmod: cannot set access %v: %v", zkPath, err) log.Warningf("chmod: cannot set access %v: %v", zkPath, err)
continue continue
} }
} }

Просмотреть файл

@ -7,11 +7,11 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"log"
"os" "os"
"sort" "sort"
"time" "time"
log "github.com/golang/glog"
"github.com/youtube/vitess/go/rpcplus" "github.com/youtube/vitess/go/rpcplus"
"github.com/youtube/vitess/go/rpcwrap/bsonrpc" "github.com/youtube/vitess/go/rpcwrap/bsonrpc"
"github.com/youtube/vitess/go/sync2" "github.com/youtube/vitess/go/sync2"

Просмотреть файл

@ -16,7 +16,7 @@ import (
"github.com/youtube/vitess/go/sync2" "github.com/youtube/vitess/go/sync2"
"github.com/youtube/vitess/go/testfiles" "github.com/youtube/vitess/go/testfiles"
"github.com/youtube/vitess/go/vt/mysqlctl/proto" "github.com/youtube/vitess/go/vt/binlog/proto"
) )
func TestPosParse(t *testing.T) { func TestPosParse(t *testing.T) {

Просмотреть файл

@ -8,7 +8,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/youtube/vitess/go/vt/mysqlctl/proto" "github.com/youtube/vitess/go/vt/binlog/proto"
) )
type eventErrorCase struct { type eventErrorCase struct {

Просмотреть файл

@ -8,8 +8,8 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/youtube/vitess/go/vt/binlog/proto"
"github.com/youtube/vitess/go/vt/key" "github.com/youtube/vitess/go/vt/key"
"github.com/youtube/vitess/go/vt/mysqlctl/proto"
) )
var testKeyRange = key.KeyRange{ var testKeyRange = key.KeyRange{

Просмотреть файл

@ -112,7 +112,7 @@ func TestWarning(t *testing.T) {
ioutil.ReadAll(out) ioutil.ReadAll(out)
mbl.Wait() mbl.Wait()
logutil.Flush() logutil.Flush()
warnbytes, err := ioutil.ReadFile(path.Join(os.TempDir(), "mysqlctl.test.WARNING")) warnbytes, err := ioutil.ReadFile(path.Join(os.TempDir(), "binlog.test.WARNING"))
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
@ -135,7 +135,7 @@ func TestError(t *testing.T) {
ioutil.ReadAll(out) ioutil.ReadAll(out)
mbl.Wait() mbl.Wait()
logutil.Flush() logutil.Flush()
warnbytes, err := ioutil.ReadFile(path.Join(os.TempDir(), "mysqlctl.test.ERROR")) warnbytes, err := ioutil.ReadFile(path.Join(os.TempDir(), "binlog.test.ERROR"))
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }

Просмотреть файл

@ -5,11 +5,9 @@
package binlog package binlog
import ( import (
//"fmt"
"testing" "testing"
// "github.com/youtube/vitess/go/vt/key" "github.com/youtube/vitess/go/vt/binlog/proto"
"github.com/youtube/vitess/go/vt/mysqlctl/proto"
) )
var testTables = []string{ var testTables = []string{

Просмотреть файл

@ -11,10 +11,10 @@ package tablet
import ( import (
"errors" "errors"
"fmt" "fmt"
"log"
"net/url" "net/url"
"strings" "strings"
log "github.com/golang/glog"
"github.com/youtube/vitess/go/db" "github.com/youtube/vitess/go/db"
mproto "github.com/youtube/vitess/go/mysql/proto" mproto "github.com/youtube/vitess/go/mysql/proto"
"github.com/youtube/vitess/go/rpcplus" "github.com/youtube/vitess/go/rpcplus"
@ -315,7 +315,7 @@ func (sr *StreamResult) Next() (row []interface{}) {
qr, ok := <-sr.sr qr, ok := <-sr.sr
if !ok { if !ok {
if sr.call.Error != nil { if sr.call.Error != nil {
log.Printf("vt: error reading the next value %v", sr.call.Error.Error()) log.Warningf("vt: error reading the next value %v", sr.call.Error.Error())
sr.err = sr.call.Error sr.err = sr.call.Error
} }
return nil return nil