Commit cdef120e authored by pfandzelter's avatar pfandzelter
Browse files

add the keygroup info api

parent 206ae7d5
Pipeline #64635 passed with stages
in 17 minutes and 40 seconds
......@@ -221,8 +221,8 @@ func (c *Client) append(ctx context.Context, keygroup string, data string) (*api
return res, err
}
func (c *Client) getKeygroupReplica(ctx context.Context, keygroup string) (*api.GetKeygroupReplicaResponse, error) {
res, err := c.Client.GetKeygroupReplica(ctx, &api.GetKeygroupReplicaRequest{Keygroup: keygroup})
func (c *Client) getKeygroupReplica(ctx context.Context, keygroup string) (*api.GetKeygroupInfoResponse, error) {
res, err := c.Client.GetKeygroupInfo(ctx, &api.GetKeygroupInfoRequest{Keygroup: keygroup})
return res, err
}
......
......@@ -337,10 +337,10 @@ func (s *Server) GetAllReplica(ctx context.Context, _ *middleware.GetAllReplicaR
return &middleware.GetAllReplicaResponse{Replicas: replicas}, err
}
// GetKeygroupReplica returns a list of all FReD nodes that replicate a given keygroup. In the future, this API will be
// GetKeygroupInfo returns a list of all FReD nodes that replicate a given keygroup. In the future, this API will be
// removed as ALExANDRA handles data replication.
func (s *Server) GetKeygroupReplica(ctx context.Context, req *middleware.GetKeygroupReplicaRequest) (*middleware.GetKeygroupReplicaResponse, error) {
res, err := s.clientsMgr.getFastestClient().Client.GetKeygroupReplica(ctx, &api.GetKeygroupReplicaRequest{Keygroup: req.Keygroup})
func (s *Server) GetKeygroupInfo(ctx context.Context, req *middleware.GetKeygroupInfoRequest) (*middleware.GetKeygroupInfoResponse, error) {
res, err := s.clientsMgr.getFastestClient().Client.GetKeygroupInfo(ctx, &api.GetKeygroupInfoRequest{Keygroup: req.Keygroup})
if err != nil {
return nil, err
......@@ -354,7 +354,10 @@ func (s *Server) GetKeygroupReplica(ctx context.Context, req *middleware.GetKeyg
}
}
return &middleware.GetKeygroupReplicaResponse{Replica: replicas}, err
return &middleware.GetKeygroupInfoResponse{
Mutable: res.Mutable,
Replica: replicas,
}, err
}
// GetKeygroupTriggers returns a list of trigger nodes for a keygroup.
......
......@@ -431,7 +431,7 @@ func (s *Server) AddReplica(ctx context.Context, request *client.AddReplicaReque
}
// GetKeygroupReplica calls this method on the exthandler
func (s *Server) GetKeygroupReplica(ctx context.Context, request *client.GetKeygroupReplicaRequest) (*client.GetKeygroupReplicaResponse, error) {
func (s *Server) GetKeygroupInfo(ctx context.Context, request *client.GetKeygroupInfoRequest) (*client.GetKeygroupInfoResponse, error) {
log.Info().Msgf("API Server has rcvd GetKeygroupReplica. In: %+v", request)
user, err := s.CheckCert(ctx)
......@@ -441,7 +441,7 @@ func (s *Server) GetKeygroupReplica(ctx context.Context, request *client.GetKeyg
return nil, err
}
n, e, err := s.e.HandleGetKeygroupReplica(user, fred.Keygroup{Name: fred.KeygroupName(request.Keygroup)})
m, n, e, err := s.e.HandleGetKeygroupInfo(user, fred.Keygroup{Name: fred.KeygroupName(request.Keygroup)})
log.Debug().Msgf("... received replicas: %+v", n)
if err != nil {
......@@ -459,7 +459,8 @@ func (s *Server) GetKeygroupReplica(ctx context.Context, request *client.GetKeyg
}
}
return &client.GetKeygroupReplicaResponse{
return &client.GetKeygroupInfoResponse{
Mutable: m,
Replica: replicas,
}, nil
......
......@@ -320,16 +320,28 @@ func (h *ExtHandler) HandleAddReplica(user string, k Keygroup, n Node) error {
return nil
}
// HandleGetKeygroupReplica handles requests to the GetKeygroupReplica endpoint of the client interface.
func (h *ExtHandler) HandleGetKeygroupReplica(user string, k Keygroup) ([]Node, map[NodeID]int, error) {
// HandleGetKeygroupInfo handles requests to the GetKeygroupInfo endpoint of the client interface.
func (h *ExtHandler) HandleGetKeygroupInfo(user string, k Keygroup) (bool, []Node, map[NodeID]int, error) {
allowed, err := h.a.isAllowed(user, GetReplica, k.Name)
if err != nil || !allowed {
log.Err(err).Msg("Exthandler uer is not allowed to GetKeygroupReplica")
return nil, nil, errors.Errorf("user %s cannot get replica for keygroup %s", user, k.Name)
return false, nil, nil, errors.Errorf("user %s cannot get replica for keygroup %s", user, k.Name)
}
return h.r.getReplicaExternal(k)
m, err := h.n.IsMutable(k.Name)
if err != nil {
return false, nil, nil, err
}
n, e, err := h.r.getReplicaExternal(k)
if err != nil {
return false, nil, nil, err
}
return m, n, e, nil
}
// HandleRemoveReplica handles requests to the RemoveKeygroupReplica endpoint of the client interface.
......
......@@ -594,9 +594,10 @@ func TestKeygroupReplicas(t *testing.T) {
assert.NoError(t, err)
nodes, expiries, err := f.E.HandleGetKeygroupReplica(user, fred.Keygroup{Name: kg})
mutable, nodes, expiries, err := f.E.HandleGetKeygroupInfo(user, fred.Keygroup{Name: kg})
assert.NoError(t, err)
assert.True(t, mutable)
assert.Len(t, nodes, 1)
assert.Equal(t, nodeID, nodes[0].ID)
assert.Equal(t, "127.0.0.1:9000", nodes[0].Host)
......
......@@ -308,8 +308,8 @@ func (a *APIProxy) AddReplica(ctx context.Context, req *client.AddReplicaRequest
return c.AddReplica(ctx, req)
}
// GetKeygroupReplica calls this method on the exthandler
func (a *APIProxy) GetKeygroupReplica(ctx context.Context, req *client.GetKeygroupReplicaRequest) (*client.GetKeygroupReplicaResponse, error) {
// GetKeygroupInfo calls this method on the exthandler
func (a *APIProxy) GetKeygroupInfo(ctx context.Context, req *client.GetKeygroupInfoRequest) (*client.GetKeygroupInfoResponse, error) {
c, err := a.getConn(req.Keygroup)
if err != nil {
......@@ -321,7 +321,7 @@ func (a *APIProxy) GetKeygroupReplica(ctx context.Context, req *client.GetKeygro
return nil, err
}
return c.GetKeygroupReplica(ctx, req)
return c.GetKeygroupInfo(ctx, req)
}
// RemoveReplica calls this method on the exthandler
......
This diff is collapsed.
......@@ -13,7 +13,7 @@ service Client {
rpc Delete (DeleteRequest) returns (DeleteResponse);
rpc Append (AppendRequest) returns (AppendResponse);
rpc AddReplica (AddReplicaRequest) returns (Empty);
rpc GetKeygroupReplica (GetKeygroupReplicaRequest) returns (GetKeygroupReplicaResponse);
rpc GetKeygroupInfo (GetKeygroupInfoRequest) returns (GetKeygroupInfoResponse);
rpc RemoveReplica (RemoveReplicaRequest) returns (Empty);
rpc GetReplica (GetReplicaRequest) returns (GetReplicaResponse);
rpc GetAllReplica (Empty) returns (GetAllReplicaResponse);
......@@ -111,12 +111,13 @@ message AddReplicaRequest {
int64 expiry = 3;
}
message GetKeygroupReplicaRequest {
message GetKeygroupInfoRequest {
string keygroup = 1;
}
message GetKeygroupReplicaResponse {
repeated KeygroupReplica replica = 1;
message GetKeygroupInfoResponse {
bool mutable = 1;
repeated KeygroupReplica replica = 2;
}
message KeygroupReplica {
......
......@@ -26,7 +26,7 @@ type ClientClient interface {
Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error)
Append(ctx context.Context, in *AppendRequest, opts ...grpc.CallOption) (*AppendResponse, error)
AddReplica(ctx context.Context, in *AddReplicaRequest, opts ...grpc.CallOption) (*Empty, error)
GetKeygroupReplica(ctx context.Context, in *GetKeygroupReplicaRequest, opts ...grpc.CallOption) (*GetKeygroupReplicaResponse, error)
GetKeygroupInfo(ctx context.Context, in *GetKeygroupInfoRequest, opts ...grpc.CallOption) (*GetKeygroupInfoResponse, error)
RemoveReplica(ctx context.Context, in *RemoveReplicaRequest, opts ...grpc.CallOption) (*Empty, error)
GetReplica(ctx context.Context, in *GetReplicaRequest, opts ...grpc.CallOption) (*GetReplicaResponse, error)
GetAllReplica(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GetAllReplicaResponse, error)
......@@ -117,9 +117,9 @@ func (c *clientClient) AddReplica(ctx context.Context, in *AddReplicaRequest, op
return out, nil
}
func (c *clientClient) GetKeygroupReplica(ctx context.Context, in *GetKeygroupReplicaRequest, opts ...grpc.CallOption) (*GetKeygroupReplicaResponse, error) {
out := new(GetKeygroupReplicaResponse)
err := c.cc.Invoke(ctx, "/mcc.fred.client.Client/GetKeygroupReplica", in, out, opts...)
func (c *clientClient) GetKeygroupInfo(ctx context.Context, in *GetKeygroupInfoRequest, opts ...grpc.CallOption) (*GetKeygroupInfoResponse, error) {
out := new(GetKeygroupInfoResponse)
err := c.cc.Invoke(ctx, "/mcc.fred.client.Client/GetKeygroupInfo", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -210,7 +210,7 @@ type ClientServer interface {
Delete(context.Context, *DeleteRequest) (*DeleteResponse, error)
Append(context.Context, *AppendRequest) (*AppendResponse, error)
AddReplica(context.Context, *AddReplicaRequest) (*Empty, error)
GetKeygroupReplica(context.Context, *GetKeygroupReplicaRequest) (*GetKeygroupReplicaResponse, error)
GetKeygroupInfo(context.Context, *GetKeygroupInfoRequest) (*GetKeygroupInfoResponse, error)
RemoveReplica(context.Context, *RemoveReplicaRequest) (*Empty, error)
GetReplica(context.Context, *GetReplicaRequest) (*GetReplicaResponse, error)
GetAllReplica(context.Context, *Empty) (*GetAllReplicaResponse, error)
......@@ -249,8 +249,8 @@ func (UnimplementedClientServer) Append(context.Context, *AppendRequest) (*Appen
func (UnimplementedClientServer) AddReplica(context.Context, *AddReplicaRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddReplica not implemented")
}
func (UnimplementedClientServer) GetKeygroupReplica(context.Context, *GetKeygroupReplicaRequest) (*GetKeygroupReplicaResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetKeygroupReplica not implemented")
func (UnimplementedClientServer) GetKeygroupInfo(context.Context, *GetKeygroupInfoRequest) (*GetKeygroupInfoResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetKeygroupInfo not implemented")
}
func (UnimplementedClientServer) RemoveReplica(context.Context, *RemoveReplicaRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method RemoveReplica not implemented")
......@@ -432,20 +432,20 @@ func _Client_AddReplica_Handler(srv interface{}, ctx context.Context, dec func(i
return interceptor(ctx, in, info, handler)
}
func _Client_GetKeygroupReplica_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetKeygroupReplicaRequest)
func _Client_GetKeygroupInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetKeygroupInfoRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ClientServer).GetKeygroupReplica(ctx, in)
return srv.(ClientServer).GetKeygroupInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/mcc.fred.client.Client/GetKeygroupReplica",
FullMethod: "/mcc.fred.client.Client/GetKeygroupInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ClientServer).GetKeygroupReplica(ctx, req.(*GetKeygroupReplicaRequest))
return srv.(ClientServer).GetKeygroupInfo(ctx, req.(*GetKeygroupInfoRequest))
}
return interceptor(ctx, in, info, handler)
}
......@@ -634,8 +634,8 @@ var Client_ServiceDesc = grpc.ServiceDesc{
Handler: _Client_AddReplica_Handler,
},
{
MethodName: "GetKeygroupReplica",
Handler: _Client_GetKeygroupReplica_Handler,
MethodName: "GetKeygroupInfo",
Handler: _Client_GetKeygroupInfo_Handler,
},
{
MethodName: "RemoveReplica",
......
This diff is collapsed.
......@@ -14,7 +14,7 @@ service Middleware {
rpc Append (AppendRequest) returns (AppendResponse);
rpc Notify (NotifyRequest) returns (NotifyResponse);
rpc AddReplica (AddReplicaRequest) returns (Empty);
rpc GetKeygroupReplica (GetKeygroupReplicaRequest) returns (GetKeygroupReplicaResponse);
rpc GetKeygroupInfo (GetKeygroupInfoRequest) returns (GetKeygroupInfoResponse);
rpc RemoveReplica (RemoveReplicaRequest) returns (Empty);
rpc GetReplica (GetReplicaRequest) returns (GetReplicaResponse);
rpc GetAllReplica (GetAllReplicaRequest) returns (GetAllReplicaResponse);
......@@ -111,12 +111,13 @@ message AddReplicaRequest {
int64 expiry = 3;
}
message GetKeygroupReplicaRequest {
message GetKeygroupInfoRequest {
string keygroup = 1;
}
message GetKeygroupReplicaResponse {
repeated KeygroupReplica replica = 1;
message GetKeygroupInfoResponse {
bool mutable = 1;
repeated KeygroupReplica replica = 2;
}
message KeygroupReplica {
......
......@@ -27,7 +27,7 @@ type MiddlewareClient interface {
Append(ctx context.Context, in *AppendRequest, opts ...grpc.CallOption) (*AppendResponse, error)
Notify(ctx context.Context, in *NotifyRequest, opts ...grpc.CallOption) (*NotifyResponse, error)
AddReplica(ctx context.Context, in *AddReplicaRequest, opts ...grpc.CallOption) (*Empty, error)
GetKeygroupReplica(ctx context.Context, in *GetKeygroupReplicaRequest, opts ...grpc.CallOption) (*GetKeygroupReplicaResponse, error)
GetKeygroupInfo(ctx context.Context, in *GetKeygroupInfoRequest, opts ...grpc.CallOption) (*GetKeygroupInfoResponse, error)
RemoveReplica(ctx context.Context, in *RemoveReplicaRequest, opts ...grpc.CallOption) (*Empty, error)
GetReplica(ctx context.Context, in *GetReplicaRequest, opts ...grpc.CallOption) (*GetReplicaResponse, error)
GetAllReplica(ctx context.Context, in *GetAllReplicaRequest, opts ...grpc.CallOption) (*GetAllReplicaResponse, error)
......@@ -127,9 +127,9 @@ func (c *middlewareClient) AddReplica(ctx context.Context, in *AddReplicaRequest
return out, nil
}
func (c *middlewareClient) GetKeygroupReplica(ctx context.Context, in *GetKeygroupReplicaRequest, opts ...grpc.CallOption) (*GetKeygroupReplicaResponse, error) {
out := new(GetKeygroupReplicaResponse)
err := c.cc.Invoke(ctx, "/mcc.fred.middleware.Middleware/GetKeygroupReplica", in, out, opts...)
func (c *middlewareClient) GetKeygroupInfo(ctx context.Context, in *GetKeygroupInfoRequest, opts ...grpc.CallOption) (*GetKeygroupInfoResponse, error) {
out := new(GetKeygroupInfoResponse)
err := c.cc.Invoke(ctx, "/mcc.fred.middleware.Middleware/GetKeygroupInfo", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -221,7 +221,7 @@ type MiddlewareServer interface {
Append(context.Context, *AppendRequest) (*AppendResponse, error)
Notify(context.Context, *NotifyRequest) (*NotifyResponse, error)
AddReplica(context.Context, *AddReplicaRequest) (*Empty, error)
GetKeygroupReplica(context.Context, *GetKeygroupReplicaRequest) (*GetKeygroupReplicaResponse, error)
GetKeygroupInfo(context.Context, *GetKeygroupInfoRequest) (*GetKeygroupInfoResponse, error)
RemoveReplica(context.Context, *RemoveReplicaRequest) (*Empty, error)
GetReplica(context.Context, *GetReplicaRequest) (*GetReplicaResponse, error)
GetAllReplica(context.Context, *GetAllReplicaRequest) (*GetAllReplicaResponse, error)
......@@ -263,8 +263,8 @@ func (UnimplementedMiddlewareServer) Notify(context.Context, *NotifyRequest) (*N
func (UnimplementedMiddlewareServer) AddReplica(context.Context, *AddReplicaRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddReplica not implemented")
}
func (UnimplementedMiddlewareServer) GetKeygroupReplica(context.Context, *GetKeygroupReplicaRequest) (*GetKeygroupReplicaResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetKeygroupReplica not implemented")
func (UnimplementedMiddlewareServer) GetKeygroupInfo(context.Context, *GetKeygroupInfoRequest) (*GetKeygroupInfoResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetKeygroupInfo not implemented")
}
func (UnimplementedMiddlewareServer) RemoveReplica(context.Context, *RemoveReplicaRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method RemoveReplica not implemented")
......@@ -464,20 +464,20 @@ func _Middleware_AddReplica_Handler(srv interface{}, ctx context.Context, dec fu
return interceptor(ctx, in, info, handler)
}
func _Middleware_GetKeygroupReplica_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetKeygroupReplicaRequest)
func _Middleware_GetKeygroupInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetKeygroupInfoRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MiddlewareServer).GetKeygroupReplica(ctx, in)
return srv.(MiddlewareServer).GetKeygroupInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/mcc.fred.middleware.Middleware/GetKeygroupReplica",
FullMethod: "/mcc.fred.middleware.Middleware/GetKeygroupInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MiddlewareServer).GetKeygroupReplica(ctx, req.(*GetKeygroupReplicaRequest))
return srv.(MiddlewareServer).GetKeygroupInfo(ctx, req.(*GetKeygroupInfoRequest))
}
return interceptor(ctx, in, info, handler)
}
......@@ -670,8 +670,8 @@ var Middleware_ServiceDesc = grpc.ServiceDesc{
Handler: _Middleware_AddReplica_Handler,
},
{
MethodName: "GetKeygroupReplica",
Handler: _Middleware_GetKeygroupReplica_Handler,
MethodName: "GetKeygroupInfo",
Handler: _Middleware_GetKeygroupInfo_Handler,
},
{
MethodName: "RemoveReplica",
......
This diff is collapsed.
......@@ -300,7 +300,7 @@ class AddReplicaRequest(google.protobuf.message.Message):
def ClearField(self, field_name: typing_extensions.Literal[u"expiry",b"expiry",u"keygroup",b"keygroup",u"nodeId",b"nodeId"]) -> None: ...
global___AddReplicaRequest = AddReplicaRequest
class GetKeygroupReplicaRequest(google.protobuf.message.Message):
class GetKeygroupInfoRequest(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
KEYGROUP_FIELD_NUMBER: builtins.int
keygroup: typing.Text = ...
......@@ -310,21 +310,24 @@ class GetKeygroupReplicaRequest(google.protobuf.message.Message):
keygroup : typing.Text = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal[u"keygroup",b"keygroup"]) -> None: ...
global___GetKeygroupReplicaRequest = GetKeygroupReplicaRequest
global___GetKeygroupInfoRequest = GetKeygroupInfoRequest
class GetKeygroupReplicaResponse(google.protobuf.message.Message):
class GetKeygroupInfoResponse(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
MUTABLE_FIELD_NUMBER: builtins.int
REPLICA_FIELD_NUMBER: builtins.int
mutable: builtins.bool = ...
@property
def replica(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___KeygroupReplica]: ...
def __init__(self,
*,
mutable : builtins.bool = ...,
replica : typing.Optional[typing.Iterable[global___KeygroupReplica]] = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal[u"replica",b"replica"]) -> None: ...
global___GetKeygroupReplicaResponse = GetKeygroupReplicaResponse
def ClearField(self, field_name: typing_extensions.Literal[u"mutable",b"mutable",u"replica",b"replica"]) -> None: ...
global___GetKeygroupInfoResponse = GetKeygroupInfoResponse
class KeygroupReplica(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
......
......@@ -60,10 +60,10 @@ class MiddlewareStub(object):
request_serializer=middleware__pb2.AddReplicaRequest.SerializeToString,
response_deserializer=middleware__pb2.Empty.FromString,
)
self.GetKeygroupReplica = channel.unary_unary(
'/mcc.fred.middleware.Middleware/GetKeygroupReplica',
request_serializer=middleware__pb2.GetKeygroupReplicaRequest.SerializeToString,
response_deserializer=middleware__pb2.GetKeygroupReplicaResponse.FromString,
self.GetKeygroupInfo = channel.unary_unary(
'/mcc.fred.middleware.Middleware/GetKeygroupInfo',
request_serializer=middleware__pb2.GetKeygroupInfoRequest.SerializeToString,
response_deserializer=middleware__pb2.GetKeygroupInfoResponse.FromString,
)
self.RemoveReplica = channel.unary_unary(
'/mcc.fred.middleware.Middleware/RemoveReplica',
......@@ -165,7 +165,7 @@ class MiddlewareServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetKeygroupReplica(self, request, context):
def GetKeygroupInfo(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
......@@ -267,10 +267,10 @@ def add_MiddlewareServicer_to_server(servicer, server):
request_deserializer=middleware__pb2.AddReplicaRequest.FromString,
response_serializer=middleware__pb2.Empty.SerializeToString,
),
'GetKeygroupReplica': grpc.unary_unary_rpc_method_handler(
servicer.GetKeygroupReplica,
request_deserializer=middleware__pb2.GetKeygroupReplicaRequest.FromString,
response_serializer=middleware__pb2.GetKeygroupReplicaResponse.SerializeToString,
'GetKeygroupInfo': grpc.unary_unary_rpc_method_handler(
servicer.GetKeygroupInfo,
request_deserializer=middleware__pb2.GetKeygroupInfoRequest.FromString,
response_serializer=middleware__pb2.GetKeygroupInfoResponse.SerializeToString,
),
'RemoveReplica': grpc.unary_unary_rpc_method_handler(
servicer.RemoveReplica,
......@@ -477,7 +477,7 @@ class Middleware(object):
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def GetKeygroupReplica(request,
def GetKeygroupInfo(request,
target,
options=(),
channel_credentials=None,
......@@ -487,9 +487,9 @@ class Middleware(object):
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/mcc.fred.middleware.Middleware/GetKeygroupReplica',
middleware__pb2.GetKeygroupReplicaRequest.SerializeToString,
middleware__pb2.GetKeygroupReplicaResponse.FromString,
return grpc.experimental.unary_unary(request, target, '/mcc.fred.middleware.Middleware/GetKeygroupInfo',
middleware__pb2.GetKeygroupInfoRequest.SerializeToString,
middleware__pb2.GetKeygroupInfoResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
......
......@@ -119,7 +119,10 @@ func (t *ReplicaSuite) RunTests() {
}
t.c.nodeB.CreateKeygroup("replicanodetest", true, 0, false)
t.c.nodeB.AddKeygroupReplica("replicanodetest", t.c.nodeA.ID, 10, false)
hosts := t.c.nodeA.GetKeygroupReplica("replicanodetest", false)
mutable, hosts := t.c.nodeA.GetKeygroupInfo("replicanodetest", false)
if !mutable {
logNodeFailure(t.c.nodeA, "keygroup is mutable", "immutable")
}
if len(hosts) != 2 {
logNodeFailure(t.c.nodeA, "2 hosts", fmt.Sprintf("%d host(s)", len(hosts)))
}
......
......@@ -132,9 +132,9 @@ func (n *Node) DeleteKeygroup(kgname string, expectError bool) {
}
// GetKeygroupReplica calls the GetKeygroupReplica endpoint of the GRPC interface.
func (n *Node) GetKeygroupReplica(kgname string, expectError bool) map[string]int {
res, err := n.Client.GetKeygroupReplica(context.Background(), &client.GetKeygroupReplicaRequest{Keygroup: kgname})
// GetKeygroupInfo calls the GetKeygroupInfo endpoint of the GRPC interface.
func (n *Node) GetKeygroupInfo(kgname string, expectError bool) (bool, map[string]int) {
res, err := n.Client.GetKeygroupInfo(context.Background(), &client.GetKeygroupInfoRequest{Keygroup: kgname})
if err != nil && !expectError {
log.Warn().Msgf("GetKeygroupReplica: error %s", err)
......@@ -147,7 +147,7 @@ func (n *Node) GetKeygroupReplica(kgname string, expectError bool) map[string]in
}
if err != nil {
return nil
return false, nil
}
nodes := make(map[string]int)
......@@ -156,7 +156,7 @@ func (n *Node) GetKeygroupReplica(kgname string, expectError bool) map[string]in
nodes[node.NodeId] = int(node.Expiry)
}
return nodes
return res.Mutable, nodes
}
// AddKeygroupReplica calls the AddKeygroupReplica endpoint of the GRPC interface.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment