query

package
v0.31.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

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.

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)
	}

}
Output:

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

Examples

Constants

View Source
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.

View Source
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.

Variables

This section is empty.

Functions

This section is empty.

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

func (o Request) MarshalXrd(w *xrdenc.WBuffer) error

MarshalXrd implements xrdproto.Marshaler.

func (*Request) ReqID

func (req *Request) ReqID() uint16

ReqID implements xrdproto.Request.ReqID.

func (*Request) ShouldSign

func (*Request) ShouldSign() bool

ShouldSign implements xrdproto.Request.ShouldSign.

func (*Request) UnmarshalXrd

func (o *Request) UnmarshalXrd(r *xrdenc.RBuffer) error

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

func (o Response) MarshalXrd(w *xrdenc.WBuffer) error

MarshalXrd implements xrdproto.Marshaler.

func (*Response) RespID

func (*Response) RespID() uint16

RespID implements xrdproto.Response.RespID.

func (*Response) UnmarshalXrd

func (o *Response) UnmarshalXrd(r *xrdenc.RBuffer) error

UnmarshalXrd implements xrdproto.Unmarshaler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL