migrate volume sync status to grpc API on volume server

This commit is contained in:
Chris Lu 2018-10-15 01:19:15 -07:00
parent b423bb9e2d
commit fda771c83f
10 changed files with 215 additions and 92 deletions

View file

@ -59,7 +59,7 @@ func runBackup(cmd *Command, args []string) bool {
}
volumeServer := lookup.Locations[0].Url
stats, err := operation.GetVolumeSyncStatus(volumeServer, vid.String())
stats, err := operation.GetVolumeSyncStatus(volumeServer, uint32(vid))
if err != nil {
fmt.Printf("Error get volume %d status: %v\n", vid, err)
return true

View file

@ -1,41 +1,24 @@
package operation
import (
"encoding/json"
"fmt"
"context"
"net/url"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
. "github.com/chrislusf/seaweedfs/weed/storage/types"
"github.com/chrislusf/seaweedfs/weed/util"
)
type SyncVolumeResponse struct {
Replication string `json:"Replication,omitempty"`
Ttl string `json:"Ttl,omitempty"`
TailOffset uint64 `json:"TailOffset,omitempty"`
CompactRevision uint16 `json:"CompactRevision,omitempty"`
IdxFileSize uint64 `json:"IdxFileSize,omitempty"`
Error string `json:"error,omitempty"`
}
func GetVolumeSyncStatus(server string, vid uint32) (resp *volume_server_pb.VolumeSyncStatusResponse, err error) {
func GetVolumeSyncStatus(server string, vid string) (*SyncVolumeResponse, error) {
values := make(url.Values)
values.Add("volume", vid)
jsonBlob, err := util.Post("http://"+server+"/admin/sync/status", values)
glog.V(2).Info("sync volume result :", string(jsonBlob))
if err != nil {
return nil, err
}
var ret SyncVolumeResponse
err = json.Unmarshal(jsonBlob, &ret)
if err != nil {
return nil, err
}
if ret.Error != "" {
return nil, fmt.Errorf("Volume %s get sync status error: %s", vid, ret.Error)
}
return &ret, nil
WithVolumeServerClient(server, func(client volume_server_pb.VolumeServerClient) error {
resp, err = client.VolumeSyncStatus(context.Background(), &volume_server_pb.VolumeSyncStatusRequest{
VolumdId: vid,
})
return nil
})
return
}
func GetVolumeIdxEntries(server string, vid string, eachEntryFn func(key NeedleId, offset Offset, size uint32)) error {

View file

@ -21,6 +21,8 @@ service VolumeServer {
}
rpc AssignVolume (AssignVolumeRequest) returns (AssignVolumeResponse) {
}
rpc VolumeSyncStatus (VolumeSyncStatusRequest) returns (VolumeSyncStatusResponse) {
}
}
//////////////////////////////////////////////////
@ -83,3 +85,15 @@ message AssignVolumeRequest {
}
message AssignVolumeResponse {
}
message VolumeSyncStatusRequest {
uint32 volumd_id = 1;
}
message VolumeSyncStatusResponse {
uint32 volumd_id = 1;
string replication = 4;
string ttl = 5;
uint64 tail_offset = 6;
uint32 compact_revision = 7;
uint64 idx_file_size = 8;
}

View file

@ -25,6 +25,8 @@ It has these top-level messages:
DeleteCollectionResponse
AssignVolumeRequest
AssignVolumeResponse
VolumeSyncStatusRequest
VolumeSyncStatusResponse
*/
package volume_server_pb
@ -320,6 +322,78 @@ func (m *AssignVolumeResponse) String() string { return proto.Compact
func (*AssignVolumeResponse) ProtoMessage() {}
func (*AssignVolumeResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} }
type VolumeSyncStatusRequest struct {
VolumdId uint32 `protobuf:"varint,1,opt,name=volumd_id,json=volumdId" json:"volumd_id,omitempty"`
}
func (m *VolumeSyncStatusRequest) Reset() { *m = VolumeSyncStatusRequest{} }
func (m *VolumeSyncStatusRequest) String() string { return proto.CompactTextString(m) }
func (*VolumeSyncStatusRequest) ProtoMessage() {}
func (*VolumeSyncStatusRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} }
func (m *VolumeSyncStatusRequest) GetVolumdId() uint32 {
if m != nil {
return m.VolumdId
}
return 0
}
type VolumeSyncStatusResponse struct {
VolumdId uint32 `protobuf:"varint,1,opt,name=volumd_id,json=volumdId" json:"volumd_id,omitempty"`
Replication string `protobuf:"bytes,4,opt,name=replication" json:"replication,omitempty"`
Ttl string `protobuf:"bytes,5,opt,name=ttl" json:"ttl,omitempty"`
TailOffset uint64 `protobuf:"varint,6,opt,name=tail_offset,json=tailOffset" json:"tail_offset,omitempty"`
CompactRevision uint32 `protobuf:"varint,7,opt,name=compact_revision,json=compactRevision" json:"compact_revision,omitempty"`
IdxFileSize uint64 `protobuf:"varint,8,opt,name=idx_file_size,json=idxFileSize" json:"idx_file_size,omitempty"`
}
func (m *VolumeSyncStatusResponse) Reset() { *m = VolumeSyncStatusResponse{} }
func (m *VolumeSyncStatusResponse) String() string { return proto.CompactTextString(m) }
func (*VolumeSyncStatusResponse) ProtoMessage() {}
func (*VolumeSyncStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} }
func (m *VolumeSyncStatusResponse) GetVolumdId() uint32 {
if m != nil {
return m.VolumdId
}
return 0
}
func (m *VolumeSyncStatusResponse) GetReplication() string {
if m != nil {
return m.Replication
}
return ""
}
func (m *VolumeSyncStatusResponse) GetTtl() string {
if m != nil {
return m.Ttl
}
return ""
}
func (m *VolumeSyncStatusResponse) GetTailOffset() uint64 {
if m != nil {
return m.TailOffset
}
return 0
}
func (m *VolumeSyncStatusResponse) GetCompactRevision() uint32 {
if m != nil {
return m.CompactRevision
}
return 0
}
func (m *VolumeSyncStatusResponse) GetIdxFileSize() uint64 {
if m != nil {
return m.IdxFileSize
}
return 0
}
func init() {
proto.RegisterType((*BatchDeleteRequest)(nil), "volume_server_pb.BatchDeleteRequest")
proto.RegisterType((*BatchDeleteResponse)(nil), "volume_server_pb.BatchDeleteResponse")
@ -337,6 +411,8 @@ func init() {
proto.RegisterType((*DeleteCollectionResponse)(nil), "volume_server_pb.DeleteCollectionResponse")
proto.RegisterType((*AssignVolumeRequest)(nil), "volume_server_pb.AssignVolumeRequest")
proto.RegisterType((*AssignVolumeResponse)(nil), "volume_server_pb.AssignVolumeResponse")
proto.RegisterType((*VolumeSyncStatusRequest)(nil), "volume_server_pb.VolumeSyncStatusRequest")
proto.RegisterType((*VolumeSyncStatusResponse)(nil), "volume_server_pb.VolumeSyncStatusResponse")
}
// Reference imports to suppress errors if they are not otherwise used.
@ -358,6 +434,7 @@ type VolumeServerClient interface {
VacuumVolumeCleanup(ctx context.Context, in *VacuumVolumeCleanupRequest, opts ...grpc.CallOption) (*VacuumVolumeCleanupResponse, error)
DeleteCollection(ctx context.Context, in *DeleteCollectionRequest, opts ...grpc.CallOption) (*DeleteCollectionResponse, error)
AssignVolume(ctx context.Context, in *AssignVolumeRequest, opts ...grpc.CallOption) (*AssignVolumeResponse, error)
VolumeSyncStatus(ctx context.Context, in *VolumeSyncStatusRequest, opts ...grpc.CallOption) (*VolumeSyncStatusResponse, error)
}
type volumeServerClient struct {
@ -431,6 +508,15 @@ func (c *volumeServerClient) AssignVolume(ctx context.Context, in *AssignVolumeR
return out, nil
}
func (c *volumeServerClient) VolumeSyncStatus(ctx context.Context, in *VolumeSyncStatusRequest, opts ...grpc.CallOption) (*VolumeSyncStatusResponse, error) {
out := new(VolumeSyncStatusResponse)
err := grpc.Invoke(ctx, "/volume_server_pb.VolumeServer/VolumeSyncStatus", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for VolumeServer service
type VolumeServerServer interface {
@ -442,6 +528,7 @@ type VolumeServerServer interface {
VacuumVolumeCleanup(context.Context, *VacuumVolumeCleanupRequest) (*VacuumVolumeCleanupResponse, error)
DeleteCollection(context.Context, *DeleteCollectionRequest) (*DeleteCollectionResponse, error)
AssignVolume(context.Context, *AssignVolumeRequest) (*AssignVolumeResponse, error)
VolumeSyncStatus(context.Context, *VolumeSyncStatusRequest) (*VolumeSyncStatusResponse, error)
}
func RegisterVolumeServerServer(s *grpc.Server, srv VolumeServerServer) {
@ -574,6 +661,24 @@ func _VolumeServer_AssignVolume_Handler(srv interface{}, ctx context.Context, de
return interceptor(ctx, in, info, handler)
}
func _VolumeServer_VolumeSyncStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VolumeSyncStatusRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(VolumeServerServer).VolumeSyncStatus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/volume_server_pb.VolumeServer/VolumeSyncStatus",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(VolumeServerServer).VolumeSyncStatus(ctx, req.(*VolumeSyncStatusRequest))
}
return interceptor(ctx, in, info, handler)
}
var _VolumeServer_serviceDesc = grpc.ServiceDesc{
ServiceName: "volume_server_pb.VolumeServer",
HandlerType: (*VolumeServerServer)(nil),
@ -606,6 +711,10 @@ var _VolumeServer_serviceDesc = grpc.ServiceDesc{
MethodName: "AssignVolume",
Handler: _VolumeServer_AssignVolume_Handler,
},
{
MethodName: "VolumeSyncStatus",
Handler: _VolumeServer_VolumeSyncStatus_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "volume_server.proto",
@ -614,41 +723,48 @@ var _VolumeServer_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("volume_server.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 571 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x55, 0x4b, 0x6f, 0xd3, 0x40,
0x10, 0xae, 0x9b, 0x57, 0x33, 0x49, 0xa4, 0x30, 0xa9, 0x5a, 0xd7, 0x85, 0x2a, 0x5a, 0x1e, 0x0a,
0x6d, 0x09, 0x52, 0x39, 0x50, 0x6e, 0x40, 0xe1, 0xd0, 0x13, 0x92, 0x91, 0x7a, 0x01, 0x29, 0x72,
0x9c, 0x25, 0xb5, 0xba, 0xce, 0xba, 0xbb, 0xeb, 0x4a, 0xf0, 0x0f, 0xf8, 0x27, 0xfc, 0x4c, 0x94,
0xf5, 0xa3, 0x7e, 0x24, 0xb2, 0x6f, 0xf6, 0xec, 0xf7, 0x98, 0x59, 0xcf, 0x97, 0xc0, 0xe8, 0x81,
0xb3, 0xd0, 0xa7, 0x33, 0x49, 0xc5, 0x03, 0x15, 0xd3, 0x40, 0x70, 0x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e2, 0xe3, 0x69,
0x99, 0xbd, 0x2d, 0x56, 0xd6, 0x59, 0x2d, 0x6c, 0xea, 0xa7, 0x60, 0xb4, 0x61, 0x93, 0xf1, 0xbc,
0x42, 0x25, 0x97, 0x26, 0xeb, 0x4d, 0x4d, 0x74, 0xea, 0x7a, 0x0f, 0x58, 0x5e, 0x73, 0x3c, 0xab,
0x94, 0x79, 0x8c, 0x91, 0x75, 0x5e, 0x0f, 0xbc, 0x75, 0xd0, 0x28, 0x00, 0x95, 0x83, 0xe6, 0x22,
0x56, 0x39, 0x68, 0x21, 0x55, 0x3b, 0x78, 0x07, 0xc3, 0x62, 0x38, 0xf0, 0xf5, 0xb6, 0x5f, 0xec,
0x52, 0xf6, 0xac, 0xd3, 0x3a, 0xd0, 0xd4, 0x6c, 0x06, 0xfd, 0xec, 0x0a, 0xe3, 0x86, 0xa5, 0xdb,
0x10, 0x46, 0xeb, 0x55, 0x15, 0x2c, 0x31, 0x98, 0xb7, 0xf5, 0xbf, 0xdb, 0xbb, 0xff, 0x01, 0x00,
0x00, 0xff, 0xff, 0x8b, 0xec, 0xe8, 0xd9, 0xf4, 0x06, 0x00, 0x00,
// 683 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x56, 0x5b, 0x4f, 0xdb, 0x4c,
0x10, 0xc5, 0xe4, 0x06, 0x93, 0x44, 0x5f, 0xbe, 0x0d, 0x02, 0x63, 0x5a, 0x1a, 0x6d, 0x2f, 0x0a,
0x97, 0x52, 0x89, 0x4a, 0x2d, 0x7d, 0x6b, 0x4b, 0x5b, 0x89, 0x27, 0x24, 0x23, 0xf1, 0xd2, 0x4a,
0x96, 0x71, 0x06, 0x58, 0xb1, 0x89, 0xcd, 0xee, 0x1a, 0x01, 0xbf, 0xa8, 0xff, 0xa9, 0xff, 0xa3,
0xcf, 0x55, 0xd6, 0x4e, 0xea, 0x5b, 0x64, 0xf7, 0xc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4a, 0xe8, 0x5c, 0xcc, 0x81, 0x4e, 0x72, 0xb1, 0x49, 0xc1,
0xd0, 0x15, 0x58, 0x94, 0xf5, 0xaa, 0x2c, 0x2c, 0xd9, 0x4d, 0x76, 0xd1, 0x8b, 0xba, 0x59, 0xe0,
0x22, 0x45, 0xdd, 0x2c, 0xf2, 0x0d, 0xba, 0x74, 0xd1, 0xd4, 0x7f, 0x30, 0xde, 0xfe, 0x09, 0x00,
0x00, 0xff, 0xff, 0xf6, 0x2c, 0x4e, 0x35, 0x77, 0x08, 0x00, 0x00,
}

View file

@ -0,0 +1,25 @@
package weed_server
import (
"context"
"fmt"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/storage"
)
func (vs *VolumeServer) VolumeSyncStatus(ctx context.Context, req *volume_server_pb.VolumeSyncStatusRequest) (*volume_server_pb.VolumeSyncStatusResponse, error) {
v := vs.store.GetVolume(storage.VolumeId(req.VolumdId))
if v == nil {
return nil, fmt.Errorf("Not Found Volume Id %d", req.VolumdId)
}
resp := v.GetVolumeSyncStatus()
glog.V(2).Infof("volume sync status %d", req.VolumdId)
return resp, nil
}

View file

@ -47,7 +47,6 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
handleStaticResources(adminMux)
adminMux.HandleFunc("/ui/index.html", vs.uiStatusHandler)
adminMux.HandleFunc("/status", vs.guard.WhiteList(vs.statusHandler))
adminMux.HandleFunc("/admin/sync/status", vs.guard.WhiteList(vs.getVolumeSyncStatusHandler))
adminMux.HandleFunc("/admin/sync/index", vs.guard.WhiteList(vs.getVolumeIndexContentHandler))
adminMux.HandleFunc("/admin/sync/data", vs.guard.WhiteList(vs.getVolumeDataContentHandler))
adminMux.HandleFunc("/admin/volume/mount", vs.guard.WhiteList(vs.getVolumeMountHandler))

View file

@ -2,11 +2,11 @@ package weed_server
import (
"fmt"
"net/http"
"path/filepath"
"github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/util"
"net/http"
"path/filepath"
)
func (vs *VolumeServer) statusHandler(w http.ResponseWriter, r *http.Request) {
@ -29,6 +29,7 @@ func (vs *VolumeServer) statsDiskHandler(w http.ResponseWriter, r *http.Request)
writeJsonQuiet(w, r, http.StatusOK, m)
}
// TODO delete this when volume sync is all moved to grpc
func (vs *VolumeServer) getVolume(volumeParameterName string, r *http.Request) (*storage.Volume, error) {
vid, err := vs.getVolumeId(volumeParameterName, r)
if err != nil {

View file

@ -4,27 +4,11 @@ import (
"fmt"
"net/http"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/storage/types"
"github.com/chrislusf/seaweedfs/weed/util"
)
func (vs *VolumeServer) getVolumeSyncStatusHandler(w http.ResponseWriter, r *http.Request) {
v, err := vs.getVolume("volume", r)
if v == nil {
writeJsonError(w, r, http.StatusBadRequest, err)
return
}
syncStat := v.GetVolumeSyncStatus()
if syncStat.Error != "" {
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Get Volume %d status error: %s", v.Id, syncStat.Error))
glog.V(2).Infoln("getVolumeSyncStatusHandler volume =", r.FormValue("volume"), ", error =", err)
} else {
writeJsonQuiet(w, r, http.StatusOK, syncStat)
}
}
func (vs *VolumeServer) getVolumeIndexContentHandler(w http.ResponseWriter, r *http.Request) {
v, err := vs.getVolume("volume", r)
if v == nil {

View file

@ -11,6 +11,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
. "github.com/chrislusf/seaweedfs/weed/storage/types"
"github.com/chrislusf/seaweedfs/weed/util"
@ -142,7 +143,7 @@ func (v *Volume) trySynchronizing(volumeServer string, masterMap *needle.Compact
func fetchVolumeFileEntries(volumeServer string, vid VolumeId) (m *needle.CompactMap, lastOffset uint64, compactRevision uint16, err error) {
m = needle.NewCompactMap()
syncStatus, err := operation.GetVolumeSyncStatus(volumeServer, vid.String())
syncStatus, err := operation.GetVolumeSyncStatus(volumeServer, uint32(vid))
if err != nil {
return m, 0, 0, err
}
@ -159,17 +160,17 @@ func fetchVolumeFileEntries(volumeServer string, vid VolumeId) (m *needle.Compac
})
glog.V(2).Infof("server %s volume %d, entries %d, last offset %d, revision %d", volumeServer, vid, total, syncStatus.TailOffset, syncStatus.CompactRevision)
return m, syncStatus.TailOffset, syncStatus.CompactRevision, err
return m, syncStatus.TailOffset, uint16(syncStatus.CompactRevision), err
}
func (v *Volume) GetVolumeSyncStatus() operation.SyncVolumeResponse {
var syncStatus = operation.SyncVolumeResponse{}
func (v *Volume) GetVolumeSyncStatus() *volume_server_pb.VolumeSyncStatusResponse {
var syncStatus = &volume_server_pb.VolumeSyncStatusResponse{}
if stat, err := v.dataFile.Stat(); err == nil {
syncStatus.TailOffset = uint64(stat.Size())
}
syncStatus.IdxFileSize = v.nm.IndexFileSize()
syncStatus.CompactRevision = v.SuperBlock.CompactRevision
syncStatus.CompactRevision = uint32(v.SuperBlock.CompactRevision)
syncStatus.Ttl = v.SuperBlock.Ttl.String()
syncStatus.Replication = v.SuperBlock.ReplicaPlacement.String()
return syncStatus

View file

@ -3,9 +3,9 @@ package topology
import (
"context"
"github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/storage"
)
type AllocateVolumeResult struct {