package query
import "go-hep.org/x/hep/xrootd/xrdproto/query"
Package query contains the types related to the query request.
See xrootd protocol specification (http://xrootd.org/doc/dev45/XRdv310.pdf, p. 79) for more details.
Code:play
Output:Example¶
package main
import (
"context"
"fmt"
"log"
"strings"
"go-hep.org/x/hep/xrootd"
"go-hep.org/x/hep/xrootd/xrdfs"
"go-hep.org/x/hep/xrootd/xrdproto/query"
)
func main() {
bkg := context.Background()
cl, err := xrootd.NewClient(bkg, "ccxrootdgotest.in2p3.fr:9001", "gopher")
if err != nil {
log.Fatalf("could not create client: %v", err)
}
defer cl.Close()
fs := cl.FS()
f, err := fs.Open(bkg, "/tmp/dir1/file1.txt", xrdfs.OpenModeOwnerRead, xrdfs.OpenOptionsOpenRead)
if err != nil {
log.Fatalf("open error: %v", err)
}
defer f.Close(bkg)
var (
resp query.Response
req = query.Request{
Query: query.Space,
Handle: f.Handle(),
Args: []byte("/tmp/dir1/file1.txt"),
}
)
id, err := cl.Send(bkg, &resp, &req)
if err != nil {
log.Fatalf("space request error: %v", err)
}
fmt.Printf("sess: %s\n", id)
// fmt.Printf("space: %q\n", resp.Data)
cfg := []string{
"bind_max",
"chksum",
"cid", "cms", "pio_max",
"readv_ior_max",
"readv_iov_max",
"role",
"sitename",
"tpc",
"version",
"wan_port",
"wan_window",
"window",
}
req = query.Request{
Query: query.Config,
Args: []byte(strings.Join(cfg, " ")),
}
id, err = cl.Send(bkg, &resp, &req)
if err != nil {
log.Fatalf("config request error: %v", err)
}
fmt.Printf("sess: %s\n", id)
for i, v := range strings.Split(strings.TrimRight(string(resp.Data), "\n"), "\n") {
if v == cfg[i] {
fmt.Printf("config: %s=N/A\n", v)
continue
}
fmt.Printf("config: %s=%q\n", cfg[i], v)
}
}
sess: ccxrootdgotest.in2p3.fr:9001
sess: ccxrootdgotest.in2p3.fr:9001
config: bind_max="15"
config: chksum="0:md5"
config: cid=N/A
config: cms="none|"
config: pio_max="5"
config: readv_ior_max="2097136"
config: readv_iov_max="1024"
config: role="server"
config: sitename=N/A
config: tpc=N/A
config: version="v4.8.5"
config: wan_port=N/A
config: wan_window=N/A
config: window="87380"
Index ¶
- Constants
- type Request
- func (o Request) MarshalXrd(w *xrdenc.WBuffer) error
- func (req *Request) ReqID() uint16
- func (*Request) ShouldSign() bool
- func (o *Request) UnmarshalXrd(r *xrdenc.RBuffer) error
- type Response
Examples ¶
Constants ¶
const ( Stats = 1 // Query server statistics Prepare = 2 // Query prepare status Checksum = 3 // Query file checksum XAttr = 4 // Query file extended attributes Space = 5 // Query server logical space statistics CancelChecksum = 6 // Query file checksum cancellation Config = 7 // Query server configuration Visa = 8 // Query file visa attributes Opaque1 = 16 // Query implementation-dependent information Opaque2 = 32 // Query implementation-dependent information Opaque3 = 64 // Query implementation-dependent information )
Query parameters.
const RequestID uint16 = 3001
RequestID is the id of the request, it is sent as part of message. See xrootd protocol specification for details: http://xrootd.org/doc/dev45/XRdv310.pdf, 2.3 Client Request Format.
Types ¶
type Request ¶
type Request struct { Query uint16 Handle xrdfs.FileHandle Args []byte // contains filtered or unexported fields }
Request holds the query request parameters.
func (Request) MarshalXrd ¶
MarshalXrd implements xrdproto.Marshaler.
func (*Request) ReqID ¶
ReqID implements xrdproto.Request.ReqID.
func (*Request) ShouldSign ¶
ShouldSign implements xrdproto.Request.ShouldSign.
func (*Request) UnmarshalXrd ¶
UnmarshalXrd implements xrdproto.Unmarshaler.
type Response ¶
type Response struct { Data []byte }
Response is the response issued by the server to a query request.
func (Response) MarshalXrd ¶
MarshalXrd implements xrdproto.Marshaler.
func (*Response) RespID ¶
RespID implements xrdproto.Response.RespID.
func (*Response) UnmarshalXrd ¶
UnmarshalXrd implements xrdproto.Unmarshaler.
Source Files ¶
query.go
- Version
- v0.36.0 (latest)
- Published
- Nov 15, 2024
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 1 day ago –
Tools for package owners.