refactoring

This commit is contained in:
Chris Lu 2019-04-20 12:05:28 -07:00
parent 6fc1f53018
commit 2ffe98443b
5 changed files with 128 additions and 126 deletions

View file

@ -22,16 +22,16 @@ func TailVolume(master string, grpcDialOption grpc.DialOption, vid needle.Volume
volumeServer := lookup.Locations[0].Url volumeServer := lookup.Locations[0].Url
return TailVolumeFromServer(volumeServer, grpcDialOption, vid, sinceNs, timeoutSeconds, fn) return TailVolumeFromSource(volumeServer, grpcDialOption, vid, sinceNs, timeoutSeconds, fn)
} }
func TailVolumeFromServer(volumeServer string, grpcDialOption grpc.DialOption, vid needle.VolumeId, sinceNs uint64, timeoutSeconds int, fn func(n *needle.Needle) error) error { func TailVolumeFromSource(volumeServer string, grpcDialOption grpc.DialOption, vid needle.VolumeId, sinceNs uint64, idleTimeoutSeconds int, fn func(n *needle.Needle) error) error {
return WithVolumeServerClient(volumeServer, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error { return WithVolumeServerClient(volumeServer, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
stream, err := client.VolumeTailSender(context.Background(), &volume_server_pb.VolumeTailSenderRequest{ stream, err := client.VolumeTailSender(context.Background(), &volume_server_pb.VolumeTailSenderRequest{
VolumeId: uint32(vid), VolumeId: uint32(vid),
SinceNs: sinceNs, SinceNs: sinceNs,
DrainingSeconds: uint32(timeoutSeconds), IdleTimeoutSeconds: uint32(idleTimeoutSeconds),
}) })
if err != nil { if err != nil {
return err return err

View file

@ -174,7 +174,7 @@ message CopyFileResponse {
message VolumeTailSenderRequest { message VolumeTailSenderRequest {
uint32 volume_id = 1; uint32 volume_id = 1;
uint64 since_ns = 2; uint64 since_ns = 2;
uint32 drainingSeconds = 3; uint32 idle_timeout_seconds = 3;
} }
message VolumeTailSenderResponse { message VolumeTailSenderResponse {
bytes needle_header = 1; bytes needle_header = 1;
@ -185,7 +185,7 @@ message VolumeTailSenderResponse {
message VolumeTailReceiverRequest { message VolumeTailReceiverRequest {
uint32 volume_id = 1; uint32 volume_id = 1;
uint64 since_ns = 2; uint64 since_ns = 2;
uint32 drainingSeconds = 3; uint32 idle_timeout_seconds = 3;
string source_volume_server = 4; string source_volume_server = 4;
} }
message VolumeTailReceiverResponse { message VolumeTailReceiverResponse {

View file

@ -663,9 +663,9 @@ func (m *CopyFileResponse) GetFileContent() []byte {
} }
type VolumeTailSenderRequest struct { type VolumeTailSenderRequest struct {
VolumeId uint32 `protobuf:"varint,1,opt,name=volume_id,json=volumeId" json:"volume_id,omitempty"` 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"` 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"` IdleTimeoutSeconds uint32 `protobuf:"varint,3,opt,name=idle_timeout_seconds,json=idleTimeoutSeconds" json:"idle_timeout_seconds,omitempty"`
} }
func (m *VolumeTailSenderRequest) Reset() { *m = VolumeTailSenderRequest{} } func (m *VolumeTailSenderRequest) Reset() { *m = VolumeTailSenderRequest{} }
@ -687,9 +687,9 @@ func (m *VolumeTailSenderRequest) GetSinceNs() uint64 {
return 0 return 0
} }
func (m *VolumeTailSenderRequest) GetDrainingSeconds() uint32 { func (m *VolumeTailSenderRequest) GetIdleTimeoutSeconds() uint32 {
if m != nil { if m != nil {
return m.DrainingSeconds return m.IdleTimeoutSeconds
} }
return 0 return 0
} }
@ -729,7 +729,7 @@ func (m *VolumeTailSenderResponse) GetIsLastChunk() bool {
type VolumeTailReceiverRequest struct { type VolumeTailReceiverRequest struct {
VolumeId uint32 `protobuf:"varint,1,opt,name=volume_id,json=volumeId" json:"volume_id,omitempty"` 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"` 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"` IdleTimeoutSeconds uint32 `protobuf:"varint,3,opt,name=idle_timeout_seconds,json=idleTimeoutSeconds" json:"idle_timeout_seconds,omitempty"`
SourceVolumeServer string `protobuf:"bytes,4,opt,name=source_volume_server,json=sourceVolumeServer" json:"source_volume_server,omitempty"` SourceVolumeServer string `protobuf:"bytes,4,opt,name=source_volume_server,json=sourceVolumeServer" json:"source_volume_server,omitempty"`
} }
@ -752,9 +752,9 @@ func (m *VolumeTailReceiverRequest) GetSinceNs() uint64 {
return 0 return 0
} }
func (m *VolumeTailReceiverRequest) GetDrainingSeconds() uint32 { func (m *VolumeTailReceiverRequest) GetIdleTimeoutSeconds() uint32 {
if m != nil { if m != nil {
return m.DrainingSeconds return m.IdleTimeoutSeconds
} }
return 0 return 0
} }
@ -1696,96 +1696,96 @@ var _VolumeServer_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("volume_server.proto", fileDescriptor0) } func init() { proto.RegisterFile("volume_server.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 1450 bytes of a gzipped FileDescriptorProto // 1453 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x58, 0xdd, 0x6e, 0xdc, 0xc4, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xc4, 0x18, 0x4b, 0x73, 0xdc, 0x44,
0x17, 0x8f, 0xbb, 0x9b, 0xec, 0xe6, 0xec, 0x26, 0x4d, 0x27, 0x69, 0xb3, 0xd9, 0x7e, 0xa5, 0x6e, 0xd3, 0xca, 0xae, 0xed, 0x75, 0xef, 0xda, 0x71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 0xb6, 0x6e, 0xb4, 0xac, 0x6d, 0x2e, 0x9c, 0xea, 0x8c, 0x2a, 0xd5, 0xbd, 0x4e, 0xb7, 0x90, 0xfc, 0x0c, 0x56, 0xdb, 0x64,
0x6c, 0xb2, 0xf5, 0x63, 0xdd, 0xcc, 0xee, 0x9c, 0xf8, 0x93, 0xf0, 0xd1, 0x3f, 0x01, 0x00, 0x00, 0x9b, 0x46, 0xcc, 0xda, 0x26, 0xdb, 0x3c, 0xd6, 0xcd, 0xec, 0xcd, 0xc9, 0xbf, 0x86, 0x0f, 0xfe,
0xff, 0xff, 0x4c, 0x2f, 0x65, 0x47, 0x3b, 0x14, 0x00, 0x00, 0x09, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xcf, 0xff, 0x14, 0x4c, 0x14, 0x00, 0x00,
} }

View file

@ -22,7 +22,7 @@ func (vs *VolumeServer) VolumeTailSender(req *volume_server_pb.VolumeTailSenderR
defer glog.V(1).Infof("tailing volume %d finished", v.Id) defer glog.V(1).Infof("tailing volume %d finished", v.Id)
lastTimestampNs := req.SinceNs lastTimestampNs := req.SinceNs
drainingSeconds := req.DrainingSeconds drainingSeconds := req.IdleTimeoutSeconds
for { for {
lastProcessedTimestampNs, err := sendNeedlesSince(stream, v, lastTimestampNs) lastProcessedTimestampNs, err := sendNeedlesSince(stream, v, lastTimestampNs)
@ -32,7 +32,7 @@ func (vs *VolumeServer) VolumeTailSender(req *volume_server_pb.VolumeTailSenderR
} }
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
if req.DrainingSeconds == 0 { if req.IdleTimeoutSeconds == 0 {
lastTimestampNs = lastProcessedTimestampNs lastTimestampNs = lastProcessedTimestampNs
continue continue
} }
@ -44,7 +44,7 @@ func (vs *VolumeServer) VolumeTailSender(req *volume_server_pb.VolumeTailSenderR
glog.V(1).Infof("tailing volume %d drains requests with %d seconds remaining", v.Id, drainingSeconds) glog.V(1).Infof("tailing volume %d drains requests with %d seconds remaining", v.Id, drainingSeconds)
} else { } else {
lastTimestampNs = lastProcessedTimestampNs lastTimestampNs = lastProcessedTimestampNs
drainingSeconds = req.DrainingSeconds drainingSeconds = req.IdleTimeoutSeconds
glog.V(1).Infof("tailing volume %d resets draining wait time to %d seconds", v.Id, drainingSeconds) glog.V(1).Infof("tailing volume %d resets draining wait time to %d seconds", v.Id, drainingSeconds)
} }
@ -110,7 +110,7 @@ func (vs *VolumeServer) VolumeTailReceiver(ctx context.Context, req *volume_serv
defer glog.V(1).Infof("receive tailing volume %d finished", v.Id) defer glog.V(1).Infof("receive tailing volume %d finished", v.Id)
return resp, operation.TailVolumeFromServer(req.SourceVolumeServer, vs.grpcDialOption, v.Id, req.SinceNs, int(req.DrainingSeconds), func(n *needle.Needle) error { return resp, operation.TailVolumeFromSource(req.SourceVolumeServer, vs.grpcDialOption, v.Id, req.SinceNs, int(req.IdleTimeoutSeconds), func(n *needle.Needle) error {
_, err := vs.store.Write(v.Id, n) _, err := vs.store.Write(v.Id, n)
return err return err
}) })

View file

@ -18,7 +18,6 @@ func init() {
} }
type commandVolumeMove struct { type commandVolumeMove struct {
grpcDialOption grpc.DialOption
} }
func (c *commandVolumeMove) Name() string { func (c *commandVolumeMove) Name() string {
@ -49,9 +48,6 @@ func (c *commandVolumeMove) Do(args []string, commandEnv *commandEnv, writer io.
fmt.Fprintf(writer, "received args: %+v\n", args) fmt.Fprintf(writer, "received args: %+v\n", args)
return fmt.Errorf("need 3 args of <source volume server host:port> <target volume server host:port> <volume id>") return fmt.Errorf("need 3 args of <source volume server host:port> <target volume server host:port> <volume id>")
} }
c.grpcDialOption = commandEnv.option.GrpcDialOption
ctx := context.Background()
sourceVolumeServer, targetVolumeServer, volumeIdString := args[0], args[1], args[2] sourceVolumeServer, targetVolumeServer, volumeIdString := args[0], args[1], args[2]
volumeId, err := needle.NewVolumeId(volumeIdString) volumeId, err := needle.NewVolumeId(volumeIdString)
@ -63,30 +59,36 @@ func (c *commandVolumeMove) Do(args []string, commandEnv *commandEnv, writer io.
return fmt.Errorf("source and target volume servers are the same!") return fmt.Errorf("source and target volume servers are the same!")
} }
ctx := context.Background()
return LiveMoveVolume(ctx, commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer, targetVolumeServer, 5*time.Second)
}
// LiveMoveVolume moves one volume from one source volume server to one target volume server, with idleTimeout to drain the incoming requests.
func LiveMoveVolume(ctx context.Context, grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer, targetVolumeServer string, idleTimeout time.Duration) (err error) {
log.Printf("copying volume %d from %s to %s", volumeId, sourceVolumeServer, targetVolumeServer) log.Printf("copying volume %d from %s to %s", volumeId, sourceVolumeServer, targetVolumeServer)
lastAppendAtNs, err := c.copyVolume(ctx, volumeId, sourceVolumeServer, targetVolumeServer) lastAppendAtNs, err := copyVolume(ctx, grpcDialOption, volumeId, sourceVolumeServer, targetVolumeServer)
if err != nil { if err != nil {
return fmt.Errorf("copy volume %d from %s to %s: %v", volumeId, sourceVolumeServer, targetVolumeServer, err) return fmt.Errorf("copy volume %d from %s to %s: %v", volumeId, sourceVolumeServer, targetVolumeServer, err)
} }
log.Printf("tailing volume %d from %s to %s", volumeId, sourceVolumeServer, targetVolumeServer) log.Printf("tailing volume %d from %s to %s", volumeId, sourceVolumeServer, targetVolumeServer)
if err = c.tailVolume(ctx, volumeId, sourceVolumeServer, targetVolumeServer, lastAppendAtNs, 5*time.Second); err != nil { if err = tailVolume(ctx, grpcDialOption, volumeId, sourceVolumeServer, targetVolumeServer, lastAppendAtNs, idleTimeout); err != nil {
return fmt.Errorf("tail volume %d from %s to %s: %v", volumeId, sourceVolumeServer, targetVolumeServer, err) return fmt.Errorf("tail volume %d from %s to %s: %v", volumeId, sourceVolumeServer, targetVolumeServer, err)
} }
log.Printf("deleting volume %d from %s", volumeId, sourceVolumeServer) log.Printf("deleting volume %d from %s", volumeId, sourceVolumeServer)
if err = c.deleteVolume(ctx, volumeId, sourceVolumeServer); err != nil { if err = deleteVolume(ctx, grpcDialOption, volumeId, sourceVolumeServer); err != nil {
return fmt.Errorf("delete volume %d from %s: %v", volumeId, sourceVolumeServer, err) return fmt.Errorf("delete volume %d from %s: %v", volumeId, sourceVolumeServer, err)
} }
log.Printf("moved volume %d from %s to %s", volumeId, sourceVolumeServer, targetVolumeServer) log.Printf("moved volume %d from %s to %s", volumeId, sourceVolumeServer, targetVolumeServer)
return nil return nil
} }
func (c *commandVolumeMove) copyVolume(ctx context.Context, volumeId needle.VolumeId, sourceVolumeServer, targetVolumeServer string) (lastAppendAtNs uint64, err error) { func copyVolume(ctx context.Context, grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer, targetVolumeServer string) (lastAppendAtNs uint64, err error) {
err = operation.WithVolumeServerClient(targetVolumeServer, c.grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { err = operation.WithVolumeServerClient(targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
resp, replicateErr := volumeServerClient.VolumeCopy(ctx, &volume_server_pb.VolumeCopyRequest{ resp, replicateErr := volumeServerClient.VolumeCopy(ctx, &volume_server_pb.VolumeCopyRequest{
VolumeId: uint32(volumeId), VolumeId: uint32(volumeId),
SourceDataNode: sourceVolumeServer, SourceDataNode: sourceVolumeServer,
@ -100,13 +102,13 @@ func (c *commandVolumeMove) copyVolume(ctx context.Context, volumeId needle.Volu
return return
} }
func (c *commandVolumeMove) tailVolume(ctx context.Context, volumeId needle.VolumeId, sourceVolumeServer, targetVolumeServer string, lastAppendAtNs uint64, timeout time.Duration) (err error) { func tailVolume(ctx context.Context, grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer, targetVolumeServer string, lastAppendAtNs uint64, idleTimeout time.Duration) (err error) {
return operation.WithVolumeServerClient(targetVolumeServer, c.grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { return operation.WithVolumeServerClient(targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
_, replicateErr := volumeServerClient.VolumeTailReceiver(ctx, &volume_server_pb.VolumeTailReceiverRequest{ _, replicateErr := volumeServerClient.VolumeTailReceiver(ctx, &volume_server_pb.VolumeTailReceiverRequest{
VolumeId: uint32(volumeId), VolumeId: uint32(volumeId),
SinceNs: lastAppendAtNs, SinceNs: lastAppendAtNs,
DrainingSeconds: uint32(timeout.Seconds()), IdleTimeoutSeconds: uint32(idleTimeout.Seconds()),
SourceVolumeServer: sourceVolumeServer, SourceVolumeServer: sourceVolumeServer,
}) })
return replicateErr return replicateErr
@ -114,8 +116,8 @@ func (c *commandVolumeMove) tailVolume(ctx context.Context, volumeId needle.Volu
} }
func (c *commandVolumeMove) deleteVolume(ctx context.Context, volumeId needle.VolumeId, sourceVolumeServer string) (err error) { func deleteVolume(ctx context.Context, grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer string) (err error) {
return operation.WithVolumeServerClient(sourceVolumeServer, c.grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { return operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
_, unmountErr := volumeServerClient.VolumeDelete(ctx, &volume_server_pb.VolumeDeleteRequest{ _, unmountErr := volumeServerClient.VolumeDelete(ctx, &volume_server_pb.VolumeDeleteRequest{
VolumeId: uint32(volumeId), VolumeId: uint32(volumeId),
}) })