Browse Source

Added VolumeNeedleStatus volume server grpc method

This is needed for the diffing tool to get the cookie for a needle
pull/1397/head
James Hartig 4 years ago
parent
commit
229f11c660
  1. 15
      weed/pb/volume_server.proto
  2. 814
      weed/pb/volume_server_pb/volume_server.pb.go
  3. 42
      weed/server/volume_grpc_admin.go

15
weed/pb/volume_server.proto

@ -86,6 +86,8 @@ service VolumeServer {
rpc Query (QueryRequest) returns (stream QueriedStripe) {
}
rpc VolumeNeedleStatus (VolumeNeedleStatusRequest) returns (VolumeNeedleStatusResponse) {
}
}
//////////////////////////////////////////////////
@ -463,3 +465,16 @@ message QueryRequest {
message QueriedStripe {
bytes records = 1;
}
message VolumeNeedleStatusRequest {
uint32 volume_id = 1;
uint64 needle_id = 2;
}
message VolumeNeedleStatusResponse {
uint64 needle_id = 1;
uint32 cookie = 2;
uint32 size = 3;
uint64 last_modified = 4;
uint32 crc = 5;
string ttl = 6;
}

814
weed/pb/volume_server_pb/volume_server.pb.go
File diff suppressed because it is too large
View File

42
weed/server/volume_grpc_admin.go

@ -10,6 +10,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
"github.com/chrislusf/seaweedfs/weed/storage/super_block"
"github.com/chrislusf/seaweedfs/weed/storage/types"
)
func (vs *VolumeServer) DeleteCollection(ctx context.Context, req *volume_server_pb.DeleteCollectionRequest) (*volume_server_pb.DeleteCollectionResponse, error) {
@ -166,3 +167,44 @@ func (vs *VolumeServer) VolumeServerStatus(ctx context.Context, req *volume_serv
return resp, nil
}
func (vs *VolumeServer) VolumeNeedleStatus(ctx context.Context, req *volume_server_pb.VolumeNeedleStatusRequest) (*volume_server_pb.VolumeNeedleStatusResponse, error) {
resp := &volume_server_pb.VolumeNeedleStatusResponse{}
volumeId := needle.VolumeId(req.VolumeId)
n := &needle.Needle{
Id: types.NeedleId(req.NeedleId),
}
var count int
var err error
hasVolume := vs.store.HasVolume(volumeId)
if !hasVolume {
_, hasEcVolume := vs.store.FindEcVolume(volumeId)
if !hasEcVolume {
return nil, fmt.Errorf("volume not found %d", req.VolumeId)
}
count, err = vs.store.ReadEcShardNeedle(volumeId, n)
} else {
count, err = vs.store.ReadVolumeNeedle(volumeId, n)
}
if err != nil {
return nil, err
}
if count < 0 {
return nil, fmt.Errorf("needle not found %d", n.Id)
}
resp.NeedleId = uint64(n.Id)
resp.Cookie = uint32(n.Cookie)
resp.Size = n.Size
resp.LastModified = n.LastModified
resp.Crc = n.Checksum.Value()
if n.HasTtl() {
resp.Ttl = n.Ttl.String()
}
return resp, nil
}
Loading…
Cancel
Save