Documentation
¶
Index ¶
- Constants
- Variables
- func Close(c io.Closer)
- func CreateSizedFile(path string, size int64) error
- func IsCloudPath(path string) bool
- func RunCp(cmd *CpCmd) error
- func ValidatePfsPath(paths []string, userName string) error
- type Chunk
- type ChunkMeta
- type ChunkMetaCmd
- type Command
- type CpCmd
- type CpCmdResult
- type LsCmd
- func (p *LsCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus
- func (*LsCmd) Name() string
- func (p *LsCmd) Run() (interface{}, error)
- func (p *LsCmd) SetFlags(f *flag.FlagSet)
- func (*LsCmd) Synopsis() string
- func (p *LsCmd) ToJSON() ([]byte, error)
- func (p *LsCmd) ToURLParam() url.Values
- func (*LsCmd) Usage() string
- func (p *LsCmd) ValidateCloudArgs(userName string) error
- func (p *LsCmd) ValidateLocalArgs() error
- type LsResult
- type MkdirCmd
- func (p *MkdirCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus
- func (*MkdirCmd) Name() string
- func (p *MkdirCmd) Run() (interface{}, error)
- func (p *MkdirCmd) SetFlags(f *flag.FlagSet)
- func (*MkdirCmd) Synopsis() string
- func (p *MkdirCmd) ToJSON() ([]byte, error)
- func (p *MkdirCmd) ToURLParam() url.Values
- func (*MkdirCmd) Usage() string
- func (p *MkdirCmd) ValidateCloudArgs(userName string) error
- func (p *MkdirCmd) ValidateLocalArgs() error
- type MkdirResult
- type RmCmd
- func (p *RmCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus
- func (*RmCmd) Name() string
- func (p *RmCmd) Run() (interface{}, error)
- func (p *RmCmd) SetFlags(f *flag.FlagSet)
- func (*RmCmd) Synopsis() string
- func (p *RmCmd) ToJSON() ([]byte, error)
- func (p *RmCmd) ToURLParam() url.Values
- func (*RmCmd) Usage() string
- func (p *RmCmd) ValidateCloudArgs(userName string) error
- func (p *RmCmd) ValidateLocalArgs() error
- type RmResult
- type StatCmd
- type TouchCmd
- type TouchResult
Constants ¶
const ( // DefaultMultiPartBoundary is the default multipart form boudary. DefaultMultiPartBoundary = "8d7b0e5709d756e21e971ff4d9ac3b20" // MaxJSONRequestSize is the max body size when server receives a request. MaxJSONRequestSize = 2048 )
const ( // StatusFileNotFound is a error string of that there is no file or directory. StatusFileNotFound = "no such file or directory" // StatusDirectoryNotAFile is a error string of that the destination should be a file. StatusDirectoryNotAFile = "should be a file not a directory" // StatusCopyFromLocalToLocal is a error string of that this system does't support copy local to local. StatusCopyFromLocalToLocal = "don't support copy local to local" // StatusDestShouldBeDirectory is a error string of that destination shoule be a directory. StatusDestShouldBeDirectory = "dest should be a directory" // StatusOnlySupportFiles is a error string of that the system only support upload or download files not directories. StatusOnlySupportFiles = "only support upload or download files not directories" // StatusBadFileSize is a error string of that the file size is no valid. StatusBadFileSize = "bad file size" // StatusDirectoryAlreadyExist is a error string of that the directory is already exist. StatusDirectoryAlreadyExist = "directory already exist" // StatusBadChunkSize is a error string of that the chunksize is error. StatusBadChunkSize = "chunksize error" // StatusShouldBePfsPath is a error string of that a path should be a pfs path. StatusShouldBePfsPath = "should be pfs path" // StatusNotEnoughArgs is a error string of that there is not enough arguments. StatusNotEnoughArgs = "not enough arguments" // StatusInvalidArgs is a error string of that arguments are not valid. StatusInvalidArgs = "invalid arguments" // StatusUnAuthorized is a error string of that what you request should have authorization. StatusUnAuthorized = "what you request is unauthorized" // StatusJSONErr is a error string of that the system parses json error. StatusJSONErr = "parse json error" // StatusCannotDelDirectory is a error string of that what you input can't delete a directory. StatusCannotDelDirectory = "can't del directory" // StatusAlreadyExist is a error string of that the destination is already exist. StatusAlreadyExist = "already exist" // StatusBadPath is a error string of that the form of path is not correct. StatusBadPath = "the path should be in format eg:/pf/datacentername/" )
const (
// ChunkMetaCmdName is the name of GetChunkMeta command.
ChunkMetaCmdName = "GetChunkMeta"
)
const (
// StatCmdName means stat command name.
StatCmdName = "stat"
)
const (
// TouchCmdName is the name of touch command.
TouchCmdName = "touch"
)
Variables ¶
var Config = config.ParseDefaultConfig()
Config is global config object for pfs commandline
Functions ¶
func CreateSizedFile ¶
CreateSizedFile creates a file with specified size.
func IsCloudPath ¶
IsCloudPath returns whether a path is a pfspath.
func ValidatePfsPath ¶
ValidatePfsPath returns whether a path is a pfspath.
Types ¶
type Chunk ¶
Chunk respresents a chunk info.
func ParseChunk ¶
ParseChunk get a Chunk struct from path. path example:
path=/pfs/datacenter1/1.txt&offset=4096&chunksize=4096
func (*Chunk) LoadChunkData ¶
LoadChunkData loads a specified chunk to io.Writer.
func (*Chunk) SaveChunkData ¶
SaveChunkData save data from io.Reader.
func (*Chunk) ToURLParam ¶
ToURLParam encodes variables to url encoding parameters.
type ChunkMeta ¶
type ChunkMeta struct { Offset int64 `json:"offset"` Checksum string `json:"checksum"` Len int64 `json:"len"` }
ChunkMeta holds the chunk meta's info.
func GetChunkMeta ¶
GetChunkMeta gets chunk metas from path of file.
type ChunkMetaCmd ¶
type ChunkMetaCmd struct { Method string `json:"method"` FilePath string `json:"path"` ChunkSize int64 `json:"chunksize"` }
ChunkMetaCmd is a command.
func NewChunkMetaCmdFromURLParam ¶
func NewChunkMetaCmdFromURLParam(r *http.Request) (*ChunkMetaCmd, error)
NewChunkMetaCmdFromURLParam get a new ChunkMetaCmd.
func (*ChunkMetaCmd) Run ¶
func (p *ChunkMetaCmd) Run() (interface{}, error)
Run is a functions which run ChunkMetaCmd.
func (*ChunkMetaCmd) ToJSON ¶
func (p *ChunkMetaCmd) ToJSON() ([]byte, error)
ToJSON encodes ChunkMetaCmd to JSON string.
func (*ChunkMetaCmd) ToURLParam ¶
func (p *ChunkMetaCmd) ToURLParam() url.Values
ToURLParam encodes ChunkMetaCmd to URL encoding string.
func (*ChunkMetaCmd) ValidateCloudArgs ¶
func (p *ChunkMetaCmd) ValidateCloudArgs(userName string) error
ValidateCloudArgs checks the conditions when running on cloud.
func (*ChunkMetaCmd) ValidateLocalArgs ¶
func (p *ChunkMetaCmd) ValidateLocalArgs() error
ValidateLocalArgs checks the conditions when running locally.
type Command ¶
type Command interface { // ToURLParam generates url.Values of the command struct. ToURLParam() url.Values // ToJSON generates JSON string of the command struct. ToJSON() ([]byte, error) // Run runs a command. Run() (interface{}, error) // ValidateLocalArgs validates arguments when running locally. ValidateLocalArgs() error // ValidateCloudArgs validates arguments when running on cloud. ValidateCloudArgs(userName string) error }
Command is a interface of all commands.
type CpCmd ¶
CpCmd means copy-command.
func (*CpCmd) Execute ¶
func (p *CpCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus
Execute runs CpCmd.
func (*CpCmd) PartToString ¶
PartToString prints command's info.
type CpCmdResult ¶
CpCmdResult means the copy-command's result.
type LsCmd ¶
LsCmd means LsCmd structure.
func NewLsCmdFromURLParam ¶
NewLsCmdFromURLParam returns a new LsCmd according path variable.
func (*LsCmd) Execute ¶
func (p *LsCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus
Execute runs a LsCmd.
func (*LsCmd) ToURLParam ¶
ToURLParam encoding LsCmd to URL Encoding string.
func (*LsCmd) ValidateCloudArgs ¶
ValidateCloudArgs checks the conditions when running on cloud.
func (*LsCmd) ValidateLocalArgs ¶
ValidateLocalArgs checks the conditions when running local.
type LsResult ¶
type LsResult struct { Path string `json:"Path"` ModTime int64 `json:"ModTime"` Size int64 `json:"Size"` IsDir bool `json:"IsDir"` }
LsResult represents a LsCmd's result.
type MkdirCmd ¶
MkdirCmd means Mkdir command.
func (*MkdirCmd) Execute ¶
func (p *MkdirCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus
Execute runs a MkdirCmd.
func (*MkdirCmd) ToURLParam ¶
ToURLParam need not to be implemented.
func (*MkdirCmd) ValidateCloudArgs ¶
ValidateCloudArgs checks the conditions when running on cloud.
func (*MkdirCmd) ValidateLocalArgs ¶
ValidateLocalArgs checks the conditions when running on local.
type MkdirResult ¶
type MkdirResult struct {
Path string `json:"path"`
}
MkdirResult means Mkdir command's result.
func RemoteMkdir ¶
func RemoteMkdir(cmd *MkdirCmd) ([]MkdirResult, error)
RemoteMkdir creat a directory on cloud.
type RmCmd ¶
RmCmd means Rm command.
func (*RmCmd) Execute ¶
func (p *RmCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus
Execute runs a RmCmd.
func (*RmCmd) ToURLParam ¶
ToURLParam needs not to be implemented.
func (*RmCmd) ValidateCloudArgs ¶
ValidateCloudArgs checks the conditions when running on cloud.
func (*RmCmd) ValidateLocalArgs ¶
ValidateLocalArgs checks the conditions when running local.
type RmResult ¶
type RmResult struct {
Path string `json:"path"`
}
RmResult means Rm-command's result.
type StatCmd ¶
StatCmd means stat command.
func NewStatCmdFromURLParam ¶
NewStatCmdFromURLParam return a new StatCmd.
func (*StatCmd) ToURLParam ¶
ToURLParam encodes StatCmd to URL Encoding string.
func (*StatCmd) ValidateCloudArgs ¶
ValidateCloudArgs checks the conditions when running on cloud.
func (*StatCmd) ValidateLocalArgs ¶
ValidateLocalArgs checks the condition when running local.
type TouchCmd ¶
type TouchCmd struct { Method string `json:"method"` FileSize int64 `json:"filesize"` Path string `json:"path"` }
TouchCmd is holds touch command's variables.
func NewTouchCmdFromURLParam ¶
NewTouchCmdFromURLParam return a new TouchCmd with specified path.
func (*TouchCmd) ToURLParam ¶
ToURLParam encodes a TouchCmd to a URL encoding string.
func (*TouchCmd) ValidateCloudArgs ¶
ValidateCloudArgs checks the conditions when running on cloud.
func (*TouchCmd) ValidateLocalArgs ¶
ValidateLocalArgs check the conditions when running local.
type TouchResult ¶
type TouchResult struct {
Path string `json:"path"`
}
TouchResult represents touch-command's result.