mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
rename to lookup
This commit is contained in:
parent
c9caf33119
commit
dbcba75271
|
@ -90,26 +90,26 @@ func (broker *MessageQueueBroker) CheckBrokerLoad(c context.Context, request *mq
|
|||
|
||||
// createOrUpdateTopicPartitions creates the topic partitions on the broker
|
||||
// 1. check
|
||||
func (broker *MessageQueueBroker) createOrUpdateTopicPartitions(topic *topic.Topic, prevAssignment *mq_pb.TopicPartitionsAssignment) (err error) {
|
||||
func (broker *MessageQueueBroker) createOrUpdateTopicPartitions(topic *topic.Topic, prevAssignments []*mq_pb.BrokerPartitionAssignment) (err error) {
|
||||
// create or update each partition
|
||||
if prevAssignment == nil {
|
||||
if prevAssignments == nil {
|
||||
broker.createOrUpdateTopicPartition(topic, nil)
|
||||
} else {
|
||||
for _, partitionAssignment := range prevAssignment.BrokerPartitions {
|
||||
broker.createOrUpdateTopicPartition(topic, partitionAssignment)
|
||||
for _, brokerPartitionAssignment := range prevAssignments {
|
||||
broker.createOrUpdateTopicPartition(topic, brokerPartitionAssignment)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (broker *MessageQueueBroker) createOrUpdateTopicPartition(topic *topic.Topic, oldAssignment *mq_pb.BrokerPartitionsAssignment) (newAssignment *mq_pb.BrokerPartitionsAssignment) {
|
||||
func (broker *MessageQueueBroker) createOrUpdateTopicPartition(topic *topic.Topic, oldAssignment *mq_pb.BrokerPartitionAssignment) (newAssignment *mq_pb.BrokerPartitionAssignment) {
|
||||
shouldCreate := broker.confirmBrokerPartitionAssignment(topic, oldAssignment)
|
||||
if !shouldCreate {
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
func (broker *MessageQueueBroker) confirmBrokerPartitionAssignment(topic *topic.Topic, oldAssignment *mq_pb.BrokerPartitionsAssignment) (shouldCreate bool) {
|
||||
func (broker *MessageQueueBroker) confirmBrokerPartitionAssignment(topic *topic.Topic, oldAssignment *mq_pb.BrokerPartitionAssignment) (shouldCreate bool) {
|
||||
if oldAssignment == nil {
|
||||
return true
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func (broker *MessageQueueBroker) confirmBrokerPartitionAssignment(topic *topic.
|
|||
_, err := client.CheckTopicPartitionsStatus(context.Background(), &mq_pb.CheckTopicPartitionsStatusRequest{
|
||||
Namespace: string(topic.Namespace),
|
||||
Topic: topic.Name,
|
||||
BrokerPartitionsAssignment: oldAssignment,
|
||||
BrokerPartitionAssignment: oldAssignment,
|
||||
ShouldCancelIfNotMatch: true,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -17,8 +17,8 @@ import (
|
|||
// 2.2 if the topic is found, return the brokers
|
||||
//
|
||||
// 3. unlock the topic
|
||||
func (broker *MessageQueueBroker) FindTopicBrokers(c context.Context, request *mq_pb.FindTopicBrokersRequest) (*mq_pb.FindTopicBrokersResponse, error) {
|
||||
ret := &mq_pb.FindTopicBrokersResponse{}
|
||||
func (broker *MessageQueueBroker) FindTopicBrokers(ctx context.Context, request *mq_pb.LookupTopicBrokersRequest) (*mq_pb.LookupTopicBrokersResponse, error) {
|
||||
ret := &mq_pb.LookupTopicBrokersResponse{}
|
||||
// TODO lock the topic
|
||||
|
||||
// find the topic partitions on the filer
|
||||
|
@ -27,6 +27,19 @@ func (broker *MessageQueueBroker) FindTopicBrokers(c context.Context, request *m
|
|||
// create the topic
|
||||
// if the request is_for_subscribe
|
||||
// return error not found
|
||||
// t := topic.FromPbTopic(request.Topic)
|
||||
ret.Topic = request.Topic
|
||||
ret.BrokerPartitionAssignments = []*mq_pb.BrokerPartitionAssignment{
|
||||
{
|
||||
LeaderBroker: "localhost:17777",
|
||||
FollowerBrokers: []string{"localhost:17777"},
|
||||
Partition: &mq_pb.Partition{
|
||||
RingSize: MaxPartitionCount,
|
||||
RangeStart: 0,
|
||||
RangeStop: MaxPartitionCount,
|
||||
},
|
||||
},
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -120,8 +120,8 @@ func (broker *MessageQueueBroker) AssignTopicPartitions(c context.Context, reque
|
|||
ret := &mq_pb.AssignTopicPartitionsResponse{}
|
||||
self := pb.ServerAddress(fmt.Sprintf("%s:%d", broker.option.Ip, broker.option.Port))
|
||||
|
||||
for _, partition := range request.TopicPartitionsAssignment.BrokerPartitions {
|
||||
localPartiton := topic.FromPbBrokerPartitionsAssignment(self, partition)
|
||||
for _, brokerPartition := range request.BrokerPartitionAssignments {
|
||||
localPartiton := topic.FromPbBrokerPartitionAssignment(self, brokerPartition)
|
||||
broker.localTopicManager.AddTopicPartition(
|
||||
topic.FromPbTopic(request.Topic),
|
||||
localPartiton)
|
||||
|
|
|
@ -27,14 +27,10 @@ func (p LocalPartition) Subscribe(clientName string, startReadTime time.Time, ea
|
|||
}, eachMessageFn)
|
||||
}
|
||||
|
||||
func FromPbBrokerPartitionsAssignment(self pb.ServerAddress, assignment *mq_pb.BrokerPartitionsAssignment) *LocalPartition {
|
||||
func FromPbBrokerPartitionAssignment(self pb.ServerAddress, assignment *mq_pb.BrokerPartitionAssignment) *LocalPartition {
|
||||
isLeaer := assignment.LeaderBroker == string(self)
|
||||
localPartition := &LocalPartition{
|
||||
Partition: Partition{
|
||||
RangeStart: assignment.PartitionStart,
|
||||
RangeStop: assignment.PartitionStop,
|
||||
RingSize: PartitionCount,
|
||||
},
|
||||
Partition: FromPbPartition(assignment.Partition),
|
||||
isLeader: isLeaer,
|
||||
}
|
||||
if !isLeaer {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.3
|
||||
// source: filer.proto
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.3
|
||||
// source: iam.proto
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.3
|
||||
// source: master.proto
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.3
|
||||
// source: mount.proto
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ service SeaweedMessaging {
|
|||
}
|
||||
|
||||
// control plane for topic partitions
|
||||
rpc FindTopicBrokers (FindTopicBrokersRequest) returns (FindTopicBrokersResponse) {
|
||||
rpc LookupTopicBrokers (LookupTopicBrokersRequest) returns (LookupTopicBrokersResponse) {
|
||||
}
|
||||
// a pub client will call this to get the topic partitions assignment
|
||||
rpc RequestTopicPartitions (RequestTopicPartitionsRequest) returns (RequestTopicPartitionsResponse) {
|
||||
|
@ -100,23 +100,18 @@ message CheckBrokerLoadResponse {
|
|||
|
||||
}
|
||||
|
||||
message FindTopicBrokersRequest {
|
||||
message LookupTopicBrokersRequest {
|
||||
Topic topic = 1;
|
||||
bool is_for_publish = 2;
|
||||
}
|
||||
message FindTopicBrokersResponse {
|
||||
message LookupTopicBrokersResponse {
|
||||
Topic topic = 1;
|
||||
TopicPartitionsAssignment topic_partitions_assignment = 2;
|
||||
repeated BrokerPartitionAssignment broker_partition_assignments = 2;
|
||||
}
|
||||
message BrokerPartitionsAssignment {
|
||||
int32 partition_start = 1;
|
||||
int32 partition_stop = 2;
|
||||
string leader_broker = 3;
|
||||
repeated string follower_brokers = 4;
|
||||
}
|
||||
message TopicPartitionsAssignment {
|
||||
int32 partition_count = 1; // over-sharded partitions, usually 1024
|
||||
repeated BrokerPartitionsAssignment broker_partitions = 2;
|
||||
message BrokerPartitionAssignment {
|
||||
Partition partition = 1;
|
||||
string leader_broker = 2;
|
||||
repeated string follower_brokers = 3;
|
||||
}
|
||||
|
||||
message RequestTopicPartitionsRequest {
|
||||
|
@ -124,12 +119,12 @@ message RequestTopicPartitionsRequest {
|
|||
int32 partition_count = 2;
|
||||
}
|
||||
message RequestTopicPartitionsResponse {
|
||||
TopicPartitionsAssignment topic_partitions_assignment = 1;
|
||||
repeated BrokerPartitionAssignment broker_partition_assignments = 1;
|
||||
}
|
||||
|
||||
message AssignTopicPartitionsRequest {
|
||||
Topic topic = 1;
|
||||
TopicPartitionsAssignment topic_partitions_assignment = 2;
|
||||
repeated BrokerPartitionAssignment broker_partition_assignments = 2;
|
||||
bool is_leader = 3;
|
||||
}
|
||||
message AssignTopicPartitionsResponse {
|
||||
|
@ -138,11 +133,11 @@ message AssignTopicPartitionsResponse {
|
|||
message CheckTopicPartitionsStatusRequest {
|
||||
string namespace = 1;
|
||||
string topic = 2;
|
||||
BrokerPartitionsAssignment broker_partitions_assignment = 3;
|
||||
BrokerPartitionAssignment broker_partition_assignment = 3;
|
||||
bool should_cancel_if_not_match = 4;
|
||||
}
|
||||
message CheckTopicPartitionsStatusResponse {
|
||||
TopicPartitionsAssignment topic_partitions_assignment = 1;
|
||||
repeated BrokerPartitionAssignment broker_partition_assignments = 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -28,7 +28,7 @@ type SeaweedMessagingClient interface {
|
|||
CheckSegmentStatus(ctx context.Context, in *CheckSegmentStatusRequest, opts ...grpc.CallOption) (*CheckSegmentStatusResponse, error)
|
||||
CheckBrokerLoad(ctx context.Context, in *CheckBrokerLoadRequest, opts ...grpc.CallOption) (*CheckBrokerLoadResponse, error)
|
||||
// control plane for topic partitions
|
||||
FindTopicBrokers(ctx context.Context, in *FindTopicBrokersRequest, opts ...grpc.CallOption) (*FindTopicBrokersResponse, error)
|
||||
LookupTopicBrokers(ctx context.Context, in *LookupTopicBrokersRequest, opts ...grpc.CallOption) (*LookupTopicBrokersResponse, error)
|
||||
// a pub client will call this to get the topic partitions assignment
|
||||
RequestTopicPartitions(ctx context.Context, in *RequestTopicPartitionsRequest, opts ...grpc.CallOption) (*RequestTopicPartitionsResponse, error)
|
||||
AssignTopicPartitions(ctx context.Context, in *AssignTopicPartitionsRequest, opts ...grpc.CallOption) (*AssignTopicPartitionsResponse, error)
|
||||
|
@ -82,9 +82,9 @@ func (c *seaweedMessagingClient) CheckBrokerLoad(ctx context.Context, in *CheckB
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *seaweedMessagingClient) FindTopicBrokers(ctx context.Context, in *FindTopicBrokersRequest, opts ...grpc.CallOption) (*FindTopicBrokersResponse, error) {
|
||||
out := new(FindTopicBrokersResponse)
|
||||
err := c.cc.Invoke(ctx, "/messaging_pb.SeaweedMessaging/FindTopicBrokers", in, out, opts...)
|
||||
func (c *seaweedMessagingClient) LookupTopicBrokers(ctx context.Context, in *LookupTopicBrokersRequest, opts ...grpc.CallOption) (*LookupTopicBrokersResponse, error) {
|
||||
out := new(LookupTopicBrokersResponse)
|
||||
err := c.cc.Invoke(ctx, "/messaging_pb.SeaweedMessaging/LookupTopicBrokers", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ type SeaweedMessagingServer interface {
|
|||
CheckSegmentStatus(context.Context, *CheckSegmentStatusRequest) (*CheckSegmentStatusResponse, error)
|
||||
CheckBrokerLoad(context.Context, *CheckBrokerLoadRequest) (*CheckBrokerLoadResponse, error)
|
||||
// control plane for topic partitions
|
||||
FindTopicBrokers(context.Context, *FindTopicBrokersRequest) (*FindTopicBrokersResponse, error)
|
||||
LookupTopicBrokers(context.Context, *LookupTopicBrokersRequest) (*LookupTopicBrokersResponse, error)
|
||||
// a pub client will call this to get the topic partitions assignment
|
||||
RequestTopicPartitions(context.Context, *RequestTopicPartitionsRequest) (*RequestTopicPartitionsResponse, error)
|
||||
AssignTopicPartitions(context.Context, *AssignTopicPartitionsRequest) (*AssignTopicPartitionsResponse, error)
|
||||
|
@ -218,8 +218,8 @@ func (UnimplementedSeaweedMessagingServer) CheckSegmentStatus(context.Context, *
|
|||
func (UnimplementedSeaweedMessagingServer) CheckBrokerLoad(context.Context, *CheckBrokerLoadRequest) (*CheckBrokerLoadResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CheckBrokerLoad not implemented")
|
||||
}
|
||||
func (UnimplementedSeaweedMessagingServer) FindTopicBrokers(context.Context, *FindTopicBrokersRequest) (*FindTopicBrokersResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FindTopicBrokers not implemented")
|
||||
func (UnimplementedSeaweedMessagingServer) LookupTopicBrokers(context.Context, *LookupTopicBrokersRequest) (*LookupTopicBrokersResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method LookupTopicBrokers not implemented")
|
||||
}
|
||||
func (UnimplementedSeaweedMessagingServer) RequestTopicPartitions(context.Context, *RequestTopicPartitionsRequest) (*RequestTopicPartitionsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RequestTopicPartitions not implemented")
|
||||
|
@ -321,20 +321,20 @@ func _SeaweedMessaging_CheckBrokerLoad_Handler(srv interface{}, ctx context.Cont
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SeaweedMessaging_FindTopicBrokers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindTopicBrokersRequest)
|
||||
func _SeaweedMessaging_LookupTopicBrokers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(LookupTopicBrokersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SeaweedMessagingServer).FindTopicBrokers(ctx, in)
|
||||
return srv.(SeaweedMessagingServer).LookupTopicBrokers(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/messaging_pb.SeaweedMessaging/FindTopicBrokers",
|
||||
FullMethod: "/messaging_pb.SeaweedMessaging/LookupTopicBrokers",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SeaweedMessagingServer).FindTopicBrokers(ctx, req.(*FindTopicBrokersRequest))
|
||||
return srv.(SeaweedMessagingServer).LookupTopicBrokers(ctx, req.(*LookupTopicBrokersRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
@ -464,8 +464,8 @@ var SeaweedMessaging_ServiceDesc = grpc.ServiceDesc{
|
|||
Handler: _SeaweedMessaging_CheckBrokerLoad_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "FindTopicBrokers",
|
||||
Handler: _SeaweedMessaging_FindTopicBrokers_Handler,
|
||||
MethodName: "LookupTopicBrokers",
|
||||
Handler: _SeaweedMessaging_LookupTopicBrokers_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RequestTopicPartitions",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.3
|
||||
// source: remote.proto
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.3
|
||||
// source: s3.proto
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.3
|
||||
// source: volume_server.proto
|
||||
|
||||
|
|
Loading…
Reference in a new issue