add VolumeStreamFollow, but not used yet

This commit is contained in:
Chris Lu 2019-04-18 00:18:29 -07:00
parent 13ad5c1966
commit b09e8dbb37
8 changed files with 351 additions and 102 deletions

View file

@ -84,7 +84,7 @@ func iterateEntries(datFile, idxFile *os.File, visitNeedle func(n *storage.Needl
}
offset := int64(superBlock.BlockSize())
version := superBlock.Version()
n, rest, err := storage.ReadNeedleHeader(datFile, version, offset)
n, _, rest, err := storage.ReadNeedleHeader(datFile, version, offset)
if err != nil {
fmt.Printf("cannot read needle header: %v", err)
return
@ -114,7 +114,7 @@ func iterateEntries(datFile, idxFile *os.File, visitNeedle func(n *storage.Needl
fmt.Println("Recovered in f", r)
}
}()
if err = n.ReadNeedleBody(datFile, version, offset+int64(types.NeedleEntrySize), rest); err != nil {
if _, err = n.ReadNeedleBody(datFile, version, offset+int64(types.NeedleEntrySize), rest); err != nil {
fmt.Printf("cannot read needle body: offset %d body %d %v\n", offset, rest, err)
}
}()
@ -126,7 +126,7 @@ func iterateEntries(datFile, idxFile *os.File, visitNeedle func(n *storage.Needl
offset += types.NeedleEntrySize + rest
//fmt.Printf("==> new entry offset %d\n", offset)
if n, rest, err = storage.ReadNeedleHeader(datFile, version, offset); err != nil {
if n, _, rest, err = storage.ReadNeedleHeader(datFile, version, offset); err != nil {
if err == io.EOF {
return
}

View file

@ -42,6 +42,9 @@ service VolumeServer {
rpc CopyFile (CopyFileRequest) returns (stream CopyFileResponse) {
}
rpc VolumeStreamFollow (VolumeStreamFollowRequest) returns (stream VolumeStreamFollowResponse) {
}
}
//////////////////////////////////////////////////
@ -120,7 +123,7 @@ message VolumeSyncStatusResponse {
message VolumeIncrementalCopyRequest {
uint32 volume_id = 1;
uint64 since = 2;
uint64 since_ns = 2;
}
message VolumeIncrementalCopyResponse {
bytes file_content = 1;
@ -163,6 +166,16 @@ message CopyFileResponse {
bytes file_content = 1;
}
message VolumeStreamFollowRequest {
uint32 volume_id = 1;
uint64 since_ns = 2;
uint32 drainingSeconds = 3;
}
message VolumeStreamFollowResponse {
bytes needle_header = 1;
bytes needle_body = 2;
}
message ReadVolumeFileStatusRequest {
uint32 volume_id = 1;
}

View file

@ -39,6 +39,8 @@ It has these top-level messages:
VolumeCopyResponse
CopyFileRequest
CopyFileResponse
VolumeStreamFollowRequest
VolumeStreamFollowResponse
ReadVolumeFileStatusRequest
ReadVolumeFileStatusResponse
DiskStatus
@ -420,7 +422,7 @@ func (m *VolumeSyncStatusResponse) GetIdxFileSize() uint64 {
type VolumeIncrementalCopyRequest struct {
VolumeId uint32 `protobuf:"varint,1,opt,name=volume_id,json=volumeId" json:"volume_id,omitempty"`
Since uint64 `protobuf:"varint,2,opt,name=since" json:"since,omitempty"`
SinceNs uint64 `protobuf:"varint,2,opt,name=since_ns,json=sinceNs" json:"since_ns,omitempty"`
}
func (m *VolumeIncrementalCopyRequest) Reset() { *m = VolumeIncrementalCopyRequest{} }
@ -435,9 +437,9 @@ func (m *VolumeIncrementalCopyRequest) GetVolumeId() uint32 {
return 0
}
func (m *VolumeIncrementalCopyRequest) GetSince() uint64 {
func (m *VolumeIncrementalCopyRequest) GetSinceNs() uint64 {
if m != nil {
return m.Since
return m.SinceNs
}
return 0
}
@ -634,6 +636,62 @@ func (m *CopyFileResponse) GetFileContent() []byte {
return nil
}
type VolumeStreamFollowRequest 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 *VolumeStreamFollowRequest) GetVolumeId() uint32 {
if m != nil {
return m.VolumeId
}
return 0
}
func (m *VolumeStreamFollowRequest) GetSinceNs() uint64 {
if m != nil {
return m.SinceNs
}
return 0
}
func (m *VolumeStreamFollowRequest) GetDrainingSeconds() uint32 {
if m != nil {
return m.DrainingSeconds
}
return 0
}
type VolumeStreamFollowResponse 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 *VolumeStreamFollowResponse) GetNeedleHeader() []byte {
if m != nil {
return m.NeedleHeader
}
return nil
}
func (m *VolumeStreamFollowResponse) GetNeedleBody() []byte {
if m != nil {
return m.NeedleBody
}
return nil
}
type ReadVolumeFileStatusRequest struct {
VolumeId uint32 `protobuf:"varint,1,opt,name=volume_id,json=volumeId" json:"volume_id,omitempty"`
}
@ -641,7 +699,7 @@ type ReadVolumeFileStatusRequest struct {
func (m *ReadVolumeFileStatusRequest) Reset() { *m = ReadVolumeFileStatusRequest{} }
func (m *ReadVolumeFileStatusRequest) String() string { return proto.CompactTextString(m) }
func (*ReadVolumeFileStatusRequest) ProtoMessage() {}
func (*ReadVolumeFileStatusRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{30} }
func (*ReadVolumeFileStatusRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{32} }
func (m *ReadVolumeFileStatusRequest) GetVolumeId() uint32 {
if m != nil {
@ -662,7 +720,7 @@ type ReadVolumeFileStatusResponse struct {
func (m *ReadVolumeFileStatusResponse) Reset() { *m = ReadVolumeFileStatusResponse{} }
func (m *ReadVolumeFileStatusResponse) String() string { return proto.CompactTextString(m) }
func (*ReadVolumeFileStatusResponse) ProtoMessage() {}
func (*ReadVolumeFileStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{31} }
func (*ReadVolumeFileStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{33} }
func (m *ReadVolumeFileStatusResponse) GetVolumeId() uint32 {
if m != nil {
@ -716,7 +774,7 @@ type DiskStatus struct {
func (m *DiskStatus) Reset() { *m = DiskStatus{} }
func (m *DiskStatus) String() string { return proto.CompactTextString(m) }
func (*DiskStatus) ProtoMessage() {}
func (*DiskStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{32} }
func (*DiskStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{34} }
func (m *DiskStatus) GetDir() string {
if m != nil {
@ -759,7 +817,7 @@ type MemStatus struct {
func (m *MemStatus) Reset() { *m = MemStatus{} }
func (m *MemStatus) String() string { return proto.CompactTextString(m) }
func (*MemStatus) ProtoMessage() {}
func (*MemStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{33} }
func (*MemStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{35} }
func (m *MemStatus) GetGoroutines() int32 {
if m != nil {
@ -841,6 +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((*ReadVolumeFileStatusRequest)(nil), "volume_server_pb.ReadVolumeFileStatusRequest")
proto.RegisterType((*ReadVolumeFileStatusResponse)(nil), "volume_server_pb.ReadVolumeFileStatusResponse")
proto.RegisterType((*DiskStatus)(nil), "volume_server_pb.DiskStatus")
@ -875,6 +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)
}
type volumeServerClient struct {
@ -1066,6 +1127,38 @@ 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...)
if err != nil {
return nil, err
}
x := &volumeServerVolumeStreamFollowClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type VolumeServer_VolumeStreamFollowClient interface {
Recv() (*VolumeStreamFollowResponse, error)
grpc.ClientStream
}
type volumeServerVolumeStreamFollowClient struct {
grpc.ClientStream
}
func (x *volumeServerVolumeStreamFollowClient) Recv() (*VolumeStreamFollowResponse, error) {
m := new(VolumeStreamFollowResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// Server API for VolumeServer service
type VolumeServerServer interface {
@ -1086,6 +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
}
func RegisterVolumeServerServer(s *grpc.Server, srv VolumeServerServer) {
@ -1368,6 +1462,27 @@ 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)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(VolumeServerServer).VolumeStreamFollow(m, &volumeServerVolumeStreamFollowServer{stream})
}
type VolumeServer_VolumeStreamFollowServer interface {
Send(*VolumeStreamFollowResponse) error
grpc.ServerStream
}
type volumeServerVolumeStreamFollowServer struct {
grpc.ServerStream
}
func (x *volumeServerVolumeStreamFollowServer) Send(m *VolumeStreamFollowResponse) error {
return x.ServerStream.SendMsg(m)
}
var _VolumeServer_serviceDesc = grpc.ServiceDesc{
ServiceName: "volume_server_pb.VolumeServer",
HandlerType: (*VolumeServerServer)(nil),
@ -1436,6 +1551,11 @@ var _VolumeServer_serviceDesc = grpc.ServiceDesc{
Handler: _VolumeServer_CopyFile_Handler,
ServerStreams: true,
},
{
StreamName: "VolumeStreamFollow",
Handler: _VolumeServer_VolumeStreamFollow_Handler,
ServerStreams: true,
},
},
Metadata: "volume_server.proto",
}
@ -1443,80 +1563,86 @@ var _VolumeServer_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("volume_server.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 1190 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x58, 0xdb, 0x72, 0xdc, 0x44,
0x13, 0xb6, 0xb2, 0xbb, 0xb6, 0xb7, 0x77, 0x9d, 0x6c, 0xc6, 0xa7, 0x8d, 0x7c, 0xf8, 0x37, 0x93,
0xfc, 0xc9, 0x26, 0x31, 0x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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,
}

View file

@ -18,9 +18,9 @@ func (vs *VolumeServer) VolumeIncrementalCopy(req *volume_server_pb.VolumeIncrem
}
stopOffset := v.Size()
foundOffset, isLastOne, err := v.BinarySearchByAppendAtNs(req.Since)
foundOffset, isLastOne, err := v.BinarySearchByAppendAtNs(req.SinceNs)
if err != nil {
return fmt.Errorf("fail to locate by appendAtNs %d: %s", req.Since, err)
return fmt.Errorf("fail to locate by appendAtNs %d: %s", req.SinceNs, err)
}
if isLastOne {

View file

@ -0,0 +1,77 @@
package weed_server
import (
"fmt"
"time"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/storage"
)
func (vs *VolumeServer) VolumeStreamFollow(req *volume_server_pb.VolumeStreamFollowRequest, stream volume_server_pb.VolumeServer_VolumeStreamFollowServer) error {
v := vs.store.GetVolume(storage.VolumeId(req.VolumeId))
if v == nil {
return fmt.Errorf("not found volume id %d", req.VolumeId)
}
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)
}
}
}
}
func sendNeedlesSince(stream volume_server_pb.VolumeServer_VolumeStreamFollowServer, 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)
}
if isLastOne {
return lastTimestampNs, nil
}
err = storage.ScanVolumeFileNeedleFrom(v.Version(), v.DataFile(), foundOffset.ToAcutalOffset(), func(needleHeader, needleBody []byte, needleAppendAtNs uint64) error {
sendErr := stream.Send(&volume_server_pb.VolumeStreamFollowResponse{
NeedleHeader: needleHeader,
NeedleBody: needleBody,
})
if sendErr != nil {
return sendErr
}
lastProcessedTimestampNs = needleAppendAtNs
return nil
})
return
}

View file

@ -267,14 +267,14 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
return nil
}
func ReadNeedleHeader(r *os.File, version Version, offset int64) (n *Needle, bodyLength int64, err error) {
func ReadNeedleHeader(r *os.File, version Version, offset int64) (n *Needle, bytes []byte, bodyLength int64, err error) {
n = new(Needle)
if version == Version1 || version == Version2 || version == Version3 {
bytes := make([]byte, NeedleEntrySize)
bytes = make([]byte, NeedleEntrySize)
var count int
count, err = r.ReadAt(bytes, offset)
if count <= 0 || err != nil {
return nil, 0, err
return nil, bytes, 0, err
}
n.ParseNeedleHeader(bytes)
bodyLength = NeedleBodyLength(n.Size, version)
@ -299,21 +299,21 @@ func NeedleBodyLength(needleSize uint32, version Version) int64 {
//n should be a needle already read the header
//the input stream will read until next file entry
func (n *Needle) ReadNeedleBody(r *os.File, version Version, offset int64, bodyLength int64) (err error) {
func (n *Needle) ReadNeedleBody(r *os.File, version Version, offset int64, bodyLength int64) (bytes []byte, err error) {
if bodyLength <= 0 {
return nil
return nil, nil
}
switch version {
case Version1:
bytes := make([]byte, bodyLength)
bytes = make([]byte, bodyLength)
if _, err = r.ReadAt(bytes, offset); err != nil {
return
}
n.Data = bytes[:n.Size]
n.Checksum = NewCRC(n.Data)
case Version2, Version3:
bytes := make([]byte, bodyLength)
bytes = make([]byte, bodyLength)
if _, err = r.ReadAt(bytes, offset); err != nil {
return
}

View file

@ -68,7 +68,7 @@ func (v *Volume) IncrementalBackup(volumeServer string, grpcDialOption grpc.Dial
stream, err := client.VolumeIncrementalCopy(ctx, &volume_server_pb.VolumeIncrementalCopyRequest{
VolumeId: uint32(v.Id),
Since: appendAtNs,
SinceNs: appendAtNs,
})
if err != nil {
return err
@ -147,11 +147,11 @@ func (v *Volume) locateLastAppendEntry() (Offset, error) {
func (v *Volume) readAppendAtNs(offset Offset) (uint64, error) {
n, bodyLength, err := ReadNeedleHeader(v.dataFile, v.SuperBlock.version, offset.ToAcutalOffset())
n, _, bodyLength, err := ReadNeedleHeader(v.dataFile, v.SuperBlock.version, offset.ToAcutalOffset())
if err != nil {
return 0, fmt.Errorf("ReadNeedleHeader: %v", err)
}
err = n.ReadNeedleBody(v.dataFile, v.SuperBlock.version, offset.ToAcutalOffset()+int64(NeedleEntrySize), bodyLength)
_, err = n.ReadNeedleBody(v.dataFile, v.SuperBlock.version, offset.ToAcutalOffset()+int64(NeedleEntrySize), bodyLength)
if err != nil {
return 0, fmt.Errorf("ReadNeedleBody offset %d, bodyLength %d: %v", offset.ToAcutalOffset(), bodyLength, err)
}

View file

@ -195,7 +195,7 @@ func ScanVolumeFile(dirname string, collection string, id VolumeId,
}
func ScanVolumeFileFrom(version Version, dataFile *os.File, offset int64, volumeFileScanner VolumeFileScanner) (err error) {
n, rest, e := ReadNeedleHeader(dataFile, version, offset)
n, _, rest, e := ReadNeedleHeader(dataFile, version, offset)
if e != nil {
if e == io.EOF {
return nil
@ -204,7 +204,7 @@ func ScanVolumeFileFrom(version Version, dataFile *os.File, offset int64, volume
}
for n != nil {
if volumeFileScanner.ReadNeedleBody() {
if err = n.ReadNeedleBody(dataFile, version, offset+NeedleEntrySize, rest); err != nil {
if _, err = n.ReadNeedleBody(dataFile, version, offset+NeedleEntrySize, rest); err != nil {
glog.V(0).Infof("cannot read needle body: %v", err)
//err = fmt.Errorf("cannot read needle body: %v", err)
//return
@ -219,7 +219,40 @@ func ScanVolumeFileFrom(version Version, dataFile *os.File, offset int64, volume
}
offset += NeedleEntrySize + rest
glog.V(4).Infof("==> new entry offset %d", offset)
if n, rest, err = ReadNeedleHeader(dataFile, version, offset); err != nil {
if n, _, rest, err = ReadNeedleHeader(dataFile, version, offset); err != nil {
if err == io.EOF {
return nil
}
return fmt.Errorf("cannot read needle header at offset %d: %v", offset, err)
}
glog.V(4).Infof("new entry needle size:%d rest:%d", n.Size, rest)
}
return nil
}
func ScanVolumeFileNeedleFrom(version Version, dataFile *os.File, offset int64, fn func(needleHeader, needleBody []byte, needleAppendAtNs uint64) error) (err error) {
n, nh, rest, e := ReadNeedleHeader(dataFile, version, offset)
if e != nil {
if e == io.EOF {
return nil
}
return fmt.Errorf("cannot read %s at offset %d: %v", dataFile.Name(), offset, e)
}
for n != nil {
var needleBody []byte
if needleBody, err = n.ReadNeedleBody(dataFile, version, offset+NeedleEntrySize, rest); err != nil {
glog.V(0).Infof("cannot read needle body: %v", err)
//err = fmt.Errorf("cannot read needle body: %v", err)
//return
}
err = fn(nh, needleBody, n.AppendAtNs)
if err != nil {
glog.V(0).Infof("visit needle error: %v", err)
return
}
offset += NeedleEntrySize + rest
glog.V(4).Infof("==> new entry offset %d", offset)
if n, nh, rest, err = ReadNeedleHeader(dataFile, version, offset); err != nil {
if err == io.EOF {
return nil
}