This commit is contained in:
Liang Guo 2014-07-29 15:39:07 -07:00
Родитель 2df02b4d37
Коммит 8e09f2f23c
2 изменённых файлов: 14 добавлений и 12 удалений

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

@ -152,6 +152,7 @@ func NewResilientSrvTopoServer(base topo.Server, counterName string) *ResilientS
}
}
// GetSrvKeyspaceNames returns all keyspace names for the given cell.
func (server *ResilientSrvTopoServer) GetSrvKeyspaceNames(context context.Context, cell string) ([]string, error) {
server.counts.Add(queryCategory, 1)
@ -199,6 +200,7 @@ func (server *ResilientSrvTopoServer) GetSrvKeyspaceNames(context context.Contex
return result, err
}
// GetSrvKeyspace returns SrvKeyspace object for the given cell and keyspace.
func (server *ResilientSrvTopoServer) GetSrvKeyspace(context context.Context, cell, keyspace string) (*topo.SrvKeyspace, error) {
server.counts.Add(queryCategory, 1)
@ -247,6 +249,7 @@ func (server *ResilientSrvTopoServer) GetSrvKeyspace(context context.Context, ce
return result, err
}
// GetEndPoints return all endpoints for the given cell, keyspace, shard, and tablet type.
func (server *ResilientSrvTopoServer) GetEndPoints(context context.Context, cell, keyspace, shard string, tabletType topo.TabletType) (*topo.EndPoints, error) {
server.counts.Add(queryCategory, 1)

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

@ -344,16 +344,15 @@ func (ft *fakeTopoRemoteMaster) GetEndPoints(cell, keyspace, shard string, table
},
},
}, nil
} else {
return &topo.EndPoints{
Entries: []topo.EndPoint{
topo.EndPoint{
Uid: 1,
Health: nil,
},
},
}, nil
}
return &topo.EndPoints{
Entries: []topo.EndPoint{
topo.EndPoint{
Uid: 1,
Health: nil,
},
},
}, nil
}
// TestRemoteMaster will test getting endpoints for remote master.
@ -431,7 +430,7 @@ func TestCachedErrors(t *testing.T) {
t.Fatalf("First GetSrvKeyspace didn't return an error")
}
if ft.callCount != 1 {
t.Fatalf("GetSrvKeyspace didn't get called 1 but %u times", ft.callCount)
t.Fatalf("GetSrvKeyspace didn't get called 1 but %v times", ft.callCount)
}
// ask again, should get an error and use cache
@ -440,7 +439,7 @@ func TestCachedErrors(t *testing.T) {
t.Fatalf("Second GetSrvKeyspace didn't return an error")
}
if ft.callCount != 1 {
t.Fatalf("GetSrvKeyspace was called again: %u times", ft.callCount)
t.Fatalf("GetSrvKeyspace was called again: %v times", ft.callCount)
}
// ask again after expired cache, should get an error
@ -450,6 +449,6 @@ func TestCachedErrors(t *testing.T) {
t.Fatalf("Third GetSrvKeyspace didn't return an error")
}
if ft.callCount != 2 {
t.Fatalf("GetSrvKeyspace was not called again: %u times", ft.callCount)
t.Fatalf("GetSrvKeyspace was not called again: %v times", ft.callCount)
}
}