Skip to content

Commit

Permalink
Add vtrpc.ErrorCodes to TabletErrors everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
aaijazi committed Aug 26, 2015
1 parent 516b561 commit 7a998a4
Show file tree
Hide file tree
Showing 47 changed files with 398 additions and 538 deletions.
6 changes: 3 additions & 3 deletions go/vt/proto/automationservice/automationservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions go/vt/proto/binlogservice/binlogservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions go/vt/proto/mysqlctl/mysqlctl.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions go/vt/proto/queryservice/queryservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions go/vt/proto/tabletmanagerservice/tabletmanagerservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions go/vt/proto/vtctlservice/vtctlservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions go/vt/proto/vtgateservice/vtgateservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 50 additions & 33 deletions go/vt/proto/vtrpc/vtrpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions go/vt/proto/vtworkerservice/vtworkerservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions go/vt/tabletserver/cache_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/youtube/vitess/go/pools"
"github.com/youtube/vitess/go/stats"
"github.com/youtube/vitess/go/sync2"
"github.com/youtube/vitess/go/vt/proto/vtrpc"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -100,10 +101,10 @@ func (cp *CachePool) Open() {
cp.mu.Lock()
defer cp.mu.Unlock()
if cp.pool != nil {
panic(NewTabletError(ErrFatal, "rowcache is already open"))
panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "rowcache is already open"))
}
if cp.rowCacheConfig.Binary == "" {
panic(NewTabletError(ErrFatal, "rowcache binary not specified"))
panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "rowcache binary not specified"))
}
cp.socket = generateFilename(cp.rowCacheConfig.Socket)
cp.startCacheService()
Expand All @@ -127,16 +128,16 @@ func generateFilename(hint string) string {
dir, base := path.Split(hint)
f, err := ioutil.TempFile(dir, base)
if err != nil {
panic(NewTabletError(ErrFatal, "error creating socket file: %v", err))
panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "error creating socket file: %v", err))
}
name := f.Name()
err = f.Close()
if err != nil {
panic(NewTabletError(ErrFatal, "error closing socket file: %v", err))
panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "error closing socket file: %v", err))
}
err = os.Remove(name)
if err != nil {
panic(NewTabletError(ErrFatal, "error removing socket file: %v", err))
panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "error removing socket file: %v", err))
}
log.Infof("sock filename: %v", name)
return name
Expand All @@ -146,7 +147,7 @@ func (cp *CachePool) startCacheService() {
commandLine := cp.rowCacheConfig.GetSubprocessFlags(cp.socket)
cp.cmd = exec.Command(commandLine[0], commandLine[1:]...)
if err := cp.cmd.Start(); err != nil {
panic(NewTabletError(ErrFatal, "can't start memcache: %v", err))
panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "can't start memcache: %v", err))
}
attempts := 0
for {
Expand All @@ -168,7 +169,7 @@ func (cp *CachePool) startCacheService() {
continue
}
if _, err = c.Set("health", 0, 0, []byte("ok")); err != nil {
panic(NewTabletError(ErrFatal, "can't communicate with cache service: %v", err))
panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "can't communicate with cache service: %v", err))
}
c.Close()
break
Expand Down Expand Up @@ -224,11 +225,11 @@ func (cp *CachePool) getPool() *pools.ResourcePool {
func (cp *CachePool) Get(ctx context.Context) cacheservice.CacheService {
pool := cp.getPool()
if pool == nil {
panic(NewTabletError(ErrFatal, "cache pool is not open"))
panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "cache pool is not open"))
}
r, err := pool.Get(ctx)
if err != nil {
panic(NewTabletErrorSql(ErrFatal, err))
panic(NewTabletErrorSql(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, err))
}
return r.(cacheservice.CacheService)
}
Expand Down
Loading

0 comments on commit 7a998a4

Please sign in to comment.