mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-22 01:47:24 +08:00
scaffold for volume server query feature
This commit is contained in:
@@ -257,7 +257,3 @@ func (vs *VolumeServer) CopyFile(req *volume_server_pb.CopyFileRequest, stream v
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vs *VolumeServer) findVolumeOrEcVolumeLocation(volumeId needle.VolumeId) {
|
||||
|
||||
}
|
||||
|
62
weed/server/volume_grpc_query.go
Normal file
62
weed/server/volume_grpc_query.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package weed_server
|
||||
|
||||
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/tidwall/gjson"
|
||||
)
|
||||
|
||||
func (vs *VolumeServer) Query(req *volume_server_pb.QueryRequest, stream volume_server_pb.VolumeServer_QueryServer) error {
|
||||
|
||||
for _, fid := range req.FromFileIds {
|
||||
|
||||
vid, id_cookie, err := operation.ParseFileId(fid)
|
||||
if err != nil {
|
||||
glog.V(0).Infof("volume query failed to parse fid %s: %v", fid, err)
|
||||
return err
|
||||
}
|
||||
|
||||
n := new(needle.Needle)
|
||||
volumeId, _ := needle.NewVolumeId(vid)
|
||||
n.ParsePath(id_cookie)
|
||||
|
||||
cookie := n.Cookie
|
||||
if _, err := vs.store.ReadVolumeNeedle(volumeId, n); err != nil {
|
||||
glog.V(0).Infof("volume query failed to read fid %s: %v", fid, err)
|
||||
return err
|
||||
}
|
||||
|
||||
if n.Cookie != cookie {
|
||||
glog.V(0).Infof("volume query failed to read fid cookie %s: %v", fid, err)
|
||||
return err
|
||||
}
|
||||
|
||||
if req.InputSerialization.CsvInput!=nil{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if req.InputSerialization.JsonInput!=nil{
|
||||
|
||||
err = stream.Send(&volume_server_pb.QueriedStripe{
|
||||
Records:nil,
|
||||
})
|
||||
if err != nil {
|
||||
// println("sending", bytesread, "bytes err", err.Error())
|
||||
return err
|
||||
}
|
||||
gjson.ForEachLine(string(n.Data), func(line gjson.Result) bool{
|
||||
println(line.String())
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user