diff --git a/unmaintained/volume_tailer/volume_tailer.go b/unmaintained/volume_tailer/volume_tailer.go new file mode 100644 index 000000000..22c3ebab4 --- /dev/null +++ b/unmaintained/volume_tailer/volume_tailer.go @@ -0,0 +1,74 @@ +package main + +import ( + "context" + "flag" + + "github.com/chrislusf/seaweedfs/weed/operation" + "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" + "github.com/chrislusf/seaweedfs/weed/security" + weed_server "github.com/chrislusf/seaweedfs/weed/server" + "github.com/chrislusf/seaweedfs/weed/storage" + "github.com/spf13/viper" + + "io" + "log" +) + +var ( + master = flag.String("master", "localhost:9333", "master server host and port") + volumeId = flag.Int("volumeId", -1, "a volume id") + timeoutSeconds = flag.Int("timeoutSeconds", 0, "disconnect if no activity after these seconds") +) + +func main() { + flag.Parse() + + weed_server.LoadConfiguration("security", false) + grpcDialOption := security.LoadClientTLS(viper.Sub("grpc"), "client") + + vid := storage.VolumeId(*volumeId) + + // find volume location, replication, ttl info + lookup, err := operation.Lookup(*master, vid.String()) + if err != nil { + log.Printf("Error looking up volume %d: %v", vid, err) + return + } + volumeServer := lookup.Locations[0].Url + log.Printf("volume %d is on volume server %s", vid, volumeServer) + + err = operation.WithVolumeServerClient(volumeServer, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error { + + stream, err := client.VolumeTail(context.Background(), &volume_server_pb.VolumeTailRequest{ + VolumeId: uint32(vid), + SinceNs: 0, + DrainingSeconds: uint32(*timeoutSeconds), + }) + if err != nil { + return err + } + + for { + resp, recvErr := stream.Recv() + if recvErr != nil { + if recvErr == io.EOF { + break + } else { + return recvErr + } + } + + println("header:", len(resp.NeedleHeader), "body:", len(resp.NeedleBody)) + } + + return nil + + }) + + if err != nil { + log.Printf("Error VolumeTail volume %d: %v", vid, err) + } + + +} diff --git a/weed/pb/volume_server.proto b/weed/pb/volume_server.proto index 4a41c7104..949eeb49a 100644 --- a/weed/pb/volume_server.proto +++ b/weed/pb/volume_server.proto @@ -42,7 +42,7 @@ service VolumeServer { rpc CopyFile (CopyFileRequest) returns (stream CopyFileResponse) { } - rpc VolumeStreamFollow (VolumeStreamFollowRequest) returns (stream VolumeStreamFollowResponse) { + rpc VolumeTail (VolumeTailRequest) returns (stream VolumeTailResponse) { } } @@ -166,12 +166,12 @@ message CopyFileResponse { bytes file_content = 1; } -message VolumeStreamFollowRequest { +message VolumeTailRequest { uint32 volume_id = 1; uint64 since_ns = 2; uint32 drainingSeconds = 3; } -message VolumeStreamFollowResponse { +message VolumeTailResponse { bytes needle_header = 1; bytes needle_body = 2; } diff --git a/weed/pb/volume_server_pb/volume_server.pb.go b/weed/pb/volume_server_pb/volume_server.pb.go index 269774aa4..bb7711865 100644 --- a/weed/pb/volume_server_pb/volume_server.pb.go +++ b/weed/pb/volume_server_pb/volume_server.pb.go @@ -39,8 +39,8 @@ It has these top-level messages: VolumeCopyResponse CopyFileRequest CopyFileResponse - VolumeStreamFollowRequest - VolumeStreamFollowResponse + VolumeTailRequest + VolumeTailResponse ReadVolumeFileStatusRequest ReadVolumeFileStatusResponse DiskStatus @@ -636,56 +636,56 @@ func (m *CopyFileResponse) GetFileContent() []byte { return nil } -type VolumeStreamFollowRequest struct { +type VolumeTailRequest struct { VolumeId uint32 `protobuf:"varint,1,opt,name=volume_id,json=volumeId" json:"volume_id,omitempty"` SinceNs uint64 `protobuf:"varint,2,opt,name=since_ns,json=sinceNs" json:"since_ns,omitempty"` DrainingSeconds uint32 `protobuf:"varint,3,opt,name=drainingSeconds" json:"drainingSeconds,omitempty"` } -func (m *VolumeStreamFollowRequest) Reset() { *m = VolumeStreamFollowRequest{} } -func (m *VolumeStreamFollowRequest) String() string { return proto.CompactTextString(m) } -func (*VolumeStreamFollowRequest) ProtoMessage() {} -func (*VolumeStreamFollowRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{30} } +func (m *VolumeTailRequest) Reset() { *m = VolumeTailRequest{} } +func (m *VolumeTailRequest) String() string { return proto.CompactTextString(m) } +func (*VolumeTailRequest) ProtoMessage() {} +func (*VolumeTailRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{30} } -func (m *VolumeStreamFollowRequest) GetVolumeId() uint32 { +func (m *VolumeTailRequest) GetVolumeId() uint32 { if m != nil { return m.VolumeId } return 0 } -func (m *VolumeStreamFollowRequest) GetSinceNs() uint64 { +func (m *VolumeTailRequest) GetSinceNs() uint64 { if m != nil { return m.SinceNs } return 0 } -func (m *VolumeStreamFollowRequest) GetDrainingSeconds() uint32 { +func (m *VolumeTailRequest) GetDrainingSeconds() uint32 { if m != nil { return m.DrainingSeconds } return 0 } -type VolumeStreamFollowResponse struct { +type VolumeTailResponse struct { NeedleHeader []byte `protobuf:"bytes,1,opt,name=needle_header,json=needleHeader,proto3" json:"needle_header,omitempty"` NeedleBody []byte `protobuf:"bytes,2,opt,name=needle_body,json=needleBody,proto3" json:"needle_body,omitempty"` } -func (m *VolumeStreamFollowResponse) Reset() { *m = VolumeStreamFollowResponse{} } -func (m *VolumeStreamFollowResponse) String() string { return proto.CompactTextString(m) } -func (*VolumeStreamFollowResponse) ProtoMessage() {} -func (*VolumeStreamFollowResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{31} } +func (m *VolumeTailResponse) Reset() { *m = VolumeTailResponse{} } +func (m *VolumeTailResponse) String() string { return proto.CompactTextString(m) } +func (*VolumeTailResponse) ProtoMessage() {} +func (*VolumeTailResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{31} } -func (m *VolumeStreamFollowResponse) GetNeedleHeader() []byte { +func (m *VolumeTailResponse) GetNeedleHeader() []byte { if m != nil { return m.NeedleHeader } return nil } -func (m *VolumeStreamFollowResponse) GetNeedleBody() []byte { +func (m *VolumeTailResponse) GetNeedleBody() []byte { if m != nil { return m.NeedleBody } @@ -899,8 +899,8 @@ func init() { proto.RegisterType((*VolumeCopyResponse)(nil), "volume_server_pb.VolumeCopyResponse") proto.RegisterType((*CopyFileRequest)(nil), "volume_server_pb.CopyFileRequest") proto.RegisterType((*CopyFileResponse)(nil), "volume_server_pb.CopyFileResponse") - proto.RegisterType((*VolumeStreamFollowRequest)(nil), "volume_server_pb.VolumeStreamFollowRequest") - proto.RegisterType((*VolumeStreamFollowResponse)(nil), "volume_server_pb.VolumeStreamFollowResponse") + proto.RegisterType((*VolumeTailRequest)(nil), "volume_server_pb.VolumeTailRequest") + proto.RegisterType((*VolumeTailResponse)(nil), "volume_server_pb.VolumeTailResponse") proto.RegisterType((*ReadVolumeFileStatusRequest)(nil), "volume_server_pb.ReadVolumeFileStatusRequest") proto.RegisterType((*ReadVolumeFileStatusResponse)(nil), "volume_server_pb.ReadVolumeFileStatusResponse") proto.RegisterType((*DiskStatus)(nil), "volume_server_pb.DiskStatus") @@ -935,7 +935,7 @@ type VolumeServerClient interface { VolumeCopy(ctx context.Context, in *VolumeCopyRequest, opts ...grpc.CallOption) (*VolumeCopyResponse, error) ReadVolumeFileStatus(ctx context.Context, in *ReadVolumeFileStatusRequest, opts ...grpc.CallOption) (*ReadVolumeFileStatusResponse, error) CopyFile(ctx context.Context, in *CopyFileRequest, opts ...grpc.CallOption) (VolumeServer_CopyFileClient, error) - VolumeStreamFollow(ctx context.Context, in *VolumeStreamFollowRequest, opts ...grpc.CallOption) (VolumeServer_VolumeStreamFollowClient, error) + VolumeTail(ctx context.Context, in *VolumeTailRequest, opts ...grpc.CallOption) (VolumeServer_VolumeTailClient, error) } type volumeServerClient struct { @@ -1127,12 +1127,12 @@ func (x *volumeServerCopyFileClient) Recv() (*CopyFileResponse, error) { return m, nil } -func (c *volumeServerClient) VolumeStreamFollow(ctx context.Context, in *VolumeStreamFollowRequest, opts ...grpc.CallOption) (VolumeServer_VolumeStreamFollowClient, error) { - stream, err := grpc.NewClientStream(ctx, &_VolumeServer_serviceDesc.Streams[2], c.cc, "/volume_server_pb.VolumeServer/VolumeStreamFollow", opts...) +func (c *volumeServerClient) VolumeTail(ctx context.Context, in *VolumeTailRequest, opts ...grpc.CallOption) (VolumeServer_VolumeTailClient, error) { + stream, err := grpc.NewClientStream(ctx, &_VolumeServer_serviceDesc.Streams[2], c.cc, "/volume_server_pb.VolumeServer/VolumeTail", opts...) if err != nil { return nil, err } - x := &volumeServerVolumeStreamFollowClient{stream} + x := &volumeServerVolumeTailClient{stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -1142,17 +1142,17 @@ func (c *volumeServerClient) VolumeStreamFollow(ctx context.Context, in *VolumeS return x, nil } -type VolumeServer_VolumeStreamFollowClient interface { - Recv() (*VolumeStreamFollowResponse, error) +type VolumeServer_VolumeTailClient interface { + Recv() (*VolumeTailResponse, error) grpc.ClientStream } -type volumeServerVolumeStreamFollowClient struct { +type volumeServerVolumeTailClient struct { grpc.ClientStream } -func (x *volumeServerVolumeStreamFollowClient) Recv() (*VolumeStreamFollowResponse, error) { - m := new(VolumeStreamFollowResponse) +func (x *volumeServerVolumeTailClient) Recv() (*VolumeTailResponse, error) { + m := new(VolumeTailResponse) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -1179,7 +1179,7 @@ type VolumeServerServer interface { VolumeCopy(context.Context, *VolumeCopyRequest) (*VolumeCopyResponse, error) ReadVolumeFileStatus(context.Context, *ReadVolumeFileStatusRequest) (*ReadVolumeFileStatusResponse, error) CopyFile(*CopyFileRequest, VolumeServer_CopyFileServer) error - VolumeStreamFollow(*VolumeStreamFollowRequest, VolumeServer_VolumeStreamFollowServer) error + VolumeTail(*VolumeTailRequest, VolumeServer_VolumeTailServer) error } func RegisterVolumeServerServer(s *grpc.Server, srv VolumeServerServer) { @@ -1462,24 +1462,24 @@ func (x *volumeServerCopyFileServer) Send(m *CopyFileResponse) error { return x.ServerStream.SendMsg(m) } -func _VolumeServer_VolumeStreamFollow_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(VolumeStreamFollowRequest) +func _VolumeServer_VolumeTail_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(VolumeTailRequest) if err := stream.RecvMsg(m); err != nil { return err } - return srv.(VolumeServerServer).VolumeStreamFollow(m, &volumeServerVolumeStreamFollowServer{stream}) + return srv.(VolumeServerServer).VolumeTail(m, &volumeServerVolumeTailServer{stream}) } -type VolumeServer_VolumeStreamFollowServer interface { - Send(*VolumeStreamFollowResponse) error +type VolumeServer_VolumeTailServer interface { + Send(*VolumeTailResponse) error grpc.ServerStream } -type volumeServerVolumeStreamFollowServer struct { +type volumeServerVolumeTailServer struct { grpc.ServerStream } -func (x *volumeServerVolumeStreamFollowServer) Send(m *VolumeStreamFollowResponse) error { +func (x *volumeServerVolumeTailServer) Send(m *VolumeTailResponse) error { return x.ServerStream.SendMsg(m) } @@ -1552,8 +1552,8 @@ var _VolumeServer_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, }, { - StreamName: "VolumeStreamFollow", - Handler: _VolumeServer_VolumeStreamFollow_Handler, + StreamName: "VolumeTail", + Handler: _VolumeServer_VolumeTail_Handler, ServerStreams: true, }, }, @@ -1563,86 +1563,86 @@ var _VolumeServer_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("volume_server.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1291 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x58, 0x5b, 0x6f, 0xdc, 0x44, - 0x14, 0x8e, 0xbb, 0x9b, 0xdb, 0xd9, 0xdd, 0x76, 0x3b, 0x49, 0x9b, 0x8d, 0x7b, 0x61, 0x3b, 0x2d, - 0xed, 0xf6, 0x42, 0x0a, 0xad, 0x80, 0xc2, 0x13, 0x34, 0xa1, 0x22, 0x0f, 0x6d, 0x25, 0x87, 0x56, - 0x20, 0x90, 0xac, 0x59, 0x7b, 0x92, 0x58, 0xb1, 0x3d, 0x5b, 0xcf, 0x38, 0x6d, 0x10, 0xfc, 0x1a, - 0xde, 0x78, 0xe0, 0x1f, 0xf0, 0xcb, 0x90, 0x10, 0xf2, 0xcc, 0xd8, 0xf1, 0x35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 0x85, 0x41, 0x41, 0x4d, 0xa1, 0xdb, 0x4d, 0x9e, 0x45, 0x8d, 0x66, 0xde, 0x99, - 0x6b, 0x97, 0xc5, 0xb0, 0xd3, 0xe9, 0xa5, 0xc7, 0x55, 0x63, 0x72, 0xc5, 0x79, 0x75, 0x7b, 0x9e, - 0x59, 0x16, 0xe0, 0x27, 0x80, 0x53, 0xf1, 0x83, 0x6e, 0x36, 0xf9, 0xe5, 0x3f, 0xc5, 0xad, 0xb3, - 0x8d, 0x32, 0xea, 0xb7, 0xb0, 0x5e, 0x77, 0xf5, 0xa2, 0x9a, 0x53, 0x78, 0xc6, 0xfd, 0x6e, 0x6e, - 0xb5, 0x35, 0xcf, 0x02, 0xbf, 0x82, 0x95, 0x54, 0x4a, 0xa1, 0x1b, 0x55, 0xef, 0x92, 0xac, 0x33, - 0xf1, 0x59, 0x26, 0xb9, 0x6e, 0xe2, 0xa9, 0x4e, 0xcc, 0x6b, 0x9d, 0xda, 0xa9, 0xd7, 0x24, 0xc8, - 0x6a, 0xa7, 0x5e, 0xa3, 0x7c, 0x4a, 0x82, 0x4e, 0x97, 0xe4, 0x3f, 0x3b, 0x8f, 0xff, 0x0b, 0x00, - 0x00, 0xff, 0xff, 0x9b, 0xf8, 0x72, 0xd3, 0xf0, 0x11, 0x00, 0x00, + // 1282 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x58, 0xdd, 0x73, 0xdb, 0x44, + 0x10, 0x8f, 0x6a, 0x3b, 0xb6, 0xd7, 0x76, 0xeb, 0x5e, 0xd2, 0xc6, 0x55, 0x93, 0xe0, 0x5e, 0x4b, + 0xeb, 0xb6, 0x21, 0x85, 0x74, 0x80, 0xc2, 0x13, 0x24, 0x81, 0x21, 0x0f, 0x6d, 0x67, 0x94, 0x36, + 0x03, 0x94, 0x19, 0xcd, 0x45, 0xba, 0x24, 0x9a, 0xc8, 0x92, 0x2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, 0x8b, 0xec, 0xab, 0xec, 0xae, 0x97, 0x11, 0xae, 0x05, 0x74, 0x08, 0x83, 0x0c, 0x7b, 0x42, + 0xf7, 0xab, 0x2c, 0xb3, 0x9c, 0x4c, 0x7f, 0x30, 0x57, 0x2f, 0xf1, 0x61, 0xc6, 0xd3, 0x4b, 0x8d, + 0xab, 0xca, 0xe0, 0xb2, 0xf3, 0xea, 0xfe, 0x3c, 0xb5, 0xc4, 0xc1, 0x4f, 0x00, 0x17, 0x64, 0x07, + 0xdd, 0xad, 0xb2, 0x4b, 0x1f, 0xc5, 0xbd, 0xcb, 0x95, 0x12, 0xe8, 0x5f, 0x61, 0xb9, 0xec, 0xe9, + 0x45, 0x25, 0xb7, 0xf0, 0x92, 0xf7, 0x5d, 0xdf, 0xac, 0xab, 0x9e, 0x38, 0x7e, 0x0d, 0x9d, 0x98, + 0x3a, 0xa1, 0x3b, 0x45, 0xeb, 0x1c, 0x8d, 0xd3, 0xf1, 0x65, 0x2a, 0xa9, 0x6e, 0x7a, 0x13, 0x97, + 0x8a, 0x73, 0x9c, 0xea, 0x52, 0xa5, 0x88, 0x57, 0x75, 0xa9, 0xd2, 0x34, 0x89, 0x83, 0x1f, 0x2e, + 0x8a, 0x7f, 0x6c, 0x9e, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x07, 0xe0, 0xca, 0x7c, 0xc8, 0x11, + 0x00, 0x00, } diff --git a/weed/server/volume_grpc_stream_follow.go b/weed/server/volume_grpc_stream_follow.go index 7c01e4b9c..52a9c1473 100644 --- a/weed/server/volume_grpc_stream_follow.go +++ b/weed/server/volume_grpc_stream_follow.go @@ -9,57 +9,63 @@ import ( "github.com/chrislusf/seaweedfs/weed/storage" ) -func (vs *VolumeServer) VolumeStreamFollow(req *volume_server_pb.VolumeStreamFollowRequest, stream volume_server_pb.VolumeServer_VolumeStreamFollowServer) error { +func (vs *VolumeServer) VolumeTail(req *volume_server_pb.VolumeTailRequest, stream volume_server_pb.VolumeServer_VolumeTailServer) error { v := vs.store.GetVolume(storage.VolumeId(req.VolumeId)) if v == nil { return fmt.Errorf("not found volume id %d", req.VolumeId) } + defer glog.V(1).Infof("tailing volume %d finished", v.Id) + lastTimestampNs := req.SinceNs drainingSeconds := req.DrainingSeconds - ticker := time.NewTicker(time.Second) - for { - select { - case <-ticker.C: - lastProcessedTimestampNs, err := sendNeedlesSince(stream, v, lastTimestampNs) - if err != nil { - return fmt.Errorf("streamFollow: %v", err) - } - if req.DrainingSeconds == 0 { - continue - } - if lastProcessedTimestampNs == lastTimestampNs { - drainingSeconds-- - if drainingSeconds <= 0 { - return nil - } - glog.V(0).Infof("volume %d drains requests with %d seconds remaining ...", v.Id, drainingSeconds) - } else { - drainingSeconds = req.DrainingSeconds - glog.V(0).Infof("volume %d resets draining wait time to %d seconds", v.Id, drainingSeconds) - } + lastProcessedTimestampNs, err := sendNeedlesSince(stream, v, lastTimestampNs) + if err != nil { + glog.Infof("sendNeedlesSince: %v", err) + return fmt.Errorf("streamFollow: %v", err) } + time.Sleep(2 * time.Second) + + if req.DrainingSeconds == 0 { + continue + } + if lastProcessedTimestampNs == lastTimestampNs { + drainingSeconds-- + if drainingSeconds <= 0 { + return nil + } + glog.V(1).Infof("tailing volume %d drains requests with %d seconds remaining", v.Id, drainingSeconds) + } else { + lastTimestampNs = lastProcessedTimestampNs + drainingSeconds = req.DrainingSeconds + glog.V(1).Infof("tailing volume %d resets draining wait time to %d seconds", v.Id, drainingSeconds) + } + } } -func sendNeedlesSince(stream volume_server_pb.VolumeServer_VolumeStreamFollowServer, v *storage.Volume, lastTimestampNs uint64) (lastProcessedTimestampNs uint64, err error) { +func sendNeedlesSince(stream volume_server_pb.VolumeServer_VolumeTailServer, v *storage.Volume, lastTimestampNs uint64) (lastProcessedTimestampNs uint64, err error) { foundOffset, isLastOne, err := v.BinarySearchByAppendAtNs(lastTimestampNs) if err != nil { return 0, fmt.Errorf("fail to locate by appendAtNs %d: %s", lastTimestampNs, err) } + // log.Printf("reading ts %d offset %d isLast %v", lastTimestampNs, foundOffset, isLastOne) + if isLastOne { - return lastTimestampNs, nil + // need to heart beat to the client to ensure the connection health + sendErr := stream.Send(&volume_server_pb.VolumeTailResponse{}) + return lastTimestampNs, sendErr } err = storage.ScanVolumeFileNeedleFrom(v.Version(), v.DataFile(), foundOffset.ToAcutalOffset(), func(needleHeader, needleBody []byte, needleAppendAtNs uint64) error { - sendErr := stream.Send(&volume_server_pb.VolumeStreamFollowResponse{ + sendErr := stream.Send(&volume_server_pb.VolumeTailResponse{ NeedleHeader: needleHeader, NeedleBody: needleBody, })