命令:hyperspace [hyperspace_ip:port]。
hyperspace命令可连接至hyperspace,并执行下列命令:
mkdir ............. Creates a directory in Hyperspace
mkdirs ............ Creates all paths leading upto and including directory in Hyperspace
delete ............ Delete file/directory
open .............. Open a file/directory
create ............ Create a file
close ............. Close previously opened file/directory
attrset ........... Set an attribute (key/value pair) for a file/directory
attrget ........... Retrieve an attribute for a file/directory
attrincr........... Atomically increment the value of an attribute (assumed uint64)
attrexists ........ Check if a particular attribute is set for a file/directory
attrlist .......... Retrieve all attributes (keys only) for a file/directory
attrdel ........... Delete an attribure for a file/directory
exists ............ Check if a file/directory exists
readdir ........... List the contents of a previously opened directory
readdirattr ....... List the contents of a previously opened directory which has
....... the named attribute set and the value of the attribute
readpathattr ...... List the values of an attribute for each path component of a
....... previously opened file/directory
lock .............. Lock access to a file/directory
trylock ........... Check whether a lock on file/directory would succeed
release ........... Release previously acquired lock
getseq ............ Get a lock sequencer for a file/directory
echo .............. Echo user input
locate ............ Get the location of Hyperspace Master or all Replicas
dump .............. Dump contents of hyperspace
1 MKDIR(S)
mkdir <dir>
创建指定的目录
mkdirs <dir>
创建指定的整个目录层次
2 Open、close
open <fname> flags=[READ|WRITE|LOCK|CREATE|EXCL|TEMP|LOCK_SHARED|LOCK_EXCLUSIVE] [event-mask=<mask>]
示例:open /hyperspace flags=read event-mask=attr_set;
实验表明:readdir、attr命令族(attrlist、attrset、attrget、attrdel、readdirattr、readpathattr等)使用前必须首先open命令操作指定的文件或者目录。
close <file>
示例:close /hyperspace;
3 Create、delete、exists
create <fname> flags=[READ|WRITE|LOCK|TEMP|LOCK_SHARED|LOCK_EXCLUSIVE] [OPTIONS]
OPTIONS:
attr:<name>=<value> This can be used to specify extended attributes that should
get created atomically when the file is created
event-mask=<mask> This indicates which events should be delivered on this handle.
The <mask> value can take any combination of the following:
ATTR_SET|ATTR_DEL|LOCK_ACQUIRED|LOCK_RELEASED
创建一个文件,并打开该文件。
示例:create /testdir/newfile flags=write attr: generation ="5" event-mask=attr_set;
实验表明:value两边必须加引号。文件创建后,无需open,即可进行attrset等操作。
exists <name>
delete <dir>
实验表明:不能删除一个已经open的目录或文件,并且不能删除一个非空的目录。
4 Attrset、attrget、attrincr、attrexists、attrlist、attrdel
attrset <file> <name>=<value> [i16|i32|i64]
示例:attrset /testdir/newfile location ="rs2";
实验表明:[i16|i32|i64]出错,例如attrset /testdir/newfile generation ="2" i16;报错“Error: Hypertable::Exception: parse error at: i16 - HYPERSPACE CLI parse error”。
attrget <file> <name> [int|short|long]
示例:attrget /testdir/newfile generation;
实验表明:[int|short|long]出错,例如attrget /testdir/newfile generation int;报错“Error: Hypertable::Exception: parse error at: int - HYPERSPACE CLI parse error”。
attrincr <file> <name>
示例:attrincr /testdir/newfile generation;
实验表明:如果属性值不是数字,将会出错。
attrexists <file> <name>
示例:attrexists /testdir/newfile location;
attrlist <file>
示例:attrlist /testdir/newfile;显示结果为
generation
location
lock.generation
实验表明:任一文件或者目录都有lock.generation属性,但该属性不能查看,即通过attrget查看该属性时会报错。
attrdel <file> <name>
示例:attrdel /testdir/newfile generation;
5 Readdir、Readdirattr、readpathattr
readdir <dir>
实验表明:hyperspace上的目录结构为
hyperspace
metadata
hypertable
master
namemap
ids
namespace编号
表编号
names
namespace名称
表名称
root
servers
RangeServer标记,例如:rs1
Tables
namespace编号
表编号
readdirattr [-r] <dir> <name>
列出dir所指定的目录结构,并显示name所指定的属性值。-r表示对子目录也递归的进行类似操作。
示例:
readdirattr /testdir generation;显示结果为
(dir) abd
newfile, generation=2
newfile1
(dir) newfolder, generation=3
readdirattr -r /testdir generation; 显示结果为
(dir) abd
newfile, generation=2
newfile1
(dir) newfolder, generation=3
+ newfile, generation=1
readpathattr <dir> <name>
自dir所指定目录或文件,逐层向上,列出name属性的值。
示例:readpathattr /testdir/newfolder/newfile generation; 显示结果为
(dir) /
(dir) /testdir/
(dir) /testdir/newfolder/, generation=3
/testdir/newfolder/newfile, generation=1
6 Lock、trylock、release、getseq
lock <file> <mode>
trylock <file> <mode>
The <mode> argument may be either SHARED or EXCLUSIVE.
示例:
open /testdir/newfile flags=WRITE|LOCK_SHARED;
lock /testdir/newfile shared;
输出结果:SEQUENCER name=/testdir/newfile mode=1 generation=22
试验表明:如果要lock或者trylock一个文件或者目录,必须首先open这个文件或者目录,并且open命令的flags参数必须至少包含:WRITE|LOCK(也可用LOCK_SHARED或LOCK_EXCLUSIVE替代LOCK)。
当测试获取EXCLUSIVE锁时,不但操作长久不能响应,而且导致整个集群的所有非Hyperspace机器提示“hyperspace session expired”,必须重启集群才可以恢复正常。
对于前文提及的“lock. Generation”,从此处的测试中推断应该为输出结果中的generation,例如上例中的“generation=22”。
release <file>
试验表明:对于已经lock或者trylock一个文件或者目录,如果再次lock或者trylock,则会提示“HYPERSPACE already locked”。必须执行release操作后,才能再次加锁。当然,如果是对同一个文件或者目录的再次open,则可直接进行加锁。
getseq <file>
试验表明:该命令输出的结果类似于“SEQUENCER name=/testdir/newfile mode=1 generation=22”格式。
7 dump
dump <path> [AS_COMMANDS] [output_file]
导出Hyperspace指定路径下所有的内容到output_file,如果没有指定output_file,则默认导出到标准输出设备。AS_COMMANDS选项将使输出的内容中附带Hyperspace shell命令,从而使得可以方便的重新导入到hyperspace中。导入时为了保持属性中的空格,可以使用类似“hyperspace --command-file dump_file”的命令格式。
示例:
dump /hyperspace;输出结果为
/hyperspace
/hyperspace/metadata
dump /hyperspace AS_COMMANDS; 输出结果为
MKDIRS /hyperspace;
OPEN /hyperspace FLAGS=READ|WRITE|CREATE ;
OPEN /hyperspace/metadata FLAGS=READ|WRITE|CREATE ;
dump /hyperspace AS_COMMANDS "/tmp/1.tsv"; 导出内容到文件,文件必须用引号进行限定。